Page 1 of 2
Email Notifications
Posted: Wed Oct 31, 2018 11:30 am
by workid
Hi, could someone help me or point me in the direction of an up-to-date guide of setting email notifications with Nagios Core?
I have setup my mail contacts in contacts.cfg
I understand i need to install a 3rd party such as Postfix to relay the mail, i did find a guide but this also used a program called Heirloom-MailX, which i understand does not exists now. The guide was from years ago so anything up-to-date that points me in the right direction would be great.
I would be wanting to send emails to myself & colleagues who's mail is on an exchange server, would that need to be setup to allow mails from Nagios or Postfix as well?
Any info would be great.
Thanks
Pete
Re: Email Notifications
Posted: Wed Oct 31, 2018 4:51 pm
by tgriep
If you have already installed postfix on the server and are looking for instructions for relaying the emais to your exchange server, the following link has an example for you to setup Postfix to relay emails and instructions on setting up authentication to the relay server. You would need to do this if the Exchange server requires it.
https://www.howtoforge.com/postfix_rela ... mailserver
Is this what you are looking for?
Re: Email Notifications
Posted: Mon Nov 05, 2018 10:41 am
by workid
Thanks for that.
I now have postfix setup and can mail to internal linux user.
I followed the guide above and have it all setup, but I'm unable to to send any mail, checking the logs im getting a error:
Code: Select all
Nov 5 15:35:00 GC-NAGIOS postfix/smtp[9093]: 3FA883E2A2D: to=<my.user@mymail.ac.uk>, relay=mail.mymail.ac.uk[123.19.1.19]:25, delay=1100, delays=1095/0.01/5/0, dsn=4.7.3, status=deferred (SASL authentication failed; server mail.mymail.ac.uk[123.19.1.19] said: 535 5.7.3 Authentication unsuccessful)
The username and password are correct so i don't know why it wont authenticate with the mail server, i have checked it is in the right format (username:password), i don't know if there is anything i need to to do on the exchange server side for this to work.
anyone got any ideas?
Re: Email Notifications
Posted: Mon Nov 05, 2018 4:05 pm
by tgriep
You would check to see if port 25 is the correct port the exchange server needs as well as what type of security settings it needs.
TLS or SSL.
The administrator of the server should be able to answer those questions.
Re: Email Notifications
Posted: Tue Nov 06, 2018 8:41 am
by workid
Thanks for that... i needed to add the server as an allowed relay in Exchange 2016.
One last thing... do i need to tell Nagios Core that Postfix is installed in Nagios somewhere?
How does Nagios and Postfix link, so that it can send the notifications?
Re: Email Notifications
Posted: Tue Nov 06, 2018 12:36 pm
by tgriep
The commands that are defined in Core by default use the mail application to send the emails to the local Mailer Daemon which is Postfix in your case.
That is the default way it works and you do not have to link them to work.
Re: Email Notifications
Posted: Wed Nov 07, 2018 8:20 am
by workid
Ok, just im not receiving any notifications from Nagios.
I have setup contacts and a contact group,
Code: Select all
define contact {
contact_name Phudson ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email myname@mymail.ac.uk ;
}
define contact {
contact_name ITservices ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias IT Services ; Full name of user
email anothername@mymail.ac.uk ;
}
define contactgroup {
contactgroup_name admins
alias Nagios Administrators
members Phudson, ITservices
}
i have also set notification on a host and also a service.
Code: Select all
define host {
use windows-server
host_name windows10-thinapp
alias Test
address 123.14.136.147
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
contact_groups admins
}
define service {
use local-service ; Name of service template to use
host_name windows10-thinapp
service_description PING
check_command check_ping!100.0,20%!500.0,60%
notifications_enabled 1
contact_groups admins
}
The notification log shows that there is an error and the actions but i don't receive any emails, i have attached a screenshot of the notifications log
Postfix is working as i can email from there through my exchange server to the notification email address, but Nagios does not seem to be sending emails through Postfix.
Got any ideas if im going wrong somewhere
Re: Email Notifications
Posted: Wed Nov 07, 2018 11:45 am
by tgriep
Do you see any errors in the /var/log/maillog file when the emails are generated by Nagios?
Re: Email Notifications
Posted: Thu Nov 08, 2018 8:07 am
by workid
There are no errors in there for the notifications, there are no details at all of any attempts to send an email for notifications, only logs of successful emails sent from postfix where i have tested the relay through the exchange server.
Re: Email Notifications
Posted: Thu Nov 08, 2018 9:02 am
by workid
I have got it working.
I needed to make a change in the commands.cfg file
\bin\mail to \usr\bin\mailx
Thanks for your help with this, you can lock this now.