dangmocrang / check_idrac

A script to monitoring DELL IDRAC via SNMP
Other
74 stars 53 forks source link

Fix improper numberic comparisons on threshold checks. #27

Closed ovidiustanila closed 8 years ago

ovidiustanila commented 8 years ago

When using warning/critical limits, e.g.: ./idrac_2.2rc4 -p -H x.x.x.x -v2c -c public -m /idrac-smiv2.mib -w SENSOR#4 --temp-warn 29,40 --temp-crit 25,75 , the (!)/(!!) string is added to the numeric recorded value of the monitored value: tmp[key][stat_t] += '(!)'

Later threshold checks fail after this is added with the following error: Traceback (most recent call last): File "./idrac_2.2rc4", line 841, in result, exit_code = PARSER().main() File "./idrac_2.2rc4", line 679, in main hw_dict, exit_code = self.raise_alert(hw_dict, value_on_alert) File "./idrac_2.2rc4", line 582, in raise_alert if float(tmp[key][stat_t]) <= conf['sensor_thresholds'][0]:

As a workaround I've stripped these characters from the recorded value:

if float(tmp[key][stat_t]) <= conf['sensor_thresholds'][0]:
if float(tmp[key][stat_t].strip('(!)')) <= conf['sensor_thresholds'][0]: Used this for all threshold checks.

Maybe there's a better way to do it, but this did the trick for us.

Regards, Ovidiu

dangmocrang commented 8 years ago

Hi,

This is because of incorrect result returned by idrac since i only add '(!)' after comparison as you see in the code. But this is good, since i don't know all possible return from many of idrac types.

Thank you.