<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><DIV>I have a script that I wrote that will parse through a log looking for instances of the word "error" and count them.<BR><BR>If there are zero instances of the word, I expect a green (STATE_OK) status. If there are 1 or more instances of the word "error", I expect to see a red (STATE_CRITICAL) status. Currently the script appears to work fine from the command line, below are the final few lines of output from the script when I have "set -x" turned on for debugging.<BR><BR>+ EXITMESSAGE= 20 errors found<BR>+ EXITSTATUS=2<BR>+ [[ 2 -eq 0 ]]<BR>+ echo 20 errors found<BR>20 errors found<BR>+ exit 2<BR><BR>Currently, on the Nagios web interface, the server is showing "Yellow" (warning status) and
the "Status Information" column has an output showing of the word "null". I feel that my issue may be a quoting issue or something simple I am overlooking. Below is my
script:<BR></DIV>
<DIV><FONT face="Courier New">#!/bin/ksh<BR><BR>set -x<BR><BR>GREPCMD=/usr/bin/grep<BR>SSHCMD=/usr/bin/ssh<BR>ECHOCMD=/usr/bin/echo<BR>NAGIOSDIR=/space/nagios<BR><BR>STATE_OK=0<BR>STATE_WARNING=1<BR>STATE_CRITICAL=2<BR>STATE_UNKNOWN=3<BR>STATE_DEPENDENT=4<BR><BR>EXITMESSAGE='ERROR'<BR><BR>while getopts :s:u:h: OPT<BR>do<BR>case $OPT in<BR> s|+s ) export SERVER=$OPTARG ;;<BR> u|+u ) export USER=$OPTARG ;;<BR> : ) $ECHO "$OPTARG requires an argument"; exit $STATE_UNKNOWN;;<BR> \? ) $ECHO "$OPTARG: bad option, use -h for help"; exit $STATE_UNKNOWN;;<BR> h|+h ) $ECHO "Usage: `basename $0` -w WARNSTATES -c CRITICALSTATES -s SERVER -u USER" ; exit $STATE_UNKNOWN;
;<BR>esac<BR><BR>done<BR><BR>if [ -z "$SERVER" ]; then<BR> EXITMESSAGE="No SERVER specified"<BR> echo $EXITMESSAGE<BR> exit
$STATE_UNKNOWN<BR>fi<BR><BR>PING_STATUS=`ping $SERVER | grep -c alive`<BR>if [ $PING_STATUS -ne 1 ]; then<BR>echo "Cannot ping $SERVER"<BR>exit $STATE_UNKNOWN<BR>fi<BR><BR>SSH_STATUS=`$NAGIOSDIR/libexec/check_tcp -H $SERVER -p 22 | grep -ic "TCP OK"`<BR>if [ $SSH_STATUS -ne 1 ]; then<BR> EXITMESSAGE="Cannot ssh to $SERVER"<BR> echo $EXITMESSAGE<BR> exit $STATE_UNKNOWN<BR>fi<BR>export CNT="$(/usr/bin/ssh -n -o BatchMode=yes -o StrictHostKeyChecking=no -l ${USER} ${SERVER} "cat /opt/app/my.log | \<BR> sed -n 's/.* Error \[.*/Found One/p' | wc -l")"<BR><BR>if [[ $CNT -eq 0 ]]; then<BR> EXITMESSAGE="No errors found"<BR> EXITSTATUS="${STATE_OK}"<BR>elif [[ $CNT -gt 0 ]]; then<BR>&
nbsp; EXITMESSAGE="${CNT} errors found"<BR> EXITSTATUS="${STATE_CRITICAL}"<BR>else<BR> EXITSTATUS="${STATE_UNKNOWN}"<BR>fi<BR><BR>if [[
$EXITSTATUS -eq $STATE_OK ]]; then<BR> EXITMESSAGE="No errors found"<BR>fi<BR><BR>echo $EXITMESSAGE<BR>exit $EXITSTATUS</FONT></DIV>
<DIV><FONT face="Courier New"></FONT> </DIV>
<DIV><FONT face="Courier New">Any input would be appreciated.</FONT></DIV></td></tr></table><br>