Page 1 of 1
syncing nagios with an external downtime scheduler
Posted: Tue Apr 22, 2014 5:39 pm
by jssingh
Hi,
is there a way to schedule a downtime in nagios 4 without using the GUI? We have a program we use for scheduling downtime and I want to sync it with the nagios downtime, but I can't really figure out how. I figured out that I can use the API to get the information from nagios, but I haven't figured out how to send the downtime information to nagios using a script. As far as I can tell the APIs only let us read information, not send it. Or am I wrong about that? Any ideas?
thanks,
-janice
Re: syncing nagios with an external downtime scheduler
Posted: Tue Apr 22, 2014 8:27 pm
by pato
Yep, use the SCHEDULE_HOST_DOWNTIME command to achieve this. From the docs:
Command Format:
SCHEDULE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
Description:
Schedules downtime for a specified host. If the "fixed" argument is set to one (1), downtime will start and end at the times specified by the "start" and "end" arguments. Otherwise, downtime will begin between the "start" and "end" times and last for "duration" seconds. The "start" and "end" arguments are specified in time_t format (seconds since the UNIX epoch). The specified host downtime can be triggered by another downtime entry if the "trigger_id" is set to the ID of another scheduled downtime entry. Set the "trigger_id" argument to zero (0) if the downtime for the specified host should not be triggered by another downtime entry.
You'll need to echo this string into your command file (typically /usr/local/nagios/var/rw/nagios.cmd) - here's what I use (also based on an example from the docs):
Code: Select all
#!/bin/sh
now=`date +%s`
cmdf='/usr/local/nagios/var/rw/nagios.cmd'
/usr/bin/printf "[$now] SCHEDULE_HOST_DOWNTIME;$host;$starttime;$finishtime>;1;0;$duration;pato;$comment\n" > $cmdf
Re: syncing nagios with an external downtime scheduler
Posted: Wed Apr 23, 2014 9:36 am
by tmcdonald
Thank you for the response, pato. jssingh, let us know how this works out for you.
Re: syncing nagios with an external downtime scheduler
Posted: Wed Apr 23, 2014 2:51 pm
by jssingh
Yes, that was exactly what I was looking for!
And what's the best place to find that documentation? I looked around online and the only place I can seem to find it is on old.nagios.org. I just want to make sure that is the best place to look.
thanks!
Re: syncing nagios with an external downtime scheduler
Posted: Wed Apr 23, 2014 3:02 pm
by slansing
The best spot to find this sort of information would be on the sourceforge documentation site, you can take a look at the index/contents here:
http://nagios.sourceforge.net/docs/3_0/toc.html