Different notification for host and service for the same user

Hey guys,

So I’m working on notifications atm and couldn’t find a way to solve this:

I have an admin user like this:

object User “admin” {
email = “admin@admin”
period = “24x7”
states = [ OK, Warning, Critical, Unknown ]
}

The problem is, atm my admin user receives those notification states for both hosts and services. What I need is to receive only “OK” states from hosts and “Ok, Warning, Critical, Unknown” from services.

Is there any way I can separete the states, so a host just notify “Ok” and service “Ok,Warning,Critical,Unknown” for the same user?

Also, could I use different notification commands for the same user? For example:

If a host goes down Icinga notify “admin” through telegram.
If a service goes down Icinga notify “admin” through email.

Thanks

Hi,

look into the notification apply rules you already have. These notification objects can be configured with states and types filters.

If you need an exception for just one host name, or a group of hosts for instance, there’s 2 possibilities:

  • Create a secondary host apply rule which matches for this host, and modify the first to exclude the host (e.g. with a new host custom attribute)
  • Use conditions inside the notification apply rule to match on a specific host pattern and explicitly set the states for this, e.g.
  if (match("abc*", host.name) {
     states = [ "Down", "Up" ]
  }

In terms of different commands for different users, you’ll need to use different notification apply rules which specify the command referencing a NotificationCommand object.

Or you go again with the host pattern match and specify a different notification command.

  if (match("*abc", host.name)) {
    command = "telegram"
  } else {
     command = "mail"
  }

Cheers,
Michael

1 Like