Page 1 of 1

nagios result different from command line

Posted: Thu Apr 08, 2010 3:50 pm
by 9000233309
Nagios running on centos 5.3
Oracle 9i running on AIX (not sure what version)

Running a simple script to get resource utilization from the oracle database. Script runs fine from the command line as either root or nagios user. When I run it from nagios I get *ERROR* cannot determine resource utilization which is the first evaluation criteria to catch a null result. I've tried this on two different systems with the same result. While troubleshooting I hard coded all of the variables, also with the same result.

Here is the script I'm running:

#! /bin/sh

PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
. $PROGPATH/utils.sh


command_output=`
sqlplus USER/PASSWORD@"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx.26.48.40)(PORT=1526)))(CONNECT_DATA=(SID=ETM)))"<<EOF
select count(*) FROM (select DISTINCT ac.sensor_oid, ac.channel from active_call ac, channel ch WHERE to_char(ac.end_time) = '1970-01-01 00:00:00.0' or (ac.end_time >= current_timestamp - INTERVAL '1' minute and ac.end_time <= current_timestamp) and ch.trunk_group = 'ATT');
exit
EOF`
rutail=`echo "$command_output" | tail -3`
ru=`echo "$rutail" | head -n 1`

if [ -z "$ru" ]; then
echo "*ERROR* Cannot Determine current Resource Utilization."
exit $STATE_UNKNOWN
fi
if [ "$ru" -le "334" ]; then
echo "Resource Utilization for Span Group $SPAN_GROUP is $ru."
exit $STATE_OK
fi

if [ "$ru" -le "568" ]; then
echo "*WARNING* Resource Utilization for Span Group $SPAN_GROUP is $ru."
exit $STATE_WARNING
fi

if [ "$ru" -gt "0" ]; then
echo "*CRITICAL* Resource Utilization for Span Group $SPAN_GROUP is $ru."
exit $STATE_CRITICAL
fi
echo "*UNKNOWN* Cannot Determine current Resource Utilization."
exit $STATE_UNKNOWN