LebooThomas
(Dumbstore. com)
February 12, 2020, 8:17am
1
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
dnsmichi
(Michael Friedrich)
February 12, 2020, 8:41am
2
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
LebooThomas
(Dumbstore. com)
February 12, 2020, 9:16am
3
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
dnsmichi
(Michael Friedrich)
February 12, 2020, 9:21am
4
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
To give an answer to your original question, you would need to think clearly about the problem and be creative:
object Host "srvad01" {
...
vars.backup_downtime = {
monday = "22:00-22:30"
}
....
}
apply ScheduledDowntime "backup-downtime" to Host {
author = "icingaadmin"
comment = "Scheduled downtime for backup"
if (host.vars.backup_downtime.monday) {
ranges += host.vars.backup_downtime.monday
}
// ...
assign where host.vars.backup_downtime
}