Failing to understand how notification time period and service check time period work together

Hi,
I have defined services that don’t require to be checked all day long, typically apt. I don’t want to receive more then 2 notifications per day about it. So I’ve defined a PointCheck period that checks for an hour between 07:00 and 08:00, but receive notification about that service outside of this range. I receive notification during all the Notification.period. Is this the expected behaviour?
Thank you for any insights.

object TimePeriod "PointCheck" {
    import "legacy-timeperiod"
    display_name = "WorkdayPointCheck"
    ranges = {
        "friday"	= "07:00-08:00"
        "monday"	= "07:00-08:00"
        "thursday"	= "07:00-08:00"
        "tuesday"	= "07:00-08:00"
        "wednesday"	= "07:00-08:00"
    }
}
template Service "apt" { 
    check_command = "[apt](nnnnn?name=apt)"    
    check_period = "PointCheck" 
    enable_notifications = true 
    enable_active_checks = true 
    enable_passive_checks = true 
    command_endpoint = host_name
 }
object TimePeriod "Workdays" {
    import "legacy-timeperiod"
    display_name = "9to5"
    ranges = {
        "friday"	= "09:00-17:00"
        "monday"	= "09:00-17:00"
        "thursday"	= "09:00-17:00"
        "tuesday"	= "09:00-17:00"
        "wednesday"	= "09:00-17:00"
    }
}
template Notification "Mail Service Notification" {
    command = "mail-service-notification"
    period = "Workdays"
    states = [ Critical, OK, Unknown, Warning ]
    types = [ Problem, Recovery ]
}
apply Notification "Mail Molbio Service Notification" to Service {
    import "Mail Service Notification"

    assign where host.enable_notifications != "false" && host.vars.department == "molbio"
    users = [ "Molbio" ]
}

Please read the docs:

https://icinga.com/docs/icinga2/latest/doc/08-advanced-topics/#time-periods

Try check_interval in your service template and define your timeperiod PointCheck.

object TimePeriod "08to10" {
  import "legacy-timeperiod"
  display_name = "08to10"
  ranges = {
        "monday"        = "08:00-10:00"
        "tuesday"       = "08:00-10:00"
        "wednesday"     = "08:00-10:00"
        "thursday"      = "08:00-10:00"
        "friday"        = "08:00-10:00"
        "saturday"      = "08:00-10:00"
        "sunday"        = "08:00-10:00"
  }
}

template Service "sap-basis" {
    import "generic-service"
	check_interval =	24h
	
	vars.sla = 	"workhours"

        vars.notification["mail"] = {
        groups = [ "sap-basis" ]
          }
}

apply Service "sap-backup"{
    import "sap-basis"
	check_period =		"08to10"
.
.
.

    assign where ...
}
1 Like

Excellent thank you, I have overseen that directive. I’ll see how I can use that.

You are welcome! :slight_smile:
Please mark it as a solution when it is done.