[Nagiosplug-help] Fwd: Nagios plugin exit code not being read ?

Allie Daneman df at drainfade.com
Fri Feb 9 16:47:27 CET 2007


This is a weird one and I'm not even sure if it's a nagios issue or something else.. I'm running an lpq shell script that I found through the nagios exchange and it's not working. I modified the script a little but it exits with the correct exit code as per nagios docs but nagios doesn't see it...it thinks it exits with 0 every time. Here's the trace of the script that exits with 1 as the code. What am I missing ? All other plugins work ok...just mine is messed up ;)

+ LPR=lp
+ WARN=1
+ ERROR=5
+ lpq -P lp
+ wc -l
+ sed s/^ *//
+ sed s/ *$//
+ QUEUE=4
+ QUEUE=2
+ INFO=Queue(2)
+ [ 2 -ge 5 ]
+ [ 2 -ge 1 ]
+ echo WARNING - Queue(2)
WARNING - Queue(2)
+ exit 1

The script looks like so:
#! /bin/sh

LPR=$1
WARN=1
ERROR=5

QUEUE=`lpq -P $LPR | wc -l |  sed 's/^ *//' | sed 's/ *$//'`
QUEUE=$(($QUEUE-2))

INFO="Queue($QUEUE)"

if [ $QUEUE -ge $ERROR ]; then
        echo "CRITICAL - $INFO"
        exit 2
fi

if [ $QUEUE -ge $WARN ]; then
        echo "WARNING - $INFO"
        exit 1
fi

echo "OK - $INFO"
exit 0

I'm running these packages related to nagios:
nagios-2.5-chroot   host and service monitor
nagios-plugins-1.4.3p2 nagios base plugins
nagios-plugins-mysql-1.4.3 mysql plugin
nagios-web-2.5-chroot cgis and webpages for nagios

OS is OpenBSD 4.0

-- 
~Allie D.






More information about the Help mailing list