We've been working on implementing SAP job monitoring. The last difficulty we face is returning the correct status codes to Nagios. I've tried simply "exit 0" or "exit 2" but it always returns the "OK" status. We run the below script to check if the output contains "ind". If it does not it should report CRITICAL. This job always breaks so there is no "ind" in the output. With the "echo "fout"" we made sure the IF statement was working correctly, which it is.
What are we doing wrong?
Code: Select all
STATE_OK=0
STATE_CRITICAL=2
output=$(/usr/local/nagios/libexec/check_sap job_de30mrprunextra pr1) 2>&1
if [[ $(/usr/local/nagios/libexec/check_sap job_de30mrprunextra pr1) =~ "ind" ]]
then
echo "goed"
# echo $output | tr --delete '|'
exitstatus=$STATE_OK
exit $exitstatus
else
echo "fout"
# echo $output | tr --delete '|'
exitstatus=$STATE_CRITICAL
exit $exitstatus
fi
Code: Select all
DE30 MRP RUN (15:00 EXTRA) History = DE30 MRP RUN (15:00 EXTRA) | 15000002 | Afgebroken, started at 2017-02-22,15:00:30 terminated at 2017-02-22,15:01:15
Dennis Lans