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.
Windows Service Restart On Critical Alert.
-
slansing
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: Windows Service Restart On Critical Alert.
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. 
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Windows Service Restart On Critical Alert.
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.
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:
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.
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%
Code: Select all
SET LOGFILE=restart.log
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.
-
slansing
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: Windows Service Restart On Critical Alert.
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 