if $volt -ge 200 ] ; then
echo “Input Voltage OK - $volt | iso.3.6.1.4.1.534.1.3.4.1.2.1=$volt”
elif $volt -lt 200 ] ; then
echo “Input Voltage CRITICAL - $volt | iso.3.6.1.4.1.534.1.3.4.1.2.1=$volt”
else
echo “Input Voltage problem - No data received from host”
fi[/code]
The script now returns the same as check_snmp (but with correct voltage), but when I give a invalid input it should return only “Input Voltage problem - No data received from host”, but instead it returns this:
$ ./mgeups 10.10.13.8
expr: non-numeric argument
./mgeups: line 4: : -ge: unary operator expected
./mgeups: line 7: : -lt: unary operator expected
Input Voltage problem - No data received from host
How do I avoid all this extra crap?
Can I just add a check command with “this_script $HOSTADDRESS$” in checkcommands.cfg, and that would work?
“Can I just add a check command with “this_script $HOSTADDRESS$” in checkcommands.cfg, and that would work?”
=> yes; it should work fine.
"How do I avoid all this extra crap?"
Well; the good thing is that all that crap is on the ERROR output; which nagios will not read it … so you will only have your “Input Voltage problem - No data received from host” line as output in nagios.
But yes, that’s not a really good way to do it.
To avoid this, you could test your exit code from the snmp command:
after the first line, add:
RET=$?
if $RET -ne 0 ]]
then
echo "Input Voltage problem - No data received from host"
exit 3
fi
let me know if this doesn’t work (I’m at work and shouldn’t take time to answer, so i didn’t check if this is correct)