Thanks and big up for the plugin.
An issue was encountered where the check exited with code 0 even if status was WARNING and CRITICAL (not checked UNKNOWN).
So, via command line the WARNING can be seen successfully but the exit code is still 0:
root@theflash /usr/lib/nagios/plugins # ./check_cpu_temp
OK - CPU(s) temperature(s): 44°C 47°C; high=79.0; crit=89.0
root@theflash /usr/lib/nagios/plugins # ./check_cpu_temp -w 40 -c 70
WARNING - CPU(s) temperature(s): 44°C 47°C; high=40; crit=70
root@theflash (NEW) /usr/lib/nagios/plugins # echo $?
0
The issue is that one will not be alerted if the threshold is reached or exceeded. The check will always remain green and display OK.
Virtualization Technology: Proxmox
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
CPU(s): 40
Vendor ID: GenuineIntel
Model name: Intel(R) Xeon(R) Silver 4114 CPU @ 2.20GHz
root@theflash /usr/lib/nagios/plugins # uname -a
Linux theflash 5.0.21-2-pve #1 SMP PVE 5.0.21-6 (Fri, 27 Sep 2019 17:17:02 +0200) x86_64 GNU/Linux
# print statuses + output
if status == OK:
print("OK - " + output)
exit(0)
elif status == WARN:
print("WARNING - " + output)
exit(1)
elif status == CRIT:
print("CRITICAL - " + output)
exit(2)
except Exception as e:
print e
status = UNK
exit(3)
raise
However, I dont think its clean code but it works. Can you check and possibly update the check with necessary the code?