Downtime for load service

Hello,

I am trying to set a downtime for the upload service.

I have this configuration in “downitmes.conf”:


/**
 * The example downtime apply rule.
 */

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

/**
 * Downtime para "load"
 */

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

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

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

And this on my host:

object Host "xxxxxxxxxxxx" {
  import "eurovia-server"

  display_name = "xxxxxxxx"
  address = "xxxxxxxxxxxxxxx"
  vars.client_endpoint = name

/* Configuracions personalitzades per als diferents serveis */
# - http -
#  vars.http_vhosts["integra4"] = {
#    http_uri = "xxxxxxxxxx"
#    http_ssl = true
#    http_port =
#    http_address = ""
#  }
# - procs -
#  vars.procs_critical = 250 // default 400
#  vars.procs_warning = 180  // default 250
# - users_integra -
#   vars.integra = true
# - disk [ "nfs4", "tracefs" ] -
  vars.disk_exclude_type = [ "nfs4","tracefs" ]
  vars.disk_wfree = "10%"
  vars.disk_cfree = "5%"
# - backups -
  vars.backup_downtime = "02:00-04:00"
# - load -
  vars.load_downtime = "05:45-06:30"
  vars.load_wload1 = 2.25
  vars.load_wload5 = 1.87
  vars.load_wload15 = 1.50
  vars.load_cload1 = 3.00
  vars.load_cload5 = 2.50
  vars.load_cload15 = 2.00


# - swap -
#vars.swap_wfree = "20%"
#vars.swap_cfree = "10%"

}

Finally, when I restart the service, this warning appears:

warning/ApplyRule: Apply rule ‘load-downtime’ (in /etc/icinga2/zones.d/global-templates/downtimes.conf: 26:1-26:50) for type ‘ScheduledDowntime’ does not match anywhere!

Hi @mb19 and welcome to our community!

The problem lies in the fact, that you defined an apply rule for a service while trying to get it to apply through a variable on the host object.
The custom variables vars defined in the host object are not going to get transfered over to the service object. You can however access them through the host.vars.custom_variable syntax.
How can you solve it then?
You can either define a service template that incorporates this custom variable or change the apply rule to assign it to where the host object has set this specific variable:

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

  ranges = {
    monday = host.vars.load_downtime
    tuesday = host.vars.load_downtime
    wednesday = host.vars.load_downtime
    thursday = host.vars.load_downtime
    friday = host.vars.load_downtime
    saturday = host.vars.load_downtime
    sunday = host.vars.load_downtime
  }

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

// EDIT
That being said, you probably want to change the assign filter to restrict the downtime solely to your upload service. You could do that by extending it with a second condition which only incorporates your upload service (I used the display name for this, it could also be any specific value that only exists on your upload service):

assign where host.vars.load_downtime != "" && match("*upload*", service.display_name)

Best regards,
Noé

Hello Noé,

Thank you very much, I have added this configuration and at least the warning no longer appears, if the notifications do not appear tomorrow I will mark your response as a solution!

I have added a little edit as it would currently apply it to all services under that specific host but you only wanted it to apply it to the “upload service”.

Best regards,
Noé