nagios pluggin using bash script

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
venkitesh
Posts: 67
Joined: Tue Jan 27, 2015 12:34 am

nagios pluggin using bash script

Post 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
Last edited by tmcdonald on Thu Dec 03, 2015 10:30 am, edited 1 time in total.
Reason: Please use [code][/code] tags around long output
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: nagios pluggin using bash script

Post 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.
Former Nagios employee
venkitesh
Posts: 67
Joined: Tue Jan 27, 2015 12:34 am

Re: nagios pluggin using bash script

Post 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
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: nagios pluggin using bash script

Post 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.
Former Nagios Employee
Locked