Page 1 of 1

EventHandler behaviour

Posted: Thu May 13, 2021 4:13 am
by FCC_Nagios_Support
Good Morning,
I have to trigger an EventHandler to a Windows System based in restart a Windows Service with a 12 minutos delayed between thenend and the start. Are there any issue if Nagios call the .bat and sleeps a while or the call is dissconected?
Thanks

Re: EventHandler behaviour

Posted: Thu May 13, 2021 5:34 pm
by ssax
I wouldn't sleep an event handler for 12 minutes, you could probably make that work (by increasing a lot of different limits) but I wouldn't recommend it. Is there any reason the event handler needs to wait for it?

Re: EventHandler behaviour

Posted: Fri May 14, 2021 1:53 am
by FCC_Nagios_Support
Hi,
Becuase the windows service spends 10 minutos to stop and then start
KR

Re: EventHandler behaviour

Posted: Fri May 14, 2021 5:43 am
by FCC_Nagios_Support
I will try to explain it better.
my 'event handler' calls a command, this command is a check_nrpe to which I pass another command that executes a service restart on the target machine.
If this last event took 10 or 12 minutes to complete, would the event handler give a timeout error? or how it has been launched without returning any error is it considered executed?

in my Nagios:
Host H - Service X --> CRITICAL --> EVENTHANDLER Y: check_nrpe -c restart_service

in host H (nsclient.ini)
restart_service --> net stop ServiceX // net start ServiceX --> it's takes 10 or 12 minutes to complete

Re: EventHandler behaviour

Posted: Fri May 14, 2021 3:37 pm
by ssax
It would timeout without modifying the event handler timeout in /usr/local/nagios/etc/nagios.cfg to be higher than the time it takes to complete:

Code: Select all

event_handler_timeout=30
If you adjust it you'll need to apply config or restart the nagios service for the changes to take effect.

Another option, since this is likely a one-off I'd probably setup a scheduled task bat script on the remote system that checks for a file's existence on that remote system and if that file exists have it restart the service and delete the file. Then you could just have your event handler call a plugin you write to create that file. That would take the 12 minute event handler out of the picture. It's not the most elegant but it's a workaround.