I have some basic Nagios checks that run against windows servers......C drive, cpu, memory etc.....
but what I want to do is if a check (CPU for example) returns with a critical, then I want a powershell script to run.
How to??
Run Powershell on critical check
Run Powershell on critical check
Everybody is somebody else’s weirdo
Re: Run Powershell on critical check
Hi @JohnFLi,
Given what you are trying to accomplish, event handlers are just the thing you need.
Event handlers are optional system commands (scripts or executables) that are run when a host or service
state change occurs. These commands include, but are not limited to, restarting services, parsing logs,
checking other host or service states, making database calls, etc. The possibilities are near limitless.
Essentially, through event handlers, Nagios XI is capable of running any operation that can be performed from
the command line with the added ability of utilizing macros passed by Nagios XI.
Please follow this guide on how to configure event handlers:
How to configure Event Handlers
Please let me know if you any questions.
Given what you are trying to accomplish, event handlers are just the thing you need.
Event handlers are optional system commands (scripts or executables) that are run when a host or service
state change occurs. These commands include, but are not limited to, restarting services, parsing logs,
checking other host or service states, making database calls, etc. The possibilities are near limitless.
Essentially, through event handlers, Nagios XI is capable of running any operation that can be performed from
the command line with the added ability of utilizing macros passed by Nagios XI.
Please follow this guide on how to configure event handlers:
How to configure Event Handlers
Please let me know if you any questions.
Re: Run Powershell on critical check
The only thing I see in there shows directly running the 'event handler', not running it IF a state is critical. In the example from that link.....the test check is running a .sh file
so basicly, I don't see on how running a script each time (no matter if its up, down or sideways) is anything different than a regular check.
so basicly, I don't see on how running a script each time (no matter if its up, down or sideways) is anything different than a regular check.
Everybody is somebody else’s weirdo
Re: Run Powershell on critical check
So perhaps our remote Windows machine is running NSClient++. NSClient++ has all sorts of commands you can call remotely from the Nagios XI machine via check_nrpe. Commands for checking disk, cpu, drives, counters, and all sorts of custom commands that you can configure yourself. What if, instead of that custom command being responsible for checking some obscure piece of the Windows machine, it instead was responsible for restarting a service? Killing a process?
That is essentially what this documentation gets at. Configuring a custom command within a NSClient++ configuration that restarts a service, then calling that custom command from Nagios XI:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
That is essentially what this documentation gets at. Configuring a custom command within a NSClient++ configuration that restarts a service, then calling that custom command from Nagios XI:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Last edited by mcapra on Tue Oct 10, 2017 3:44 pm, edited 2 times in total.
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
Re: Run Powershell on critical check
go ahead and close this thread as it isn't providing anything usefull
Everybody is somebody else’s weirdo
Re: Run Powershell on critical check
The HOSTSTATE and HOSTSTATETYPE variables can be used in the script to determine the state and state type of a service or host and then execute commands based on them. Hope this helps.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.