Page 1 of 1

Automating disable request

Posted: Thu Jul 31, 2014 12:17 pm
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

Re: Automating disable request

Posted: Thu Jul 31, 2014 12:32 pm
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.

Re: Automating disable request

Posted: Thu Jul 31, 2014 1:09 pm
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.

Re: Automating disable request

Posted: Thu Jul 31, 2014 8:10 pm
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.

Re: Automating disable request

Posted: Thu Jul 31, 2014 8:22 pm
by eloyd
Yup, you can do that too. Be forewarned about network security and all that, but yes.