Hi all,
I have written a Python plugin to check our NetApp devices using SNMP. If I run it on the command line on my linux Nagios server it runs fine:
[root@monitor netapp-snmp]# /opt/nagios/libexec/check_netapp_disks.py -H netapp1 -o /vol/test1/ -w 80 -c 90
OK - /vol/test1/ - total: 250 Gb - used 6 Gb (2%) - free: 243 Gb|NetApp /vol/gate/ Used Space=6GB;160;180;0;250
But when I add it in to Nagios commands.cfg it returns “null” in the Nagios GUI:
define command{
command_name check-swe-test
command_line $USER1$/check_netapp_disks.py -H netapp1 -o /vol/test1/ -w 80 -c 90
}
For the return codes I use sys.exit in Python (0 for OK, 1 for Warning, 2 for Critical). I have written custom plugins before in shell scripts but this is my first Python one. Not sure where the issue would be exactly.
Here is the if-else where i specify the return code:
if state == 'OK':
print '%s - %s - total: %s Gb - used %s Gb (%s%%) - free: %s Gb|NetApp %s Used Space=%sGB;%s;%s;0;%s' % (state, volume, total, used, used_p, avail, volume, used, warn_p, crit_p, total)
sys.exit(0)
elif state == 'WARNING':
print '%s - %s - total: %s Gb - used %s Gb (%s%%) - free: %s Gb|NetApp %s Used Space=%sGB;%s;%s;0;%s' % (state, volume, total, used, used_p, avail, volume, used, warn_p, crit_p, total)
sys.exit(1)
elif state == 'CRITICAL':
print '%s - %s - total: %s Gb - used %s Gb (%s%%) - free: %s Gb|NetApp %s Used Space=%sGB;%s;%s;0;%s' % (state, volume, total, used, used_p, avail, volume, used, warn_p, crit_p, total)
sys.exit(2)
else:
sys.exit(3)
Thanks!