Automating disable request

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
stecino
Posts: 248
Joined: Thu Mar 14, 2013 4:42 pm

Automating disable request

Post by stecino »

Hi All,

I was wondering if there is a way to send a command to Nagios from init script upon application container shutdown, to disable specific monitors automatically. Any API, or cgi maybe.

Thanks
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Automating disable request

Post by tmcdonald »

http://old.nagios.org/developerinfo/ext ... ndlist.php

You'll want to write to the nagios.cmd file. All commands with example scripts are listed.

In particular:

Single host disable
Hostgroup disable

Similar commands exist for services and servicegroups.
Former Nagios employee
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Automating disable request

Post by eloyd »

We do this all the time for event handlers where we know the restart will take longer than the check interval. We temporarily stop Nagios's service checks while the event handler starts, and then enable them again when it completes. The trick is, what happens if something goes wrong in the middle?

So we also have a lock file that we put in place. The event handler creates this and deletes this as well. A cleanup gizmo comes along every ten minutes and looks for lock files that are 60 minutes old (or older). If there are any, it assumes that the event handler died, kills the lock file, enables the nagios service, and everything starts back over again with notifications handled through Nagios.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
chris.fixter
Posts: 22
Joined: Wed Jun 18, 2014 4:15 am

Re: Automating disable request

Post by chris.fixter »

my simple trick to find the API is to perform the task you wanted to from nagios web gui, use a http track tools (eg. Developer Tools in Chrome) to record the GET/POST action.
Then use whatever utility( wget, curl, msxml ) to simulate the action again when necessary.
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Automating disable request

Post by eloyd »

Yup, you can do that too. Be forewarned about network security and all that, but yes.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
Locked