Over load service so it checks once per week

Hello, I am trying to adjust one service so it only checks and notifies once per week. I want the other services to continue to check as per regular schedule, I only want one service to check weekly.

in templates.conf I have.

  template Host "generic-host" {
    max_check_attempts = 3
    check_interval = 1h
    retry_interval = 30m
    check_command = "hostalive"
    vars.family = "Debian"
}

The host is importing “generic-host”. Most of the OS’s is Debian based and I am only overloading the family variable in cases where its RHEL/Centos or BSD.

I then created.


template Service "weekly-service-check" {
  max_check_attempts = 5
  check_interval = 168h
  retry_interval = 24h
}

In services.conf I have

  apply Service "apt"{
      import "weekly-service-check"
      check_command = "apt"
      command_endpoint = host.vars.client_endpoint
      assign where (host.address || host.address6) && host.vars.os == "Linux" && host.vars.family == "Debian"
    }

It seems to not be working as expected. Am I missing a setting in the actual hosts entry?

Can you explain why you think that it is not working, or even better show it (with a screenshot maybe?)
Maybe also show the config of one of the hosts.

Host and service check intervals are two different pairs of shoes. They don’t influence each other.

1 Like

I set the service to check and notify every 1 week. However, its still checking and notifying of critical updates every 1 hour.

object Zone "fqdn.name" {
        endpoints = [ "fqdn.name" ]
        parent = "master"
}

object Endpoint "fqdn.name" {
  host = "ip.addr"
  log_duration = 0
}

object Host "fqdn.name" {
  import "generic-host"
  address = "ip.addr"

  vars.client_endpoint = name
  vars.os = "Linux"
  vars.type = "Webserver"

  vars.disks["disk /"] = {
    disk_partitions = "/"
  }

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

}

Ok, so you have set the check interval for the service to one week.
Does this work correctly? What is the next check date in the icinga web interface?

Then you are talking about notifications.
The notification interval is a “third pair of shoes” :wink: It has nothing to does with neither the host check interval nor the service check interval.
So you will have to create a dedicated time period for the notifications and assign this time period to the notification rule.
Check: https://icinga.com/docs/icinga2/latest/doc/09-object-types/#timeperiod

I checked the web interface. No, i havent made a item in notifictations for the service. I didnt know you had to.

|Command |apt Process check result|
|---|---|
|Check Source |fqdn|
|Reachable |yes|
|Last check |1m 0s ago|
|Next check |on Oct 22 Reschedule|
|Check attempts |1/5 (hard state)|
|Check execution time |1.08s|

So the check interval is working correct.
You will now have to figure out how to handle notifications.

You can put a delay on the notification, to delay the delivery.
Or you can define a dedicated time period for sending the notifications, add this time period to a notification template and then create a notification rule with the template.
Check the docs for the time period configuration (see link in my last post)

1 Like

Hello, I did some more work on it and created a special service check as well as notification for apt service so it only notifies on one day. its still seems to be sending out all day long notifications.

do i need to specifically create an ignore statement for the server because its also being included in the global service checks still? below is my code.

    template Notification "mail-service-notification" {
      command = "mail-service-notification"
      states = [ OK, Warning, Critical, Unknown ]
      types = [ Problem, Acknowledgement, Recovery, Custom,
                FlappingStart, FlappingEnd,
                DowntimeStart, DowntimeEnd, DowntimeRemoved ]
      vars += {
        notification_logtosyslog = false
      }
      period = "24x7"
    }

    template Notification "apt-mail-service-notification" {
      import "mail-service-notification"
      period = "Thursday-only"
    }

    apply Notification "apt-service-notify" to Service {
      import "apt-mail-service-notification"
      user_groups = [ "webdevs" ]
      assign where match ("*apt*", service.check_command)
    }
	
    object TimePeriod "Thursday-only" {
      import "legacy-timeperiod"
      display_name = "Thursday Only"
      ranges = {
        "thursday"   = "12:00-22:00"
      }
    }

    template Service "weekly-service-check" {
      max_check_attempts = 5
      check_interval = 7d
      retry_interval = 1d
    }

    apply Service "apt"{
      import "weekly-service-check"
      check_command = "apt"
      command_endpoint = host.vars.client_endpoint
      assign where (host.address || host.address6) && host.vars.os == "Linux" && host.vars.family == "Debian"
    }

  template Host "generic-host" {
    max_check_attempts = 3
    check_interval = 1h
    retry_interval = 30m
    check_command = "hostalive"
    vars.family = "Debian"
}

Hello, I did some more work on it and created a special service check as
well as notification for apt service so it only notifies on one day. its
still seems to be sending out all day long notifications.

Try adding “interval = 0” to the following stanza:

template Notification "mail-service-notification" {
  command = "mail-service-notification"
  states = [ OK, Warning, Critical, Unknown ]
  types = [ Problem, Acknowledgement, Recovery, Custom,
            FlappingStart, FlappingEnd,
            DowntimeStart, DowntimeEnd, DowntimeRemoved ]
  vars += {
    notification_logtosyslog = false
  }
  period = "24x7"
}

See https://icinga.com/docs/icinga2/latest/doc/03-monitoring-basics/#disable-
renotification for more details.

Antony.