Page 1 of 1
Restart Service on Windows using Event Handlers
Posted: Wed Sep 13, 2017 9:26 am
by Sampath.Basireddy
Hello There,
I am trying to configure event handler to auto start/restart Service on Windows Servers with NCPA.
I do have link for "how to restart a Windows service via NRPE and NSClient++". Is there any similar documentation for NCPA as well?
Thank You
Re: Restart Service on Windows using Event Handlers
Posted: Wed Sep 13, 2017 10:34 am
by gormank
Off topic but my first defense would be to tell the service to restart itself twice before dying. Example for nsclient:
sc failure nscp reset= 86400 actions= restart/120000/restart/120000/none/120000
Re: Restart Service on Windows using Event Handlers
Posted: Wed Sep 13, 2017 11:11 am
by Sampath.Basireddy
That is already in place. My requirement is kind of different. I want to configure event handlers on NCPA.
Starting of Service when it goes down is not my exact requirement, but for other reasons where any application has a dependency of a service and it might need a service restart.
Re: Restart Service on Windows using Event Handlers
Posted: Wed Sep 13, 2017 11:20 am
by scottwilkerson
Re: Restart Service on Windows using Event Handlers
Posted: Wed Sep 13, 2017 11:35 am
by Sampath.Basireddy
That link has instructions for NRPE and NSClient++. Is there a similar document for NCPA?
Re: Restart Service on Windows using Event Handlers
Posted: Wed Sep 13, 2017 11:48 am
by mcapra
Refer to the documentation for the NCPA
plugins endpoint:
https://www.nagios.org/ncpa/help/2.0/ap ... es-plugins
Basically, you store the script (such as one that restarts a service) in the
plugin_path and call it via the
plugins endpoint:
Code: Select all
https://my.host.com:5693/api/plugins/<plugin name>/<arg1>/<arg2>/?token=mytoken
Or as a check_ncpa command:
Code: Select all
check_ncpa.py -H my.host.com -t mytoken -M 'plugins/restart_service.bat'
Re: Restart Service on Windows using Event Handlers
Posted: Wed Sep 13, 2017 11:56 am
by scottwilkerson
Thanks
@mcapra this is exactly how to do it.
Re: Restart Service on Windows using Event Handlers
Posted: Wed Sep 13, 2017 2:11 pm
by Sampath.Basireddy
Perfect. Thank You
@mcapra
I created a command like below and selected it as Event handler and it worked..
Code: Select all
$USER1$/check_ncpa.py -H $HOSTADDRESS$ -t <String> -M 'plugins/restart_service.bat'
Re: Restart Service on Windows using Event Handlers
Posted: Wed Sep 13, 2017 2:22 pm
by scottwilkerson
Excellent! Going to Lock this thread