Multiple Notifications with same assign parameter

Hello,

I’m currently trying to assign two notifications with the same “assign” rule but it doesn’t work.

I must do the following behaviour for my notifications :

  • Send a notification immediatly to some users
  • Send a delayed notification in case no ACK or RECOVERY status happend after 20min

I tried the following configurations (notifications.conf) :

apply Notification "pager-sms-host" to Host {
    command = "sms-host-notification"
    user_groups = [ "pager_group" ]
    assign where "pager" in host.vars.notifications
    interval = 0 # Disable re-notification
}

apply Notification "notify-alert-delay-host" to Host {
    command = "alert-delay-host"
    users = [ "rescue_user" ]
    assign where "pager" in host.vars.notifications
    interval = 0 # Disable re-notification
    times.begin = 20m
}​

The problem is that only the first notification is applied to the hosts having “pager” in vars.notifications. I can’t assign the second to the same host.

Is there any solution to make the behaviour discribed ?

And one final question : with the times.begin instruction, if an ACK or a RECOVERY occurs before the notification should be send, does the notification still be send ?

Thank you and have a nice day !

How do you validate that?

What is the output of
icinga2 object list --type notification --name 'SomeHost!pager-sms-host'
and
icinga2 object list --type notification --name 'SomeHost!notify-alert-delay-host

No, the delayed notification will only be sent if the problem persists/is not handled.

Hello,

Thanks for your answer.

The output of the command icinga2 object list --type notification shows this :

icinga2 object list --type notification --name 'TEST_CRS!pager-sms-host'

Object 'TEST_CRS!pager-sms-host' of type 'Notification':
  % declared in '/etc/icinga2/tvs.d/notifications.conf', lines 58:1-58:47
  * __name = "TEST_CRS!pager-sms-host"
  * command = "sms-host-notification"
    % = modified in '/etc/icinga2/tvs.d/notifications.conf', lines 59:5-59:37
  * command_endpoint = ""
  * host_name = "TEST_CRS"
    % = modified in '/etc/icinga2/tvs.d/notifications.conf', lines 58:1-58:47
  * interval = 0
    % = modified in '/etc/icinga2/tvs.d/notifications.conf', lines 62:5-62:16
  * name = "pager-sms-host"
  * package = "_etc"
    % = modified in '/etc/icinga2/tvs.d/notifications.conf', lines 58:1-58:47
  * period = ""
  * service_name = ""
  * source_location
    * first_column = 1
    * first_line = 58
    * last_column = 47
    * last_line = 58
    * path = "/etc/icinga2/tvs.d/notifications.conf"
  * states = null
  * templates = [ "pager-sms-host" ]
    % = modified in '/etc/icinga2/tvs.d/notifications.conf', lines 58:1-58:47
  * times = null
  * type = "Notification"
  * types = null
  * user_groups = [ "tvs_pager" ]
    % = modified in '/etc/icinga2/tvs.d/notifications.conf', lines 60:5-60:33
  * users = null
  * vars = null
  * zone = ""

icinga2 object list --type notification --name 'TEST_CRS!notify-alert-delay-host'
[no output]

Even without the --name parameter, I don’t find my notification notify-alert-delay-host for any host.

But if I comment in the notifications.conf file the notification pager-sms-host, it displays the other notification.

So I don’t know how to set these two notifications for the same host …

Thank you for your clarification about times.begin !

That sounds strange.
Any warnings when running icinga2 daemon -C that could help?

Have tried it with the Director.
Two apply rules, named differently with the same assign statement:

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

    assign where host.vars.os in [ "Windows" ]
    users = [ "icingaadmin23" ]
}
apply Notification "test1" to Host {
    import "mail-host-notification"

    assign where host.vars.os in [ "Windows" ]
    users = [ "icingaadmin" ]
}

Works without problems.

The only thing that differs from your config is the order of the variable and the content in the assign where.

What type is the variable host.vars.notifications? Is it an array or a simple string?

Nothing related to my notifications in icinga2 daemon -C.

I tried to change the assign parameter like your example :

apply Notification "notify-alert-delay-host" to Host {
    command = "alert-delay-host"
    users = [ "rescue_user" ]
    assign where host.vars.notifications in [ "pager" ]
    interval = 0 # Disable re-notification
    times.begin = 20m
}​

But it didn’t fix the issue.

The var host.vars.notifications is an array :

object Host "TEST_CRS" {
  import "host-5m"
  address = "MY IP"
  display_name = "TEST CRS"
  check_command = "hostalive"
  vars.notifications = [ "pager" ]
}

I tried to create a new user and set this user to be notified with this notification, but it didn’t change anything either…

I tried to remove all unused objects listed in icinga2 daemon -C but it didn’t change either…

I don’t know where the issue could occurs…

:thinking: :face_with_raised_eyebrow: :man_shrugging:

I’m out of ideas as well.
Maybe we are overlooking something totally obvious, but I can’t lay my finger on it.

Yes, it’s very strange…

Anyway, thank you for your help ! :slightly_smiling_face:

Hello,

I think I found a workaround. To make multiple notifications on same “assign” instruction, I created another file where I put my other configuration.

For example, I had one file called notifications.conf containing all notification types. When I put another notification with the same assign value, only the first one was executed.

To set another Notification with the same assign value, I created the file notifications_delay.conf in the same folder and now it works.