Linux – How to set icinga2 downtime across midnight

backupicingalinuxmonitoring

Our backup is running between 22:00 and about 05:00 the next day. I could not figure out how to set this in a scheduled downtime with "apply ScheduledDowntime" in icinga2 (r2.4.1-1 on opensuse 42.1).

Just setting 22:00-05:00 gives me an error:

Invalid time range definition '22:00-05:00': Time period segment ends before it begins

The current mechanism uses a service variable backup_downtime which in turn triggers the "apply" rule when not empty:

apply ScheduledDowntime "backup-downtime" to Service {
  author = "icingaadmin"
  comment = "Scheduled downtime for backup"

  ranges = {
    monday = service.vars.backup_downtime
    tuesday = service.vars.backup_downtime
    wednesday = service.vars.backup_downtime
    thursday = service.vars.backup_downtime
    friday = service.vars.backup_downtime
    saturday = service.vars.backup_downtime
    sunday = service.vars.backup_downtime
  }

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

Somebody an idea? Thanks

Best Answer

You could assign the service.vars.backup_downtime value "22:00-24:00,00:00-05:00" so that you get downtime from 22:00 to 05:00 the next day.

ie. service definition will be:

apply Service "foo" {
  display_name = "foo process"
  import "generic-service"
  check_command = "foo-process"
  command_endpoint = host.address
  vars.backup_downtime = "22:00-24:00,00:00-05:00"
  assign where host.vars.type == "bar"
}
Related Topic