Nagios - How do I schedule a regular period of downtime?

I have Nagios Core up and running, and cannot find any way to schedule a regular period of downtime for hosts. For example, let's say I have a host that is scheduled to reboot itself every Sunday at 1 am. I'd like to be able to schedule that known downtime of "every Sunday from 1:00am to 1:10am" into Nagios, but the only way I see to do so is one event at a time.


Solution 1:

Without using the cron solution mentioned by JakePaulus the typical method for handling "downtime" with Nagios is to define and use a timeperiod that does not include the time during which the host will be down. E.g., in your case

define timeperiod {
  timeperiod_name foo
  sunday 00:00-1:00,1:10-24:00
  monday 00:00-24:00
  tuesday 00:00-24:00
  wednesday 00:00-24:00
  thursday 00:00-24:00
  friday 00:00-24:00
  saturday 00:00-24:00
}

A simpler method is to take your pre-existing 24x7 timeperiod and define and exclusion:

define timeperiod {
  name reboot
  timeperiod_name reboot
  sunday 1:00-1:10
}

define timeperiod {
  timeperiod_name foo
  use 24x7
  exclude reboot
}

Solution 2:

You can do this using a shell script that submits an external command (outputs a command to the named pipe nagios.cmd file) on a schedule dictated by cron. Here's a link to what we use.

http://exchange.nagios.org/directory/Addons/Scheduled-Downtime/Schedule-Downtime-via-cron/details