Page 1 of 1

Starting/Ending Downtime via passive message or similar?

Posted: Sat Apr 19, 2014 7:15 am
by bazza2000
Hi,

I've been using Nagios Core for a number of weeks now and been searching for a while of a way to implement a blackout but either as a passive message or some other mechanism.

My situation is that we use Jenkins to do code deploys, but during the code deploy we need to restart servers, I want to initiate (from a client with NSCA, NRPE etc installed) a message to the Nagios server to enable downtime for 5 mins (or longer depending on the type of deployment we're doing) before we restart the services on the particular host. I've checked NSCA but it only appear to be able to send back passive status updates as opposed to actual downtime initiations etc.
I know I could probably do this with flexible downtime settings etc, but once the restart has finished I then want to send a message to say end the downtime and alert as normal on this host.

i know I could do this by setting up some SSH pub/pri key exchange and SSH straight into the server and add to the command file, but doesn't seem very elegant.

I'm sure someone else must have seen this problem and resolved so any help would be much appreciated,

Thanks,

Re: Starting/Ending Downtime via passive message or similar?

Posted: Mon Apr 21, 2014 10:32 am
by sreinhardt
You could do this with an event handler on that host\service that looks for a passive check and certain arguments within the string that informs it how to format the command sent to the command subsys. Otherwise as you imagine, the only real way to do this is either via post requests to the nagios interface or directly to the nagios.cmd file.

Re: Starting/Ending Downtime via passive message or similar?

Posted: Mon Apr 21, 2014 10:36 am
by abrist
You could write to the command pipe with external commands, but you are correct that this would require a local script:
http://old.nagios.org/developerinfo/ext ... and_id=118
http://old.nagios.org/developerinfo/ext ... and_id=125

You could alternatively submit/delete downtime through a GET request to the cmd.cgi:
Create Host Downtime (typ=86):

Code: Select all

http://nagiosadmin:<pass>@<nagios ip>/nagios/cgi-bin/cmd.cgi?cmd_typ=86&cmd_mod=2&host=%3C<hostname>%3E&com_author=%3C<author>%3E&com_data=%3C<comment>%3E&
trigger=0&start_time=<start time>&end_time=<end_time>&fixed=1&child_options=1&btnSubmit=Commit
Time format example:

Code: Select all

03-26-2014%2018:19:35
Delete Host Downtime (cmd_typ=78):

Code: Select all

http://<ip>/nagios/cgi-bin/cmd.cgi?cmd_typ=78&down_id=<id>&cmd_mod=2&btnSubmit=Commit
NOTE: You will need to url encode the hostname, author name, comment and time format.

Re: Starting/Ending Downtime via passive message or similar?

Posted: Mon Apr 21, 2014 3:22 pm
by bazza2000
Appreciate the responses, thanks. Just wondering if the cmd.cgi GET format may change in the future in a new release?

Re: Starting/Ending Downtime via passive message or similar?

Posted: Mon Apr 21, 2014 3:40 pm
by slansing
I don't think you need to worry about that, it is well established and we have not seen a need to change it so far.