yvx
(paulo)
July 18, 2022, 10:37am
1
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:
Icinga’s default host
My custom host using director
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.
ritzgu
July 19, 2022, 5:06pm
2
Hi @yvx
you will need a notification object that applies to the hosts that you created with the director.
yvx
(paulo)
July 20, 2022, 10:30am
3
Hello @ritzgu thank you for answering,
Could you please show me what is wrong with my notification object?
ritzgu
July 21, 2022, 10:39am
4
Can you set the assign where rule to is true (or set)
instead of =
?
yvx
(paulo)
July 21, 2022, 10:50am
5
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…
ritzgu
July 21, 2022, 12:33pm
6
paulo:
Attribute 'states': State filter is invalid.
[...]
[stage]/zones.d/localhost.localdomain/notification_apply.conf(17): states = [ Critical, Down, Unknown, Warning ]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I think that you are mixing states here. Valid host states are Up
and Down
. See Host States .
yvx
(paulo)
July 21, 2022, 1:42pm
7
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.
ritzgu
July 21, 2022, 6:01pm
8
Well, the error has changed You first have to create a User object (Icinga Director → Users / Contacts).
yvx
(paulo)
July 22, 2022, 11:14am
9
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…
ritzgu
July 22, 2022, 11:46am
10
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:
paulo:
While you are at it you could also check if a user group called “users” already exists.
yvx
(paulo)
July 22, 2022, 1:35pm
11
This is how it looks like
But I will try to change “notificator” to “user” like you said.
yvx
(paulo)
July 22, 2022, 1:37pm
12
It worked, changing the name to “user” made it deploy without any issues.
yvx
(paulo)
July 22, 2022, 1:40pm
13
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…
rsx
(Roland Sommer)
July 22, 2022, 2:08pm
14
I’d assume this has to be
host.vars.enable_notifications
ritzgu
July 23, 2022, 9:17am
15
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" {
}
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"
yvx
(paulo)
July 25, 2022, 10:27am
16
Done, deployed with no problem but I’m afraid nothing has changed