checks fails at one script callback second script

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
ganeshanrs1983
Posts: 55
Joined: Wed Jun 18, 2014 10:16 am

checks fails at one script callback second script

Post by ganeshanrs1983 »

hello,

We have to implement nagios monitoring for the below test script. Let me know how to implement if check fails at first script we need to callback second script. Any ideas ?

•Check looks for “i_am_here” in /tmp

#!/bin/bash
if [[ -e “/tmp/i_am_here” ]]
then
exit 0;
else
exit 1;
fi
•On fail do the following execute “restart script” callback

#!/bin/bash
date >> /tmp/restart_test
date >> /tmp/i_am_here

if [[ -e “/tmp/i_am_here” ]]
then
exit 0;
else
exit 1;
fi
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: checks fails at one script callback second script

Post by tmcdonald »

We have a great doc on exactly this:

http://assets.nagios.com/downloads/nagi ... ios-XI.pdf
Former Nagios employee
ganeshanrs1983
Posts: 55
Joined: Wed Jun 18, 2014 10:16 am

Re: checks fails at one script callback second script

Post by ganeshanrs1983 »

Thanks will check the link.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: checks fails at one script callback second script

Post by slansing »

Let us know if you need help implementing an event handler, a lot of it is going to be down to the architecture on your side though.
ganeshanrs1983
Posts: 55
Joined: Wed Jun 18, 2014 10:16 am

Re: checks fails at one script callback second script

Post by ganeshanrs1983 »

Yes i need help in implementing the event handler. Below is our new requirement could you please provide the steps how to implement monitoring in Nagios XI.
If apache/tomcat process stopped in server Nagios has to start the apache/tomcat process. If restart fails , halt monitoring and set as critical.

1.Run check script
2.Send result to OS client
3. If failure detected attempt restart for apache/tomcat
4. If restart fail, halt monitoring and set as critical
5.Forward result to monitoring station
6. Report on restart status using standard framework
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: checks fails at one script callback second script

Post by sreinhardt »

You would use the check script as normal via a standard service check. You would handle the rest with a single event handler. My suggestion, since this is not local to the nagios system, would be to configure check_by_ssh to call a script on the remote system that will perform all the needed steps such as restarting services and checking things. If you need it to forward checks, having that event handler call the check script you originally ran and use send_nrdp to forward back to nagios would be relatively easy, but you could also let nagios use the retry check to do a second much quicker check instead. That way you wouldn't have to include additional unneeded logic and nagios would still get results before and after the repair event handler was run.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
ganeshanrs1983
Posts: 55
Joined: Wed Jun 18, 2014 10:16 am

Re: checks fails at one script callback second script

Post by ganeshanrs1983 »

Below is my requirement. Could you please explain briefly in steps how to implement Nagios monitoring.

We have to implement nagios monitoring for the below test script. Let me know how to implement if check fails at first script we need to callback second script. Any ideas ?

•Check looks for “i_am_here” in /tmp

#!/bin/bash
if [[ -e “/tmp/i_am_here” ]]
then
exit 0;
else
exit 1;
fi

-----------------------------------------------------------------------------------------
•On fail do the following execute “restart script” callback

#!/bin/bash
date >> /tmp/restart_test
date >> /tmp/i_am_here

if [[ -e “/tmp/i_am_here” ]]
then
exit 0;
else
exit 1;
fi
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: checks fails at one script callback second script

Post by tmcdonald »

The document I linked explains step-by-step how to add an event handler to a service check.
Former Nagios employee
ganeshanrs1983
Posts: 55
Joined: Wed Jun 18, 2014 10:16 am

Re: checks fails at one script callback second script

Post by ganeshanrs1983 »

Thanks for your response. Let me follow this document. Will get back to you if i stuck in the middle.
ganeshanrs1983
Posts: 55
Joined: Wed Jun 18, 2014 10:16 am

Re: checks fails at one script callback second script

Post by ganeshanrs1983 »

I am really new to this event handler option. Let me know which plugin i need to use to get the output on nagios monitoring system.
Locked