Skip to content

Commit 886ad1f

Browse files
committed
fixes issue with inconsistent temperature perf data output
1 parent 43b0541 commit 886ad1f

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

cr_module/temp.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,27 +100,25 @@ def get_single_chassi_temp(redfish_url, chassi_id, thermal_data):
100100

101101
temp_num += 1
102102

103-
if str(warning_temp) in ["0", "0.0", "N/A"]:
104-
warning_temp = None
103+
if isinstance(warning_temp, (int, float)):
104+
warning_temp = int(warning_temp)
105105

106-
if warning_temp is not None and float(current_temp) >= float(warning_temp):
107-
status = "WARNING"
106+
if 0 > current_temp >= warning_temp:
107+
status = "WARNING"
108108

109-
if str(critical_temp) in ["0", "0.0", "N/A"]:
110-
critical_temp = None
109+
if isinstance(critical_temp, (int, float)):
110+
critical_temp = int(critical_temp)
111111

112-
if critical_temp is not None and float(current_temp) >= float(critical_temp):
113-
status = "CRITICAL"
112+
if 0 > current_temp >= critical_temp:
113+
status = "CRITICAL"
114114

115-
critical_temp_text = "N/A"
116-
if critical_temp is not None:
117-
critical_temp_text = "%.1f" % float(critical_temp)
118115

119116
if system_power_state != "ON":
120117
status = "OK"
121118

122-
status_text = f"Temp sensor {temp_inventory.name} status is: " \
123-
f"{status} (%.1f °C) (max: {critical_temp_text} °C)" % current_temp
119+
status_text = f"Temp sensor {temp_inventory.name} status is: {status} ({current_temp} °C)"
120+
if critical_temp is not None:
121+
status_text += f" (max: {critical_temp} °C)"
124122

125123
plugin_object.add_output_data("CRITICAL" if status not in ["OK", "WARNING"] else status, status_text,
126124
location=f"Chassi {chassi_id}")
@@ -129,7 +127,7 @@ def get_single_chassi_temp(redfish_url, chassi_id, thermal_data):
129127
if num_chassis > 1:
130128
temp_name = f"{chassi_id}.{temp_name}"
131129

132-
plugin_object.add_perf_data(f"temp_{temp_name}", float(current_temp), warning=warning_temp,
130+
plugin_object.add_perf_data(f"temp_{temp_name}", current_temp, warning=warning_temp,
133131
critical=critical_temp, location=f"Chassi {chassi_id}")
134132

135133
if len(thermal_data.get("Temperatures")) > 0:

0 commit comments

Comments
 (0)