Problem with check_nrpe and tnsping


#1

Hi there,
I have a problem with the checks, it seems locally works but when nagios call the nrpe fails.
Enviroment example:
NAGIOS CENTRAL:
/usr/local/nagios/libexec/check_nrpe -H xx.xxx.xxx.xxx -c check_tnsping
No TNS Listener on SID

LOCAL HOST:
/usr/local/nagios/libexec/check_oracle2 --tns SID
OK - reply time 0 msec from SID

The services.cfg in nagios central calls to check_oracle2 in localhost via NRPE, all ths stuff is ok.

Any idea?

The script is a modifu of check_oracle :

–tns)
tnschk=tnsping $2
tnschk2=echo $tnschk | grep -c OK
if ${tnschk2} -eq 1 ] ; then
tnschk3=echo $tnschk | sed -e 's/.*(//' -e 's/).*//'
echo "OK - reply time ${tnschk3} from $2"
exit $STATE_OK
else
echo "No TNS Listener on $2"
exit $STATE_CRITICAL
fi
;;

I think the FAIL is at the comparisson : if ${tnschk2} -eq 1 ] ; then
but why works local and not when call from nrpe?

Thanks and excuse my poor english


#2

Hi!

usually, this happen when an environment variable is missing.
Maybe you should add the variables you need at the beginning of your script, like “ORACLE_HOME=/my_path/to_oracle”

or, the problem may also come from the fact that nrpe doesn’t know all the paths, like the path to tnsping.
=> you should always use full paths in your nrpe/nagios scripts
the line “tnschk=tnsping $2” should become “/my_path/_to_somewhere/tnschk=tnsping $2

hope this helps


#3

Hi,
The enviroment variables al well defined at the beginning of the script.

I


#4

Part of the script

#! /bin/sh

latigid010@yahoo.com

01/06/2000

This Nagios plugin was created to check Oracle status

PROGNAME=basename $0
PROGPATH=echo $0 | sed -e 's,\\/]^\\/]^\\/]*$,,'
REVISION=echo '$Revision: 1749 $' | sed -e 's/^0-9.]//g'

ORACLE_BASE=/u01/app/oracle;export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1;export ORACLE_HOME
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib:/lib:/usr/local/lib:/usr/X11R6/lib;export LD_LIBRARY_PATH
PATH=/usr/bin:/bin:/usr/local/bin:/usr/sbin:/sbin:$ORACLE_HOME/bin:/usr/bin/X11:/etc:JAVA_HOME/bin:$ORACLE_HOME/perl/bin;export PATH

.
.
.

–tns)
echo antes de realizar el ping > /tmp/nagios_debug.log
tnschk=/u01/app/oracle/product/10.2.0/db_1/bin/tnsping $2
echo $tnschk >> /tmp/nagios_debug.log
tnschk2=echo $tnschk | grep -c OK
echo $tnschk2 >> /tmp/nagios_debug.log
if $tnschk2 -eq 1 ] ; then
echo paso3 >> /tmp/nagios_debug.log
tnschk3=echo $tnschk | sed -e 's/.*(//' -e 's/).*//'
echo "OK - reply time ${tnschk3} from $2"
exit $STATE_OK
else
echo "No TNS Listener on $2"
exit $STATE_CRITICAL
fi
;;

Works only localy…
When execute from nrpe call it fails…