Service vs. Host notification periods

Hi,

we’ve got a host that has a notification period called workhours and we have a service, which is assigned to specific hosts/groups, and it has a 24x7 period. Now that overrides/ignores the host period for that particular host. Is it somehow possible, without having to duplicate services/periods or something, to just toggle a switch, set an option, to inherit the host period instead, to now wake me up at midnight? Is there an easy way to do that?

Hi,

that sounds a little like Icinga 1.x config. If not, please share the existing notification apply rules, and sample host/service objects from Icinga 2.

Cheers,
Michael

 apply Service "ssh_restrict_load" {
    import "generic-service"

    check_command = "ssh_restrict"
    display_name = "Load Average SSH"

    vars.command = "loadavg"

    vars.param1 = "6.0,5.0,4.0"
    vars.param2 = "9.0,7.5,6.0"

    check_interval = 5m
    retry_interval = 5m

    vars.notification_period = "mon_sun_08-22"

    assign where "RHEL_Server_notify" in host.groups
    assign where "CentOS_Server_notify" in host.groups
    assign where "Debian_Server_notify" in host.groups
    assign where "Ubuntu_Server_notify" in host.groups
    assign where "Gentoo_Server_notify" in host.groups
    assign where "SLES_Server_notify" in host.groups
}

object Host "somehost" {
        import  "generic-host"

        address = "192.168.1.1"
        display_name = name + ":Test VM"
        vars.notification_period = "workhours"
        enable_notifications = true
        groups = ["CentOS_Server", "CentOS_Server_notify"]
        vars.state = "online"
        vars.distribution = "CentOS"
        vars.arch = "64 Bit"
        vars.release = "7.0" 
        vars.manufacturer = "VM"
}

object TimePeriod "workhours" {
  import "legacy-timeperiod"

  display_name = "Normal Work Hours"
  ranges = {
    "monday" 	= "09:00-18:00"
    "tuesday" 	= "09:00-18:00"
    "wednesday" = "09:00-18:00"
    "thursday" 	= "09:00-18:00"
    "friday" 	= "09:00-18:00"
  }
}

object TimePeriod "mon_sun_08-22" {
  import "legacy-timeperiod"

  display_name = "Timeperiod Mon-Sun 08-22"
  ranges = {
    "monday"    = "08:00-22:00"
    "tuesday"   = "08:00-22:00"
    "wednesday" = "08:00-22:00"
    "thursday"  = "08:00-22:00"
    "friday"    = "08:00-22:00"
    "saturday"  = "08:00-22:00"
    "sunday"    = "08:00-22:00"
  }
}

And the notification apply rules?

You mean like:
template Notification “mail-host-notification” {
command = “mail-host-notification”

  states = [ Up, Down ]
  types = [ Problem, Acknowledgement, Recovery, Custom,
            FlappingStart, FlappingEnd,
            DowntimeStart, DowntimeEnd, DowntimeRemoved ]

  period = "24x7"
}

apply Notification "host-sms" to Host {
    import "mail-host-notification"

    command = "sms-host-notification"

    states = [ Down ]
    types = [ Problem ]

    if (host.vars.notification_interval) {
        interval = host.vars.notification_interval
    } else {
        interval = 1h
    }

    user_groups = host.vars.user_groups

    period = host.vars.notification_period

    assign where host.enable_notifications
}