Add notification types and states to one service only

Hi everyone,

thanks for all the help and knowledge in this community, I have read a lot but wasn’t able to figure out how to solve my problem, so I decided to ask :slight_smile:

for our uptime monitoring service checks, I would like to remove the warning state and the recovery type, as I only want to know when the check is critical, that’s enough because I know okay it rebooted and I should check why, but I don’t care about the following warning and recovery notifications.

I tried different solutions but nothing worked, that was the last one:

apply Service "windows_uptime" {
  import "generic-service-agent"

  check_command = "windows_uptime"
  vars.notification["types"] = [ Custom, Acknowledgement, Problem, FlappingStart, FlappingEnd, ]
  vars.notification["states"] = [ OK, Critical, Unknown, ]
  assign where host.vars.os == "windows"
}

there are still warning and recovery notifications coming. so I guess it’s not possible to set these variables directly on the service, or do I have a syntax error?

here you can see how our notifications are configured:

# general mail-service template
template Notification "mail-service-notification" {
  command = "mail-service-notification"
  interval = 0s
  types = [ Custom, Acknowledgement, Problem, Recovery, FlappingStart, FlappingEnd, ]
  period = "24x7"
}

# 24x7 mail apply rule
apply Notification "mail-service-group" to Service {
  import "mail-service-notification"

  user_groups = [ "admins", ]
  assign where "mail" in service.vars.notifications
  ignore where "no_mail" in service.vars.notifications
  ignore where "no_notifications" in service.vars.notifications
  ignore where "no_notifications" in host.vars.notifications
  ignore where "officetime" in host.vars.notifications
  ignore where "officetime" in service.vars.notifications
}

we also have officetime notifications, so we don’t get alarmed during nighttime::

# officetime just sets another period
template Notification "mail-service-notification-officetime" {
  import "mail-service-notification"

  period = "officetime_de"
}

apply Notification "mail-service-officetime-apply" to Service {
  import "mail-service-notification-officetime"

  user_groups = [ "admins", ]
  assign where "officetime" in service.vars.notifications
  assign where "officetime" in host.vars.notifications
  ignore where "no_mail" in service.vars.notifications
  ignore where "no_mail" in host.vars.notifications
  ignore where "no_notifications" in service.vars.notifications
  ignore where "no_notifications" in host.vars.notifications
}

this works perfectly and a host like this will only send notifications during officetimes:

object Host "PROJECT-MELE05.project.zone" {
  import "generic-host-project-office"

  address = "172.16.2.125"
  vars.notifications = [ "officetime", ]
}

The question is, how do I implement for only the uptime check on all Windows hosts, that it should not send any recovery or warning notifications?

thank you and have a great day!
cheers

You can only set the notification filters on the notifications and the user objects.
So I would use a dedicated notification apply rule for your purpose and add a ignore in the regular one.