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?
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”