We have a problem with multiple services (different scripts). They exit with exit code 2 but Nagios still presents them with a green icon (OK status).
We can force an error by locking a specific account on a oracle database.
SIDNR=$1
ORATAB=/etc/oratab
VLGNR=0
# extract maken van 2e parm die mode= bevat; nodig voor uniek maken van chkfile
MODE=`echo "$2" | awk -F= '{print $2}' -`
CHKFILE="/tmp/check_oracle_health_$SIDNR$MODE.dat"
rm $CHKFILE
cat $ORATAB | while read LINE
do
case $LINE in
*\#*) ;; #comment-line in oratab
*)
if [ "`echo $LINE | awk -F: '{print $3}' -`" != "A" ] ; then
if [ "`echo $LINE | awk -F: '{print $3}' -`" = "Y" ] ; then
VLGNR=$((VLGNR + 1))
if [ "$VLGNR" = "$SIDNR" ] ; then
DB=`echo $LINE | awk -F: '{print $1}' -`
OH=`echo $LINE | awk -F: '{print $2}' -`
ID="nagios/nagios@"$DB
PARM=$2" "$3" "$4" "$5" "$6" --connect="$ID" --environment=ORACLE_HOME="$OH
# echo "Db "$DB
# echo "parm:" $PARM
# echo "volgnr sid:" $VLGNR" en parm is "$1" en sid is "$DB
touch $CHKFILE
UITVOER=`/beheer/scripts/nagios/check_oracle_health $PARM`
echo "${UITVOER}"
if [ "`echo ${UITVOER} | awk '{print $4}' -`" = "CRITICAL" ] ; then
exit 2
fi
if [ "`echo ${UITVOER} | awk '{print $4}' -`" = "OK" ] ; then
exit 0
fi
# RET=$?
# exit $RET
echo "Hier komen is niet mogelijk"
exit 1
fi
fi
fi
;;
esac
done
# Parameters in de while-loop zijn erbuiten niet op te vragen
# Daarom werken we met het wel/niet bestaan van een bestandje
if [ ! -f "$CHKFILE" ] ; then
echo "Oracle check sid-volgnr $SIDNR: CRITICAL"
echo "Geen ORATAB-entry $SIDNR gevonden op: " `date`
exit 2
fi
I've tested this on Nagios XI 2012 v1.6 en v2.3. Same result. We use the CentOS 64bit vsphere appliance from your website.
You do not have the required permissions to view the files attached to this post.
Last edited by fogier on Thu May 08, 2014 3:19 am, edited 1 time in total.
Looks like to me that the "exit 2" is being returned as text instead of an exit code. It should not appear in the text returned as you can see in the one image you attached. Can't see why that's happening in the script, but haven't looked hard yet.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
I've editted the script in the meanwhile. We've added echo "exit 2" to the script to see it's really ending there.
After that, we've removed it again as you can see in the script. Sorry for the misunderstanding.
So at this point is it working, or are you still having difficulties?
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.