I have a python plugin, basic code below. I run it fine from the command line as nagios, and from cron as nagios. But when I try and let nagios run it, it gives me the dread warning:(null).
Please note that I've commented out the test here: It should be doing nothing but returning OK:
#!/usr/bin/python
import sys
import boto
import boto.rds
import os
import getopt
import subprocess
status = { 'OK' : 0 , 'WARNING' : 1, 'CRITICAL' : 2 , 'UNKNOWN' : 3}
host = sys.argv[1]
warn_limit = int(sys.argv[2])
#warn_limit = 80
crit_limit = int(sys.argv[3])
#crit_limit = 85
conn = boto.rds.connect_to_region(XXXXXX')
instances = conn.get_all_dbinstances(host)
db = instances[0]
dblocation = db.endpoint[0]
alloc = db.allocated_storage
used = subprocess.Popen([ "/usr/local/nagios/libexec/mysqlsize.sh", host ], stdout=subproc
ess.PIPE).communicate()[0]
allocf = float(alloc)
usedf = float(used)
percent = usedf / allocf
percenttest = percent * 100
percentprint = "%.2f" % percenttest
warn=False
if percenttest >= warn_limit :
warn = True
crit=False
if percenttest >= crit_limit:
crit = True
#if warn == True:
#
# if crit == True:
# print "Critical: Disk Usage at " + percentprint + "%"
# sys.exit(status['CRITICAL'])
# else:
# print "Warning: Disk Usage at " + percentprint + "%"
# sys.exit(status['WARNING'])
#
#.else:
# print "OK: Disk Usage at " + percentprint + "%"
print "OK"
sys.exit(status['OK'])
Running Nagios Core 3.5.1 in AWS.
Any suggestions?
Stumped with a plugin problem
-
slansing
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: Stumped with a plugin problem
Have you tried throwing an echo in after the first function, and then moving it lower in the script as you retry? This should tell you roughly what line is bailing out.