Monitoring in Check Period


During Windows patching we have a check_period configured to ensure we don’t have any PagerDuty callouts during the maintenance window. This works fine for the services and we use the following code within our service checks:

if (host.vars.check_period) {
  check_period = host.vars.check_period
 } else {
  check_period = "24x7"

and apply this within the host object:

vars.check_period = "overnight-maintenance"

However the host check (check_command = “ping4”) against the host will trigger an alert during this time:

PROBLEM - {hostname} is DOWN

Please can anyone advise the best method to disable this ping check during the maintenance window? I have attempted to configure a similar approach to what we do with the services but it produces an error:

critical/config: Error: Error while evaluating expression: Tried to access undefined script variable 'host'
Location: in /etc/icinga2/zones.d/master/templates.conf

Thank you.

Hello @cbowden!

Please share (at least example) concrete config visualizing the current and “similar” approaches.


Hi @Al2Klimov

Thank you for reaching out to me for more info!

So an example of code from our windows-services.conf:

apply Service "Windows: Load" {
if (host.vars.check_period) {
  check_period = host.vars.check_period
 } else {
  check_period = "24x7"
  import "generic-service"
  check_command = "load-windows"
  command_endpoint = host.vars.client_endpoint
  assign where host.vars.os == "Windows"

and a windows-hosts.conf, that includes the check_period:

 object Host "" {
   display_name = ""
   import "generic-host"
   address = ""

   vars.check_period = "overnight-c"

   vars.service_win_service = "DNS"
   vars.notification["mail"] = {
     groups = [ "icingaservers" ]

…and the above works perfectly for the Windows: Load service, i.e. it does not check during this maintenance window.

Now I need to apply something similar against the host check, which in our case is called from the template.conf as follows:

template Host "generic-host" {
  max_check_attempts = 3
  check_interval = 5m
  retry_interval = 1m

  check_command = "ping4"
     /*if (host.vars.check_period) {
       check_period = host.vars.check_period
      } else {
       check_period = "24x7"

I basically want to be able to disable the “ping4” against any hosts during this maintenance window. As you can see I attempted to use the same block of code as I used with the services but this fails with the error shown in my original message.

Any guidance would be greatly appreciated, thank you.


  if (vars.check_period) {
   check_period = vars.check_period
  } else {
   check_period = "24x7"

into a separate template and import it at the bottom in every host (as needed).

@Al2Klimov Thank you for the update. We’ve now put this in place so we’ll sit tight until our next round of Windows patching to see if this now behaves as expected.

I’ll go ahead and mark this as the solution and thanks once again for your assistance.