Page 1 of 1
Windows Service Restart On Critical Alert.
Posted: Wed Nov 14, 2012 11:24 am
by kubben
Here's my scenario.
I've just read over
http://library.nagios.com/library/produ ... -nagios-xi
Which is great for monitoring a service and restarting it when it has stopped, but what what i am doing, is monitoring a directory, which is acting as a spool directory for a Fax Software, which alerts on a file count.
What i need to do, is, when a critical alert is met, aka the above alert is fired, i need the event handler to restart a specific service on the host.
would this be done in the same way? I actually need an answer on this.
Re: Windows Service Restart On Critical Alert.
Posted: Wed Nov 14, 2012 12:41 pm
by slansing
Yes It would be done in the same fashion, in the documentation it cites where you need to replace the example service text with a service of your choice.

Re: Windows Service Restart On Critical Alert.
Posted: Wed Nov 14, 2012 12:43 pm
by scottwilkerson
This would be done in the exact same way, the only exception is you wouldn't run the wizard on page 3 you would just add this event handler to your service that is checking the file count.
Re: Windows Service Restart On Critical Alert.
Posted: Thu Nov 15, 2012 11:01 am
by CGraham
If this is a windows server, I have two recommendations:
1. Add a sleep into your script between the stop and start. Easiest way to do this is by pinging the loopback:
Code: Select all
:: Waiting 10 Seconds
echo Waiting 10 seconds >>%LOGFILE%
ping -n 11 -w 1000 127.0.0.1 >nul
echo Finished waiting 120 seconds >>%LOGFILE%
2. Add logging.
Then put " >>%LOGFILE%" at the end of every command.
Actually these hold true for Linux too, but are accomplished differently.
EDIT: Additionally, I've added " >> /usr/local/nagios/var/restart.log" into my servicerestart.sh command to log those too.
Re: Windows Service Restart On Critical Alert.
Posted: Thu Nov 15, 2012 3:22 pm
by slansing
The logfile would be a good addition, though what is being done is quite simple I suppose it depends on the complexity of what is being done. As far as the sleep timer goes, in my experience the script has waited for the previous command to finish before issuing the next, unless the sleep was for something in addition to that. Time to go fiddle around with your ideas
