How to configure nagios to take action

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
sho7x
Posts: 6
Joined: Wed Mar 20, 2019 10:57 am

How to configure nagios to take action

Post 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
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: How to configure nagios to take action

Post 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/
Former Nagios employee
https://www.mcapra.com/
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: How to configure nagios to take action

Post by benjaminsmith »

Thanks @mcapra!

Let us know if you're able to get started or if you have further questions.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
sho7x
Posts: 6
Joined: Wed Mar 20, 2019 10:57 am

Re: How to configure nagios to take action

Post 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.
Attachments
nsc2.txt
(11.33 KiB) Downloaded 178 times
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: How to configure nagios to take action

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked