Schedule downtimes for hosts

Hi, i want to schedule downtime for a host on saturday from 22h00 to 23h00, i hve this in downtimes.conf:

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

  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 != ""
}

and im my host config :

object Host "srvad01" {
        import "generic-host"
        address = "192.168.168.68"
        check_command = "hostalive"
        vars.os = "Serveur"
        vars.backup_downtime = "22:00-22:30"

        vars.notification["mail"] = {
           groups = ["icingaadmins"]
           users = ["icingaadmin"]
        }
}

but with this code, the downtime is scheduled every day so how can i do to schedule it only o saturday ?
Thanks

Hi,

the apply rule for the ScheduledDowntime fetches the host.vars.backup_downtime variable into its scope and generates the ranges attributes.

Keep it simpler, and modify your ScheduledDowntime object as such:

apply ScheduledDowntime “backup-downtime-saturday” to Host {
  author = “icingaadmin”
  comment = “Scheduled downtime for backup on Saturday”

  ranges = {
    saturday = “22:00-22:30”
  }

  assign where host.vars.os == "Serveur"
}

Once that works, you can still optimize the apply rule and fetch specific variables from the host, when needed.

Cheers,
Michael

i hae an other question, is that possible to configure notifications to be sent only 1 time ? like whet the mail is sent you won’t get an other ? or you can’t ?
thanks

Hi,

let’s solve the SD question, and for the notifications, please create a new topic to allow others to catch up.

Cheers,
Michael

1 Like