Recuring Downtime for host and its services

Hey there,

i created a recuring downtime for some hosts for backup puropses. For that i edited the downtimes.conf in /etc/icinga2/conf.d/ and added

apply ScheduledDowntime "backup-downtime" to Host {
  author = "sma"
  comment = "Scheduled downtime for backup"

  child_options = DowntimeTriggeredChildren
  
  ranges = {
    monday = host.vars.backup_downtime
    tuesday = host.vars.backup_downtime
    wednesday = host.vars.backup_downtime
    thursday = host.vars.backup_downtime
    friday = host.vars.backup_downtime
    saturday = host.vars.backup_downtime
    sunday = host.vars.backup_downtime
  }

  assign where host.vars.backup_downtime != ""
}

In director i can specify to create the downtime for all services of the host and the host itself. How can i do that in my recuring downtime? Is there an option for that?

Greets
Sebbo

Hello Sebbo,

for recurring downtimes (ScheduledDowntimes) you have to configure them for host objects and for the service objects seperatly. Maybe there will be an option in the future (hint: ask for a new feature on github).

Regards,
Carsten

Hi,

I don’t think that this will happen, since the apply rule needs a scope, either to Host or to Service to know about the specific objects and their possible attributes in assign where expressions. When implementing the apply rules, we thought about such generics already, and decided against it. Technically, service apply rules would also need to Host, but since there’s only one route, this is hidden by default.

You can always put attributes into templates for instance, and only import them into apply rules, hiding duplicated parts in there.

Cheers,
Michael

1 Like

Too bad. I thought there’d be a switch, since there is a checkbox in director for that on a host object when i create a downtime manually.

The Director abstracts that and just generates the configuration in the background, it fairly looks the same as if you would write it by hand.

As said, if there’s generic content, use templates like this:

template ScheduledDowntime "backup-tmpl" {
  ranges = { 
    //...
  }
}

apply ScheduledDowntime "backup" to Host {
  import "backup-tmpl"
  assign where ...
}

apply ScheduledDowntime "backup" to Service {
  import "backup-tmpl"
  assign where ...
}

Cheers,
Michael

1 Like

Hi!
How can I create a "ScheduledDowntimeTemplate from Director - as you tell above ?
IN the director --> Downtime section - Only Downtime are possible. I can’t see any TEMPLATE feature here…
In addiction how can insert\define the ranges in Downtime section of director ?
thx