Skip to content

Only exit code 0 for plugin check_cpu_temp #2

@ssgoburdhun

Description

@ssgoburdhun

Hello bms8197,

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.

Server Specs:

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

I have manually forced the exit code at STATUS check:

    # 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?

Cheers,
Sarvesh.

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