Director hosts have no contact group

I’ve created a notification command with icinga director that works well with the default hosts/services, it sends emails just like I want it to, but the hosts I created using the director dont send notifications. I tried sending custom notifications but I noticed a difference between the two:

  1. Icinga’s default host
    Screenshot_1
  2. My custom host using director
    Screenshot_2

I dont know if any of this could be related but i’d really appreciate some help, here are the rest of the specifications.

I am using Linux CentOS 7.

Hi @yvx

you will need a notification object that applies to the hosts that you created with the director.

Hello @ritzgu thank you for answering,

Could you please show me what is wrong with my notification object?


Can you set the assign where rule to is true (or set) instead of =?

Gives me this error when deployed and does not send notifications to my custom hosts:

[2022-07-21 10:44:48 +0000] information/cli: Icinga application loader (version: r2.13.4-1)
[2022-07-21 10:44:48 +0000] information/cli: Loading configuration file(s).
[2022-07-21 10:44:48 +0000] information/ConfigItem: Committing config item(s).
[2022-07-21 10:44:49 +0000] information/ApiListener: My API identity: localhost.localdomain
[2022-07-21 10:44:49 +0000] critical/config: Error: Validation failed for object 'test host!noti-h' of type 'Notification'; Attribute 'states': State filter is invalid.
Location: in [stage]/zones.d/localhost.localdomain/notification_apply.conf: 17:5-17:49
[stage]/zones.d/localhost.localdomain/notification_apply.conf(15):     interval = 10s
[stage]/zones.d/localhost.localdomain/notification_apply.conf(16):     assign where host.enable_notifications
[stage]/zones.d/localhost.localdomain/notification_apply.conf(17):     states = [ Critical, Down, Unknown, Warning ]
                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[stage]/zones.d/localhost.localdomain/notification_apply.conf(18):     types = [ Custom, Problem ]
[stage]/zones.d/localhost.localdomain/notification_apply.conf(19):     users = [ "paulo" ]
[2022-07-21 10:44:49 +0000] critical/config: Error: Validation failed for object 'printer!noti-h' of type 'Notification'; Attribute 'states': State filter is invalid.
Location: in [stage]/zones.d/localhost.localdomain/notification_apply.conf: 17:5-17:49
[stage]/zones.d/localhost.localdomain/notification_apply.conf(15):     interval = 10s
[stage]/zones.d/localhost.localdomain/notification_apply.conf(16):     assign where host.enable_notifications
[stage]/zones.d/localhost.localdomain/notification_apply.conf(17):     states = [ Critical, Down, Unknown, Warning ]
                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[stage]/zones.d/localhost.localdomain/notification_apply.conf(18):     types = [ Custom, Problem ]
[stage]/zones.d/localhost.localdomain/notification_apply.conf(19):     users = [ "paulo" ]
[2022-07-21 10:44:49 +0000] critical/config: Error: Validation failed for object 'localhost.localdomain!test noti' of type 'Notification'; Attribute 'users': Object 'user' of type 'User' does not exist.
Location: in /etc/icinga2/conf.d/notifications.conf: 37:3-37:18
/etc/icinga2/conf.d/notifications.conf(35): apply Notification "test noti" to Host {
/etc/icinga2/conf.d/notifications.conf(36):   import "mail-host-notification"
/etc/icinga2/conf.d/notifications.conf(37):   users = ["user"]
                                              ^^^^^^^^^^^^^^^^
/etc/icinga2/conf.d/notifications.conf(38): 
/etc/icinga2/conf.d/notifications.conf(39):   //interval = 2h
[2022-07-21 10:44:49 +0000] critical/config: Error: Validation failed for object 'localhost.localdomain!noti-h' of type 'Notification'; Attribute 'states': State filter is invalid.
Location: in [stage]/zones.d/localhost.localdomain/notification_apply.conf: 17:5-17:49
[stage]/zones.d/localhost.localdomain/notification_apply.conf(15):     interval = 10s
[stage]/zones.d/localhost.localdomain/notification_apply.conf(16):     assign where host.enable_notifications
[stage]/zones.d/localhost.localdomain/notification_apply.conf(17):     states = [ Critical, Down, Unknown, Warning ]
                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[stage]/zones.d/localhost.localdomain/notification_apply.conf(18):     types = [ Custom, Problem ]
[stage]/zones.d/localhost.localdomain/notification_apply.conf(19):     users = [ "paulo" ]
[2022-07-21 10:44:49 +0000] critical/config: Error: Validation failed for object 'teste 1!noti-h' of type 'Notification'; Attribute 'states': State filter is invalid.
Location: in [stage]/zones.d/localhost.localdomain/notification_apply.conf: 17:5-17:49
[stage]/zones.d/localhost.localdomain/notification_apply.conf(15):     interval = 10s
[stage]/zones.d/localhost.localdomain/notification_apply.conf(16):     assign where host.enable_notifications
[stage]/zones.d/localhost.localdomain/notification_apply.conf(17):     states = [ Critical, Down, Unknown, Warning ]
                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[stage]/zones.d/localhost.localdomain/notification_apply.conf(18):     types = [ Custom, Problem ]
[stage]/zones.d/localhost.localdomain/notification_apply.conf(19):     users = [ "paulo" ]
[2022-07-21 10:44:49 +0000] critical/config: 5 errors
[2022-07-21 10:44:49 +0000] critical/cli: Config validation failed. Re-run with 'icinga2 daemon -C' after fixing the config.

From what I can see it seems like its still clinging on to deleted notifications and users…

I think that you are mixing states here. Valid host states are Up and Down. See Host States.

Changed it solely to Down

apply Notification "noti-h" to Host {
    import "test-h"

    times = {
        end = 2s
    }
    interval = 10s
    assign where host.enable_notifications
    states = [ Down ]
    users = [ "paulo" ]
}

But nothing has really changed, its not sending notifications nor did the deployment error go away.

[2022-07-21 13:39:34 +0000] information/cli: Icinga application loader (version: r2.13.4-1)
[2022-07-21 13:39:34 +0000] information/cli: Loading configuration file(s).
[2022-07-21 13:39:35 +0000] information/ConfigItem: Committing config item(s).
[2022-07-21 13:39:36 +0000] information/ApiListener: My API identity: localhost.localdomain
[2022-07-21 13:39:36 +0000] critical/config: Error: Validation failed for object 'localhost.localdomain!test noti' of type 'Notification'; Attribute 'users': Object 'user' of type 'User' does not exist.
Location: in /etc/icinga2/conf.d/notifications.conf: 37:3-37:18
/etc/icinga2/conf.d/notifications.conf(35): apply Notification "test noti" to Host {
/etc/icinga2/conf.d/notifications.conf(36):   import "mail-host-notification"
/etc/icinga2/conf.d/notifications.conf(37):   users = ["user"]
                                              ^^^^^^^^^^^^^^^^
/etc/icinga2/conf.d/notifications.conf(38): 
/etc/icinga2/conf.d/notifications.conf(39):   //interval = 2h
[2022-07-21 13:39:36 +0000] critical/config: 1 error
[2022-07-21 13:39:36 +0000] critical/cli: Config validation failed. Re-run with 'icinga2 daemon -C' after fixing the config.

Well, the error has changed :slight_smile: You first have to create a User object (Icinga Director → Users / Contacts).

This is so frustrating… I created a new User object like this:

object User "notificator" {
    import "user-h"

    display_name = "noti"
    email = "xxxxxxxxxxx@gmail.com"
    states = [ Down, Up ]
}

But it still gives the same error when deploying…

[2022-07-22 11:11:59 +0000] information/cli: Icinga application loader (version: r2.13.4-1)
[2022-07-22 11:11:59 +0000] information/cli: Loading configuration file(s).
[2022-07-22 11:11:59 +0000] information/ConfigItem: Committing config item(s).
[2022-07-22 11:12:00 +0000] information/ApiListener: My API identity: localhost.localdomain
[2022-07-22 11:12:00 +0000] critical/config: Error: Validation failed for object 'localhost.localdomain!test noti' of type 'Notification'; Attribute 'users': Object 'user' of type 'User' does not exist.
Location: in /etc/icinga2/conf.d/notifications.conf: 37:3-37:18
/etc/icinga2/conf.d/notifications.conf(35): apply Notification "test noti" to Host {
/etc/icinga2/conf.d/notifications.conf(36):   import "mail-host-notification"
/etc/icinga2/conf.d/notifications.conf(37):   users = ["user"]
                                              ^^^^^^^^^^^^^^^^
/etc/icinga2/conf.d/notifications.conf(38): 
/etc/icinga2/conf.d/notifications.conf(39):   //interval = 2h
[2022-07-22 11:12:00 +0000] critical/config: 1 error
[2022-07-22 11:12:00 +0000] critical/cli: Config validation failed. Re-run with 'icinga2 daemon -C' after fixing the config.

The user its refering to is a deleted Object user but for some reason its still clinging on to that…

Your icinga is looking for a user called “user” which probably does not exist. You created a user with the name “notificator”.

You could either: rename the newly created user Object from “notificator” to “user”, OR change the user in the notification object from “user” to “notificator” (the property “Users”). The reason it is still clinging is probably because it is still set in the notification object:

While you are at it you could also check if a user group called “users” already exists. :slight_smile:

This is how it looks like
Screenshot_17


But I will try to change “notificator” to “user” like you said.

It worked, changing the name to “user” made it deploy without any issues.

This is how the notification apply rule looks like now:

apply Notification "noti-h" to Host {
    import "test-h"

    times = {
        end = 2s
    }
    interval = 10s
    assign where host.enable_notifications
    states = [ Down ]
    users = [ "user" ]
}

However it still doesnt send notifications nor show the contacts…

Screenshot_19

I’d assume this has to be

host.vars.enable_notifications

I tried it because i was curious:

object Host "testhost" {
        check_command = "dummy"
}

apply Notification "testnoti" to Host {
        command = "testnoticommand"
        user_groups = [ "testgroup" ]
        assign where host.enable_notifications
}
object NotificationCommand "testnoticommand" {
        command = "dummy"
}
object UserGroup "testgroup" {
}

image

host.enable_notifications is true:

> icinga2 object list --type Host --name "testhost"
Object 'testhost' of type 'Host':
  [...]
  * check_timeout = null
  * command_endpoint = ""
  * display_name = "testhost"
  * enable_active_checks = true
  * enable_event_handler = true
  * enable_flapping = false
  * enable_notifications = true
  * enable_passive_checks = true
[...]

@yvx
Can you check if enable_notifications is actually true for the host?
icinga2 object list --type Host --name "name_of_your_host"

Done, deployed with no problem but I’m afraid nothing has changed

Yes, it is set to true