Email Notification

(Software Info) #1

Hi All
I am wondering. How does Icinga know which email server to send emails through and can this be set manually? I am asking because for the first time I have an install that doesn’t just work after I set up the users.conf.

Regards

(Michael Friedrich) #2

The example scripts call the mail binary which depends on your installed MTA. Some distributions prefer exim, some sendmail, some postfix. All of them can and must be configured, especially if you want to use a mailserver as relay.

1 Like
(Nicolai) #3

Icinga sends the notifications via an executable script. Example script for sending email notifications are provided along with the icinga2 packages in /etc/icinga2/scripts/.

These script use the systems mail utility, which relies on a working local email configuration on your monitoring host. Usually this is done with a local installation of postfix, exim, ssmtp or whatever you prefer.

TL;DR: You should configure your monitoring server as a satelite host or verify that sending mails as an MTA is working.

1 Like
(Software Info) #4

Thanks. So I have now installed and configured Postfix and I can send an email from the commandline. I notice though that when I try to trigger a notification from within icingaweb:, the email sender address is nagios@localhost and the email doesn’t get delivered. I am trying to rewrite this from Icinga but I haven’t been successful as yet. Is this done from the script or is there a place in Icingaweb that can?

#5

you can change the sending mail address by setting the custom variable “vars.notification_from” in your Notification object. This variable is used by the standard mail notification script when set.

(Michael Friedrich) #6

Keep in mind that this only works for some MTAs. Look into the notification scripts how it is used and implemented for calling the mail binary. It has been tested on RHEL, Debian and SLES, others may need changes.

1 Like
(Nicolai) #7

You could also do the rewrite in your MTA configuration.

With postfix the smtp_generic_maps option would do the trick. Have a look at the postfix documentation: http://www.postfix.org/ADDRESS_REWRITING_README.html#generic

(Software Info) #8

Thanks so much for all the input. Here is what worked for me.

[main.cf]
canonical_maps = hash:/etc/postfix/canonical

[canonical]
nagios@debian-8 icinga-HA@mydomain.com

1 Like
(Software Info) #9

So a bit of a correction. It seems the proper solution is sender_canonical_maps and not just canonical maps so only the sender address is rewritten. Working now as expected

(Andre) #10

Is there also a howto for Ubuntu 18.04 with exim4 ?

I get nagios@domain.de and I want icinga2@domain.de

Thx