Page 1 of 1

How to configure nagios to take action

Posted: Wed Mar 20, 2019 11:03 am
by sho7x
Hi, I recently created a Nagios check that checks the event log to see if a specific event has occurred. Upon the occurrence of the event I needed Nagios to perform an iis reset. From what I have read I need to create a script and add it to the scripts folder in the agent on the specific machine and then point the check to that script. I have never done something like this so any guidance/help would be much appreciated.

thanks

Re: How to configure nagios to take action

Posted: Wed Mar 20, 2019 12:26 pm
by mcapra
What agent is being used on the Windows machine? NSClient++ and NCPA are the two most common.

This documentation covers leveraging a Nagios event handler with NSClient++:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf

The documentation mentions "Nagios XI" many times, but the documentation is just as relevant for Nagios Core aside from configuring the Nagios Core objects required.

Here's a blog post that does similar things, but covers configuring raw Nagios Core objects:
http://www.katherinevillyard.com/2013/0 ... n-windows/

Re: How to configure nagios to take action

Posted: Wed Mar 20, 2019 2:10 pm
by benjaminsmith
Thanks @mcapra!

Let us know if you're able to get started or if you have further questions.

Re: How to configure nagios to take action

Posted: Wed Mar 20, 2019 2:33 pm
by sho7x
thank you for your prompt responses, it is much appreciated. I am using nsclient++ and have copy pasted the code listed in the XI document you provided and saved it as a batch file under scripts. the next step says to add the restart_service=... line to the ini file. I have attached my ini file and just wanted to make sure the placement was correct. Also, in the following step I am unsure about where allow needs to be set to arguments = true as I cannot find the exact sections in my ini file as listed on the document. Sorry if my questions seem basic as I only have basic knowledge of Nagios core.

Re: How to configure nagios to take action

Posted: Thu Mar 21, 2019 4:57 pm
by tgriep
The placement of the restart_service command looks good but under this section

Code: Select all

[External Script]
Add these so the client will receive arguments, etc... when running external scripts.

Code: Select all

allow_arguments=1
allow_nasty_meta_chars=1
script_dir=C:\Program Files\NSClient++\scripts