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,
Starting/Ending Downtime via passive message or similar?
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: Starting/Ending Downtime via passive message or similar?
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.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Re: Starting/Ending Downtime via passive message or similar?
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):
Time format example:
Delete Host Downtime (cmd_typ=78):
NOTE: You will need to url encode the hostname, author name, comment and time format.
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=CommitCode: Select all
03-26-2014%2018:19:35Code: Select all
http://<ip>/nagios/cgi-bin/cmd.cgi?cmd_typ=78&down_id=<id>&cmd_mod=2&btnSubmit=CommitFormer Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Starting/Ending Downtime via passive message or similar?
Appreciate the responses, thanks. Just wondering if the cmd.cgi GET format may change in the future in a new release?
-
slansing
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: Starting/Ending Downtime via passive message or similar?
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.