icinga2
icinga2 copied to clipboard
Allow to apply Notifications based on HostGroups
fixes #8116
Edit
Define an order in which to load Notifications after HostGroups, so Notification applies can use the HostGroups info.
Edit II
Maybe it already accidentally(!) just works for most(!) users and they don't need this PR. But IMAO if we wanna support this, we shall define the load order so Icinga always(!) has HostGroups while applying Notifications.
@cla-bot check
@Al2Klimov @julianbrost any plans to review and merge this? thanks in advance!
Was there some other change that "accidentally" fixed this? At least I failed to reproduce this on Icinga 2.13.6 with this config:
object CheckCommand "true" { command = ["true"] }
object NotificationCommand "true" { command = ["true"] }
object User "dummy" {}
object Host "aa" { check_command = "true" }
object Host "ab" { check_command = "true" }
object Host "ba" { check_command = "true" }
apply Service "x" { check_command = "true"; assign where true }
apply Service "y" { check_command = "true"; assign where true }
object HostGroup "a" {
assign where match("a*", host.name)
}
apply Notification "a-host-notification" to Host {
log("instantiating a-host-notification for " + host.name)
command = "true"
users = ["dummy"]
assign where "a" in host.groups
}
apply Notification "a-service-notification" to Service {
log("instantiating a-service-notification for " + host.name + "!" + service.name)
command = "true"
users = ["dummy"]
assign where "a" in host.groups
}
[2023-01-30 10:54:35 +0000] information/cli: Icinga application loader (version: v2.13.6)
[2023-01-30 10:54:35 +0000] information/cli: Loading configuration file(s).
[2023-01-30 10:54:35 +0000] information/ConfigItem: Committing config item(s).
[2023-01-30 10:54:35 +0000] information/config: instantiating a-service-notification for aa!x
[2023-01-30 10:54:35 +0000] information/config: instantiating a-service-notification for aa!y
[2023-01-30 10:54:35 +0000] information/config: instantiating a-service-notification for ab!x
[2023-01-30 10:54:35 +0000] information/config: instantiating a-service-notification for ab!y
[2023-01-30 10:54:35 +0000] information/config: instantiating a-host-notification for aa
[2023-01-30 10:54:35 +0000] information/config: instantiating a-host-notification for ab
[2023-01-30 10:54:35 +0000] information/ConfigItem: Instantiated 1 User.
[2023-01-30 10:54:35 +0000] information/ConfigItem: Instantiated 6 Services.
[2023-01-30 10:54:35 +0000] information/ConfigItem: Instantiated 1 NotificationCommand.
[2023-01-30 10:54:35 +0000] information/ConfigItem: Instantiated 6 Notifications.
[2023-01-30 10:54:35 +0000] information/ConfigItem: Instantiated 3 Hosts.
[2023-01-30 10:54:35 +0000] information/ConfigItem: Instantiated 1 IcingaApplication.
[2023-01-30 10:54:35 +0000] information/ConfigItem: Instantiated 1 HostGroup.
[2023-01-30 10:54:35 +0000] information/ConfigItem: Instantiated 1 CheckCommand.
[2023-01-30 10:54:35 +0000] information/ScriptGlobal: Dumping variables to file '/var/cache/icinga2/icinga2.vars'
[2023-01-30 10:54:35 +0000] information/cli: Finished validating the configuration file(s).
@rotanid Counter question: would you share your config and/or test this fix if I build packages for you?
IMAO explicit is better than implicit.