Skip to content

Commit

Permalink
Simplify the fetch exception on redfish (#79)
Browse files Browse the repository at this point in the history
When any exception happens during redfish fetch the metric
redfish_call_success is set to 0 that will trigger Prometheus
alerts.
  • Loading branch information
gabrielcocenza authored Aug 1, 2024
1 parent 5ddd4d2 commit 3ce26fe
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions prometheus_hardware_exporter/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
from typing import Any, Dict, List

from prometheus_client.metrics_core import GaugeMetricFamily, InfoMetricFamily
from redfish.rest.v1 import (
InvalidCredentialsError,
RetriesExhaustedError,
SessionCreationError,
)

from .collectors.dmidecode import Dmidecode
from .collectors.ipmi_dcmi import IpmiDcmi, IpmiTool
Expand Down Expand Up @@ -1041,13 +1036,7 @@ def fetch(self) -> List[Payload]:
smart_storage_health_data: Dict[str, Any] = (
redfish_helper.get_smart_storage_health_data()
)
except ( # pylint: disable=W0718
ConnectionError,
InvalidCredentialsError,
RetriesExhaustedError,
SessionCreationError,
Exception,
) as err:
except Exception as err: # pylint: disable=broad-exception-caught
logger.exception("Exception occurred while using redfish object: %s", err)
payloads.append(Payload(name="redfish_call_success", value=0.0))
return payloads
Expand Down

0 comments on commit 3ce26fe

Please sign in to comment.