Page 1 of 1

nagios pluggin using bash script

Posted: Thu Dec 03, 2015 5:47 am
by venkitesh
Hi Team,

i am writing a bash script to monitor netapp volumes which are greater than 90%

Code: Select all

#!/bin/bash
OK=0
CRITICAL=2
sshpass -p 'test_user' ssh -o StrictHostKeyChecking=no -l test_user 10.0.01 'volume show -percent-used > 90%' |awk '{print $2,$6,$7,$8}' | column -t  >> strcritical
cat strcritical;
if [[ `cat strcritical` == *"your"* ]]
then
echo "OK"
exit $OK
rm -rf strcritical;
else
echo "CRITICAL"
rm -rf strcritical;
exit $CRITICAL;
fi
the ouput is getting as expected.

But even though i have given the exit codes for critical and ok in the script, nagiosxi is not understanding that.

When i am integating this with nagios xi, it is not changing the service state. Seems like some syntax issue.

Could you please how to change the above script make it work.

Regards
Venk

Re: nagios pluggin using bash script

Posted: Thu Dec 03, 2015 10:33 am
by tmcdonald
Two things. First, remove the cat strcritical; line as that will pollute your status output.

Second, you likely will want to switch these two lines:

Code: Select all

exit $OK
rm -rf strcritical;
to this

Code: Select all

exit $OK
rm -rf strcritical;
otherwise your script is exiting before it can clean up the strcritical file. You might also consider using > instead of >> for the output saving, unless you need to keep the history in that file.

Re: nagios pluggin using bash script

Posted: Fri Jan 29, 2016 12:55 am
by venkitesh
hi team,

Thanks it worked!!

i am getting an error message in my nagios xi server

nagios: Warning: Service performance data file processing command '/bin/mv /usr/local/nagios/var/service-perfdata /usr/local/nagios/var/spool/xidpe/1454046093.perfdata.service' timed out after 5 seconds

Please help

Regards
Venkitesh

Re: nagios pluggin using bash script

Posted: Fri Jan 29, 2016 11:49 am
by rkennedy
What happens if you increase your perfdata_timeout=5 to 20 in your nagios.cfg?

After that, restart your nagios service. Let us know if that works.