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
syncing nagios with an external downtime scheduler
Re: syncing nagios with an external downtime scheduler
Yep, use the SCHEDULE_HOST_DOWNTIME command to achieve this. From the docs:
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):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.
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
Thank you for the response, pato. jssingh, let us know how this works out for you.
Former Nagios employee
Re: syncing nagios with an external downtime scheduler
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!
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!
-
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: syncing nagios with an external downtime scheduler
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
http://nagios.sourceforge.net/docs/3_0/toc.html