# Downtime for load service

**URL:** <https://community.icinga.com/t/downtime-for-load-service/12747>\
**Category:** Events and Community\
**Tags:** notifications\
**Created:** [October 13, 2023, 8:12am UTC](https://community.icinga.com/t/downtime-for-load-service/12747 "2023-10-13T08:12:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mb19](https://community.icinga.com/user_avatar/community.icinga.com/mb19/32/7260_2.png) [@mb19](https://community.icinga.com/u/mb19)\
**Post date:** [October 13, 2023, 8:12am UTC](https://community.icinga.com/t/downtime-for-load-service/12747/1 "2023-10-13T08:12:17Z")

</div>

Hello,

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

I have this configuration in “downitmes.conf”:

```auto

/**
 * 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:

```auto
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!

---

<div class="post-metadata">

**Author:** ![ncosta](https://community.icinga.com/user_avatar/community.icinga.com/ncosta/32/7278_2.png) [@ncosta](https://community.icinga.com/u/ncosta)\
**Post date:** [October 13, 2023, 9:01am UTC](https://community.icinga.com/t/downtime-for-load-service/12747/2 "2023-10-13T09:01:12Z")

</div>

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:

```auto
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):

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

```

Best regards,  
Noé

---

<div class="post-metadata">

**Author:** ![mb19](https://community.icinga.com/user_avatar/community.icinga.com/mb19/32/7260_2.png) [@mb19](https://community.icinga.com/u/mb19)\
**Post date:** [October 13, 2023, 9:07am UTC](https://community.icinga.com/t/downtime-for-load-service/12747/3 "2023-10-13T09:07:20Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![ncosta](https://community.icinga.com/user_avatar/community.icinga.com/ncosta/32/7278_2.png) [@ncosta](https://community.icinga.com/u/ncosta)\
**Post date:** [October 13, 2023, 9:10am UTC](https://community.icinga.com/t/downtime-for-load-service/12747/4 "2023-10-13T09:10:33Z")

</div>

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é
