Page 1 of 2

Nagios XI not mailing

Posted: Thu Jun 24, 2021 6:34 am
by connected
I've recently upgraded from Nagios XI 5.x to 5.8 and in this process had to migrate from Centos 6 to 7.
Thus got the new Centos 7 VMware image from the Nagios website and restored a backup.

Everything seems to working fine and I can also send a test mail from the Nagios GUI, but when an host goes down there is no message send (or at least not received ;) )

Where do I begin to troubleshoot this?

Re: Nagios XI not mailing

Posted: Thu Jun 24, 2021 3:59 pm
by gsmith
Hi

Do you have a service or host you can play with to force a notification to be sent?

For example sometimes I set up a service for "number of users", then set the warning and critical settings at 1 and 2.
Then I log in to that server via ssh in 3 different sessions to force a critical alert. Make sure you set up the notification
for this alert to email you.

When you do that and see the alert, get the /var/log/maillog file and send it to me.

Also grab a System Profile for me:

To send us your system profile.
1. Login to the Nagios XI GUI using a web browser.
2. Click the "Admin" > "System Profile" Menu
3. Click the "Download Profile" button
4. Save the profile.zip file and share this in a private message and then reply to this post to bring it up in the queue.

Thanks

Re: Nagios XI not mailing

Posted: Mon Jun 28, 2021 4:38 am
by connected
Added the files as PM.

The /var/spool/root log files is mailing as [email protected] to [email protected].
This is wrong I suppose, but not sure how to fix this. The hostname is set via nmtui.

The testmail button works fine. Perhaps there is an additional config file that is missing some data?

Re: Nagios XI not mailing

Posted: Mon Jun 28, 2021 2:08 pm
by ssax
Your old system likely had a relayhost added to /etc/postfix/main.cf to relay properly for contacts that use notify-host-by-email and notify-service-by-email commands.

Does your SMTP server require authentication (username and password)?

if so, you can follow this:

https://devops.ionos.com/tutorials/conf ... -centos-7/

If not, you can add it to /etc/postfix/main.cf:
- Change your.mail.server and the port if necessary

Code: Select all

relayhost = [your.mail.server]:25
Then restart postfix:

Code: Select all

systemctl restart postfix
See if that resolves it.

Re: Nagios XI not mailing

Posted: Tue Jun 29, 2021 2:19 am
by connected
The postfix main.cf file has it's default values.
We are just using sendmail. No SMTP.

Re: Nagios XI not mailing

Posted: Tue Jun 29, 2021 3:40 pm
by ssax
What is the output of this command?

Code: Select all

alternatives --display mta

Re: Nagios XI not mailing

Posted: Wed Jun 30, 2021 2:34 am
by connected
[root@nagios ~]# alternatives --display mta
mta - status is auto.
link currently points to /usr/sbin/sendmail.postfix
/usr/sbin/sendmail.postfix - priority 30
slave mta-pam: /etc/pam.d/smtp.postfix
slave mta-mailq: /usr/bin/mailq.postfix
slave mta-newaliases: /usr/bin/newaliases.postfix
slave mta-rmail: /usr/bin/rmail.postfix
slave mta-sendmail: /usr/lib/sendmail.postfix
slave mta-mailqman: /usr/share/man/man1/mailq.postfix.1.gz
slave mta-newaliasesman: /usr/share/man/man1/newaliases.postfix.1.gz
slave mta-aliasesman: /usr/share/man/man5/aliases.postfix.5.gz
slave mta-sendmailman: /usr/share/man/man1/sendmail.postfix.1.gz
Current `best' version is /usr/sbin/sendmail.postfix.

Re: Nagios XI not mailing

Posted: Wed Jun 30, 2021 3:48 pm
by ssax

Code: Select all

link currently points to /usr/sbin/sendmail.postfix
The Admin > Email Settings > Sendmail setting will use the backend MTA which your system is showing as postfix.

If you have an SMTP server to relay through you can set it up by following this guide:

https://devops.ionos.com/tutorials/conf ... -centos-7/

Then it will work.

Do you still have access to the old system? If so, what does this show on it?

Code: Select all

alternatives --display mta
EDIT: If you do not have an SMTP relay there is a high probability that the mail servers will reject them, check /var/log/maillog to see the activity.

Re: Nagios XI not mailing

Posted: Fri Jul 02, 2021 7:02 am
by connected
The old system is still accessible indeed.
The output looks quite similar.

[root@VCAMSSV24 ~]# alternatives --display mta
mta - status is auto.
link currently points to /usr/sbin/sendmail.postfix
/usr/sbin/sendmail.postfix - priority 30
slave mta-pam: /etc/pam.d/smtp.postfix
slave mta-mailq: /usr/bin/mailq.postfix
slave mta-newaliases: /usr/bin/newaliases.postfix
slave mta-rmail: /usr/bin/rmail.postfix
slave mta-sendmail: /usr/lib/sendmail.postfix
slave mta-mailqman: /usr/share/man/man1/mailq.postfix.1.gz
slave mta-newaliasesman: /usr/share/man/man1/newaliases.postfix.1.gz
slave mta-aliasesman: /usr/share/man/man5/aliases.postfix.5.gz
slave mta-sendmailman: /usr/share/man/man1/sendmail.postfix.1.gz
Current `best' version is /usr/sbin/sendmail.postfix.

Configuring Sendmail and SMTP on the GUI both works when pressing the 'Send a Test Email' button. Our spamfilters and SPF records are set up propery and allow for this to be properly received.
Except when an alert is triggered.

/etc/postfix/main.cf on the old system is also pretty default.

Re: Nagios XI not mailing

Posted: Fri Jul 02, 2021 3:29 pm
by ssax
The send a test email button will use PHPMailer, the contacts using notify-host-by-email and notify-service-by-email will not and requires the backend MTA be setup.

Please do a diff of this file from both servers, they are both setup to use postfix on the backend:

Code: Select all

/etc/postfix/main.cf
Does Admin > Email Settings have Sendmail selected on the old one as well?