Create ScheduledDowntime with 'TimePeriod'?

Hi there!

I am wondering if the following is possible to configure using the DSL.

We currently patch all of our Windows servers on the last Sunday of every month.

Reading through the TimePeriod documentation, this could be written as such:

object TimePeriod "patching" {
  ranges = {
    "sunday -1 jan" = "00:00-9:00" //last sunday in january
    "sunday -1 feb" = "00:00-9:00" //last sunday in february
    // etc...
  }
} 

And we can create a time period for all other times that excludes the patching dates.

object TimePeriod "prod-notifications" {
  excludes = [ "patching" ]
  // etc...
}

Is it possible to assign this TimePeriod object to a ScheduledDowntime object?

We are trying to avoid creating downtime on specific dates - e.g. if we could specify a TimePeriod for ScheduledDowntime, and have Icinga do the calculation to figure out whether it is in downtime or not.

Originally, we were attempting this with some python scripts to calculate the last Sunday of each month and convert it to a unix timestamp, but that becomes difficult to monitor to ensure the downtime is scheduled and it would make more sense for us to generate this at runtime.

I can see it’s possible to have checks excluded during this time, but we’d still like to count this as scheduled downtime rather than disable checking, so the downtime is still logged.

Hi,

there’s no direct relationship between TP and SD objects. Though, if you want to avoid duplicated information, you could move the ranges Dictionary into a global constant and referencing them in both objects.

const RangesPatching = {
    "sunday -1 jan" = "00:00-9:00" //last sunday in january
    "sunday -1 feb" = "00:00-9:00" //last sunday in february
    // etc...
}
object TimePeriod "patching" {
  ranges = RangesPatching
  //...
}

object ScheduledDowntime "patching" {
  ranges = RangesPatching
  //...
}

Cheers,
Michael

3 Likes