Restart Service on Windows using Event Handlers
-
Sampath.Basireddy
- Posts: 252
- Joined: Wed Dec 14, 2016 12:30 pm
Restart Service on Windows using Event Handlers
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
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
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
sc failure nscp reset= 86400 actions= restart/120000/restart/120000/none/120000
-
Sampath.Basireddy
- Posts: 252
- Joined: Wed Dec 14, 2016 12:30 pm
Re: Restart Service on Windows using Event Handlers
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.
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.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
-
Sampath.Basireddy
- Posts: 252
- Joined: Wed Dec 14, 2016 12:30 pm
Re: Restart Service on Windows using Event Handlers
That link has instructions for NRPE and NSClient++. Is there a similar document for NCPA?
Re: Restart Service on Windows using Event Handlers
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:
Or as a check_ncpa command:
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=mytokenCode: Select all
check_ncpa.py -H my.host.com -t mytoken -M 'plugins/restart_service.bat'Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Restart Service on Windows using Event Handlers
Thanks @mcapra this is exactly how to do it.
-
Sampath.Basireddy
- Posts: 252
- Joined: Wed Dec 14, 2016 12:30 pm
Re: Restart Service on Windows using Event Handlers
Perfect. Thank You @mcapra
I created a command like below and selected it as Event handler and it worked..
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'
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Restart Service on Windows using Event Handlers
Excellent! Going to Lock this thread