Page 1 of 1

Stumped with a plugin problem

Posted: Wed Dec 18, 2013 7:01 pm
by steven_schwartz
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?

Re: Stumped with a plugin problem

Posted: Thu Dec 19, 2013 10:40 am
by slansing
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.