DIfferent notification settings for users

Hi, I am sure this is possible but I am having issues finding it in the doc.

I would like to over ride default notification settings for a used based on host or service monitored.

For example, I have two notification periods setup. 24x7 and 9-5.

User A is set to be notified 9-5 week days by default.

But for certain hosts or services, I was the user to be notified 24x7.

Hi and welcome to the community. Firstly, share your config as an example for host/ service, timeperiod, notificationtemplate, notification, user/ usergroup.
I think there is a problem in heredity.

Host:

object Host “t1” {
import “unix-work”
address = “iii.pp.i.p”
notes = “SLES12 Testserver”
vars.os = “linux”
vars.sla = “never” //overwrites vars.sla from hosttemplate
vars.time = false
}

Hosttemplate:

template Host "unix-work" {
	import "generic-host" 
	icon_image = "custom/suse.png"	
	vars.os =	"linux"
	vars.sla = 	"workhours"

	vars.notification["mail"] = {
		groups = [ "unix" ]
	}
}

Timeperiod:

object TimePeriod "workhours" {
  import "legacy-timeperiod"
  display_name = "Buerozeiten"
  ranges = {
        "monday"        = "07:00-17:00"
        "tuesday"       = "07:00-17:00"
        "wednesday"     = "07:00-17:00"
        "thursday"      = "07:00-17:00"
        "friday"        = "07:00-15:00"
  }
}

Notificationtemplate:

template Notification "host-workhours" {
  interval = 6h

  command = "mail-host-notification"
  states = [ Up, Down ]
  types = [ Problem, Acknowledgement, Recovery, Custom,
                        FlappingStart, FlappingEnd,
                        DowntimeStart, DowntimeEnd, DowntimeRemoved ]
  period = "workhours"
}

Notifications:

apply Notification "mail-host-workhours" to Host {
  import "host-workhours"

  user_groups = host.vars.notification.mail.groups
  users = host.vars.notification.mail.users

  assign where host.vars.sla == "workhours" && host.vars.notification.mail
  ignore where host.vars.sla == "never"
}

apply Notification "mail-service-workhours" to Service {
  import "service-workhours"

   if (service.vars.notification.mail.users) {
          users = service.vars.notification.mail.users
   } else {
          users = host.vars.notification.mail.users
   }

   if (service.vars.notification.mail.groups) {
          user_groups = service.vars.notification.mail.groups
   } else {
          user_groups = host.vars.notification.mail.groups
   }

  assign where service.vars.sla == "workhours" && host.vars.notification.mail
  ignore where host.vars.sla == "never"
}

Hi & welcome to the community,

can you share your existing notification apply rules to get a better idea what to suggest?

In case of such special cases, I strongly recommend to create different notification apply rules with period attributes, and assigned users.

E.g. for specific services/hosts matched via assign where expression, 9to5 applies and sets the users array.

apply Notification "basic-services-mail-9to5" to Service {
  //...
  period = "9to5"

  users = [ "userA" ]

  assign where match("*disk*", service.name)
}

A different one could be ping which highlights an outage of the host itself.

apply Service "ping-service-mail-24x7" to Service {
  //...
  period = "24x7"

  users = [ "userA" ]

  assign where match("*ping*", service.name)
}

Cheers,
Michael

2 Likes

Thanks. That worked.