syncing nagios with an external downtime scheduler

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
User avatar
jssingh
Posts: 110
Joined: Mon Apr 29, 2013 4:55 pm

syncing nagios with an external downtime scheduler

Post 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
pato
Posts: 18
Joined: Thu Oct 10, 2013 6:06 pm
Location: Melbourne, Australia

Re: syncing nagios with an external downtime scheduler

Post 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
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: syncing nagios with an external downtime scheduler

Post by tmcdonald »

Thank you for the response, pato. jssingh, let us know how this works out for you.
Former Nagios employee
User avatar
jssingh
Posts: 110
Joined: Mon Apr 29, 2013 4:55 pm

Re: syncing nagios with an external downtime scheduler

Post 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!
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: syncing nagios with an external downtime scheduler

Post 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
Locked