Good afternoon,
I’ve been trying for a while to configure the Notifications with Icinga Director using Marianne M. Spiller’s tutorial and scripts (https://www.unixe.de/icinga2-director-notifications/), but I still didn’t achieve to get the notifications automatically. I tried many other suggestions from different posts, FAQs, books, etc., but I still could not find out where the problem could be.
As you can see I already created the timeperiod template, the timeperiod, the user template, my own user, the notification template and the notifications. I am using Debian 10 with Icinga Web 2 Version 2.8.2 and the latest version of Icinga Director.
Time Period Template
zones.d/director-global/timeperiod_templates.conf
template TimePeriod “Generic Time Period Template” {
import “legacy-timeperiod”
includes = [ “Always” ]
ranges = {
“friday” = “00:00-24:00”
“monday” = “00:00-24:00”
“saturday” = “00:00-24:00”
“sunday” = “00:00-24:00”
“thursday” = “00:00-24:00”
“tuesday” = “00:00-24:00”
“wednesday” = “00:00-24:00”
}
}
Time Period
zones.d/director-global/timeperiods.conf
object TimePeriod “Always” {
import “legacy-timeperiod”
import “Generic Time Period Template”
display_name = "Always"
ranges = {
"friday" = "00:00-24:00"
"monday" = "00:00-24:00"
"saturday" = "00:00-24:00"
"sunday" = "00:00-24:00"
"thursday" = "00:00-24:00"
"tuesday" = "00:00-24:00"
"wednesday" = "00:00-24:00"
}
}
User Template
zones.d/director-global/user_templates.conf
template User “User Template” {
enable_notifications = true
period = “Always”
states = [ Critical, Down, OK, Unknown, Up, Warning ]
types = [
Acknowledgement,
Custom,
DowntimeEnd,
DowntimeRemoved,
DowntimeStart,
FlappingEnd,
FlappingStart,
Problem,
Recovery
]
}
My User
zones.d/Master/users.conf
object User “Javier” {
import “User Template”
display_name = "javier"
email = "my e-mail address"
enable_notifications = true
period = "Always"
}
Host Notification Template
zones.d/Master/notification_templates.conf
template Notification “Host Alarm By Email Template” {
command = “host alarm e-mail”
interval = 15s
period = “Always”
states = [ Critical, Down, OK, Unknown, Up, Warning ]
types = [
Acknowledgement,
Custom,
DowntimeEnd,
DowntimeRemoved,
DowntimeStart,
FlappingEnd,
FlappingStart,
Problem,
Recovery
]
users = [ “Javier” ]
}
Service Notification Template
zones.d/Master/notification_templates.conf
template Notification “Service Alarm By Email Template” {
command = “service alarm e-mail”
interval = 15s
period = “Always”
states = [ Critical, OK, Unknown, Warning ]
types = [
Acknowledgement,
Custom,
DowntimeEnd,
DowntimeRemoved,
DowntimeStart,
FlappingEnd,
FlappingStart,
Problem,
Recovery
]
users = [ “Javier” ]
}
Host Notification
zones.d/Master/notification_apply.conf
apply Notification “Host Alarm By Email” to Host {
import “Host Alarm By Email Template”
assign where host.enable_notifications == "true" || host.vars.notification == "mail"
users = [ "Javier" ]
}
Service Notification
zones.d/Master/notification_apply.conf
apply Notification “Service Alarm By Email” to Service {
import “Service Alarm By Email Template”
assign where service.enable_notifications == "true" || service.vars.notification == "mail" || host.vars.os == "Linux"
users = [ "Javier" ]
}
Scripts
object NotificationCommand “host alarm e-mail” {
import “plugin-notification-command”
command = [ PluginDir + “/etc/icinga2/scripts/host-by-mail.sh” ]
arguments += {
“-4” = {
required = true
value = “$address$”
}
“-6” = {
required = true
value = “$address6$”
}
“-d” = {
required = true
value = “$icinga.long_date_time$”
}
“-l” = {
required = true
value = “$host.name$”
}
“-n” = {
required = true
value = “$host.display_name$”
}
“-o” = {
required = true
value = “$host.output$”
}
“-r” = {
required = true
value = “$user.email$”
}
“-s” = {
required = true
value = “$host.state$”
}
“-t” = {
required = true
value = “$notification.type$”
}
}
}
object NotificationCommand “service alarm e-mail” {
import “plugin-notification-command”
command = [ PluginDir + “/etc/icinga2/scripts/service-by-mail.sh” ]
arguments += {
“-4” = {
required = true
value = “$address$”
}
“-6” = “$address6$”
“-d” = {
required = true
value = “$icinga.long_date_time$”
}
“-e” = {
required = true
value = “$service.name$”
}
“-l” = {
required = true
value = “$host.name$”
}
“-n” = {
required = true
value = “$host.display_name$”
}
“-o” = {
required = true
value = “$service.output$”
}
“-r” = {
required = true
value = “$user.email$”
}
“-s” = {
required = true
value = “$service.state$”
}
“-t” = {
required = true
value = “$notification.type$”
}
“-u” = {
required = true
value = “$service.display_name$”
}
}
}
icinga2 daemon -C Output
[2020-10-14 14:04:20 +0200] information/cli: Icinga application loader (version: r2.12.0-1)
[2020-10-14 14:04:20 +0200] information/cli: Loading configuration file(s).
[2020-10-14 14:04:20 +0200] warning/config: Ignoring directory ‘/etc/icinga2/zones.d/master’ for unknown zone ‘master’.
[2020-10-14 14:04:20 +0200] warning/config: Ignoring directory ‘/var/lib/icinga2/api/zones/NodeName’ for unknown zone ‘NodeName’.
[2020-10-14 14:04:20 +0200] warning/config: Ignoring directory ‘/var/lib/icinga2/api/zones/mon01.akademie.bildendekunst.ac.at’ for unknown zone ‘mon01.akademie.bildendekunst.ac.at’.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Committing config item(s).
[2020-10-14 14:04:20 +0200] information/ApiListener: My API identity: mon01.akademie.bildendekunst.ac.at
[2020-10-14 14:04:20 +0200] warning/ApplyRule: Apply rule ‘Host Alarm By Email’ (in /var/lib/icinga2/api/packages/director/05940512-2888-4d33-aff3-b00647ad6031/zones.d/Master/notification_apply.conf: 1:0-1:47) for type ‘Notification’ does not match anywhere!
[2020-10-14 14:04:20 +0200] warning/ApplyRule: Apply rule ‘Service Alarm By Email’ (in /var/lib/icinga2/api/packages/director/05940512-2888-4d33-aff3-b00647ad6031/zones.d/Master/notification_apply.conf: 8:1-8:54) for type ‘Notification’ does not match anywhere!
[2020-10-14 14:04:20 +0200] warning/ApplyRule: Apply rule ‘swap’ (in /var/lib/icinga2/api/packages/director/05940512-2888-4d33-aff3-b00647ad6031/zones.d/director-global/service_apply.conf: 121:1-121:20) for type ‘Service’ does not match anywhere!
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 ElasticsearchWriter.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 NotificationComponent.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 SyslogLogger.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 122 Hosts.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 GraphiteWriter.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 2 NotificationCommands.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 2 FileLoggers.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 IcingaApplication.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 PerfdataWriter.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 IcingaDB.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 CheckerComponent.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 3 Zones.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 GelfWriter.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 OpenTsdbWriter.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 StatusDataWriter.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 Endpoint.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 ExternalCommandListener.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 IdoMysqlConnection.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 2 ApiUsers.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 CompatLogger.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 ApiListener.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 288 CheckCommands.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 InfluxdbWriter.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 LivestatusListener.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 TimePeriod.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 1 User.
[2020-10-14 14:04:20 +0200] information/ConfigItem: Instantiated 496 Services.
[2020-10-14 14:04:20 +0200] information/ScriptGlobal: Dumping variables to file ‘/var/cache/icinga2/icinga2.vars’
[2020-10-14 14:04:20 +0200] information/cli: Finished validating the configuration file(s).
Please let me know if you need any further information.
Thank you for your help.
Best regards,
Javier