improve error handling
This commit is contained in:
parent
01c44aa2fe
commit
ff206c24cb
15
main.py
15
main.py
@ -17,7 +17,6 @@ from targets.memory import *
|
|||||||
import targets.power
|
import targets.power
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import traceback
|
|
||||||
|
|
||||||
NAMESPACE = 'ilo'
|
NAMESPACE = 'ilo'
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ if args.quiet and args.verbose:
|
|||||||
print('stop it. (--quiet and --verbose do not mix)')
|
print('stop it. (--quiet and --verbose do not mix)')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
SCAN_FAIL_COUNTER = Counter('exporter', 'Number of times scanning the iLO for SNMP variables has failed.', namespace=NAMESPACE, subsystem='snmp_scan_failures')
|
SCAN_FAIL_COUNTER = Counter('scrape_failures', 'Number of times scraping the iLO for SNMP variables has failed.', namespace=NAMESPACE, subsystem='exporter')
|
||||||
|
|
||||||
|
|
||||||
def noisy(*a, **kwa):
|
def noisy(*a, **kwa):
|
||||||
@ -76,14 +75,9 @@ class BulkCollector(Collector):
|
|||||||
def collect(self):
|
def collect(self):
|
||||||
cache = {}
|
cache = {}
|
||||||
|
|
||||||
if self._scan_on_collect:
|
|
||||||
try:
|
try:
|
||||||
|
if self._scan_on_collect:
|
||||||
self.scan()
|
self.scan()
|
||||||
except Exception as e:
|
|
||||||
traceback.print_exception(e)
|
|
||||||
print('Failed to scan SNMP, aborting collection')
|
|
||||||
SCAN_FAIL_COUNTER.inc()
|
|
||||||
return
|
|
||||||
|
|
||||||
for documentation, bulk_values, bulk_labels in self._metrics_groups:
|
for documentation, bulk_values, bulk_labels in self._metrics_groups:
|
||||||
metric_name = self._name_template % bulk_values.name
|
metric_name = self._name_template % bulk_values.name
|
||||||
@ -120,6 +114,11 @@ class BulkCollector(Collector):
|
|||||||
|
|
||||||
yield metric
|
yield metric
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print('Failed to scan SNMP, aborting collection')
|
||||||
|
SCAN_FAIL_COUNTER.inc()
|
||||||
|
raise e
|
||||||
|
|
||||||
|
|
||||||
def get_power_draw() -> float:
|
def get_power_draw() -> float:
|
||||||
verbose('collecting ilo_server_power_draw')
|
verbose('collecting ilo_server_power_draw')
|
||||||
|
Loading…
Reference in New Issue
Block a user