Skip to content

ValueError: could not convert string to float: "CPU1 Temp" #79

@Be-Shary

Description

@Be-Shary

If serwer if in standby mode, script cant read sensor temp. So i have that error:

Traceback (most recent call last):
File "/root/check_idrac.py", line 842, in
result, exit_code = PARSER().main()
File "/root/check_idrac.py", line 680, in main
hw_dict, exit_code = self.raise_alert(hw_dict, value_on_alert)
File "/root/check_idrac.py", line 568, in raise_alert
tmp[key][stat_t] = float(tmp[key][stat_t])/10
ValueError: could not convert string to float: "CPU1 Temp"

To fix it i add one IF at SENSOR reads:
elif self.hardware[2] == 'Sensor':
if str(tmp[key][2]) != "unknown(!)":
tmp[key][stat_t] = float(tmp[key][stat_t])/10
tmp[key][stat_t] = '%.1f' %tmp[key][stat_t]

Now when there will be no temp i will pass:
SENSOR
--System Board Inlet Temp: 19.0 C ENABLED/OK
--(n/a): "CPU1 TEMP" C UNKNOWN(!)/UNKNOWN(!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions