Hello,
I am currently configuring email notification on an Icinga 2 server, but run into a problem on the final step.
After spending lots of hours troubleshooting, I hope that I can get some external input as I have no clue what exactly is the problem.
To begin with:
I have made sure that the server itself is able to sent outbound email from the CLI.
Therefore I have configured mutt as root and run the following command to check if its working:
/usr/bin/printf "This is the body text" | mutt \
-e "set content_type=text/html" \
-s "This is the subject" \
my@mailaddress.com
A few seconds later I can see this email in my inbox - so no problem.
Then I have edited the mailscript /etc/icinga2/scripts/mail-host-notification.sh and changed it, so that the above command can send the email:
[...]
#Do not remove -e 'my_hdr From:', This is used for setting 'from' address in mutt
/usr/bin/printf "%b" "$template" | mutt -e "set content_type=text/html" -e 'my_hdr From:Icinga Monitoring<icinga@maildomain.com>' -s "$NOTIFICATIONTYPE - $HOSTDISPLAYNAME is $HOSTSTATE" $USEREMAIL
[...]
Then I followed this guide ( https://andreas.scherbaum.la/blog/archives/1101-How-to-configure-notifications-in-Icinga2-Director.html ) to create:
- a time period “always” in: Icinga Director → Timeperiods → Timeperiods
- a user template “generic-director-user-template” in: Icinga Director → Users/Contacts → User Templates and addes all states and transition types
- a new user with the same email, which I tested as recipient in CLI before in: Icinga Director → Users/Contacts → Users/Contacts
- Checked external commands for mail-host-notification in: Icinga Director → Commands → External Commands and made sure that it points to the correct file located at: /etc/icinga2/scripts/mail-host-notification.sh
- Created a notification template “host-notification-default-template” in: Icinga Director → Notifications → Notification Templates and pointed it to the external notification command (mail-host-notification) and addes states and transition types
- Created a “host notification” in: Icinga Director → Notifications → Notifications and importing the notification template and added the created user and set “Apply to” to Hosts and configuring the time period which I created. Additionally I set Assign where to “host enable_notifications = is true (or set)”
If I now click on deployment I get an error in the deployment log.
If I disable the created host notification which I created in step 6 by setting Disabled to True the deployment run will work.
[2022-05-18 14:51:38 +0200] information/cli: Icinga application loader (version: 2.13.0-1)
[2022-05-18 14:51:38 +0200] information/cli: Loading configuration file(s).
[2022-05-18 14:51:38 +0200] information/ConfigItem: Committing config item(s).
[2022-05-18 14:51:38 +0200] information/ApiListener: My API identity: vsrv-icinga-4.intern.DOMAIN.COM
[2022-05-18 14:51:39 +0200] critical/config: Error: Validation failed for object 'ITSWI02!E-Mails (Hosts)' of type 'Notification'; Attribute 'command': Object 'mail-host-notification' of type 'NotificationCommand' does not exist.
Location: in [stage]/zones.d/master/notification_templates.conf: 2:5-2:38
[stage]/zones.d/master/notification_templates.conf(1): template Notification "Notification Template E-Mail Host" {
[stage]/zones.d/master/notification_templates.conf(2): command = "mail-host-notification"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[stage]/zones.d/master/notification_templates.conf(3): states = [ Down, Up ]
I have looked into /var/lib/icinga2/api/zones/master/director/notification_templates.conf
template Notification "host-notification-default-template" {
command = "mail-host-notification"
states = [ Down, Up ]
types = [
Acknowledgement,
Custom,
DowntimeEnd,
DowntimeRemoved,
DowntimeStart,
FlappingEnd,
FlappingStart,
Problem,
Recovery
]
}
template Notification "E-Mail (Service)" {
command = "mail-service-notification"
states = [ Critical, OK, Unknown, Warning ]
types = [
Acknowledgement,
Custom,
DowntimeEnd,
DowntimeRemoved,
DowntimeStart,
FlappingEnd,
FlappingStart,
Problem,
Recovery
]
}
If I do a locate lookup just for mail-host-notification I only get the following results:
/etc/icinga2/scripts/mail-host-notification.sh
Am I maybe missing a file which links the command “mail-host-notification” to the script located at /etc/icinga2/scripts/mail-host-notification.sh ?
Any suggestions would be helpfull.
Kind regards from germany
- Pit