custom Nagios check script not returning value to Nagios
Posted: Fri May 31, 2013 1:28 pm
I'm having trouble running a custom Nagios check script that I created for Nagios. The purpose of the script is to check for a degraded state in on our MegaRAID cards and report it back to Nagios.
On my server that this script runs on, I have given Nagios sudo access with no password) to ONLY this script and the MegaCLi64 binary, since MegaCLi64 will only report the data back if you run at the root user. Now here here an interesting twist:
If I run this script locally on the server, it runs fine and returns the proper error code.
[root@nas1 nrpe_raid_monitor]# su nagios
sh-3.2$ ./raid_monitoring_megaraid.sh
CRITICAL: RAID Errors Present
However if I run the script through NRPE/Nagios, it always returns as if the status is OK, even though it isn't.
Any thoughts on what I could be doing wrong. This is the first time I've ever written custom Nagios checks so I may be doing something wrong.
Any help would be greatly appreciated. Thanks!
Code: Select all
# Get status of RAID card
COUNT=`sudo /usr/local/bin/MegaCli64 -LDInfo -Lall -aALL|grep Degraded|wc -l`
if [ $COUNT -ge 1 ]
then
echo "CRITICAL: RAID Errors Present"
exit 2
else
echo "OK: No Errors Found"
exit 0
fiIf I run this script locally on the server, it runs fine and returns the proper error code.
[root@nas1 nrpe_raid_monitor]# su nagios
sh-3.2$ ./raid_monitoring_megaraid.sh
CRITICAL: RAID Errors Present
However if I run the script through NRPE/Nagios, it always returns as if the status is OK, even though it isn't.
Any thoughts on what I could be doing wrong. This is the first time I've ever written custom Nagios checks so I may be doing something wrong.
Any help would be greatly appreciated. Thanks!