Page 1 of 1

No email notification

Posted: Wed Aug 08, 2012 11:13 am
by guna_pmk
Hi,

I have just installed and configured Nagios on a CentOS6 machine. It is nicely monitoring my other two CentOs servers through NRPE. But I could not get the alert emails sent.

I have enabled debug and I could see the actual email command in the /var/log/nagios/nagios.debug. If I copy that whole command, and execute it from the command line, it sends the email without any problem

/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: CUSTOM\n\nService: CPU\nHost: myhostname\nAddress: myhost.mydomain\nState: CRITICAL\n\nDate/Time: Wed Aug 8 16:45:45 BST 2012\n\nAdditional Info:\n\nConnection refused by host\n" | /usr/bin/nail -r "from@mydomain (Nagios)" -s "** CUSTOM Service Alert: myhost/CPU is CRITICAL **" -S "smtp=mysmtp" -S "smtp-auth=login" -S "smtp-auth-user=from@mydomain" nagiosadmin@mydomain

Can anybody throw some light on this?

Thanks

Re: No email notification

Posted: Wed Aug 08, 2012 11:16 am
by nscott
Are any errors showing up in /var/log/messages around the time the mail is supposed to be sent?

Re: No email notification

Posted: Wed Aug 08, 2012 11:32 am
by guna_pmk
No, I can't see any errors at all. I have verified the following files:

/var/log/messages
/var/log/nagios/nagios.log
/var/log/nagios/nagios.debug

Please let me know if you need anymore information in this regard.

Thanks

[Solved]Re: No email notification

Posted: Thu Aug 09, 2012 4:01 am
by guna_pmk
Hello,

I got this fixed now. The problem was, when I started nagios service, it did not have a $HOME (usual for a Linux service)., which in turn hid the .mailrc. I use mailrc for providing the password for the smtp server to send emails.

To solve the problem, I exported MAILRC as

Code: Select all

export MAILRC=NAGIOS_HOME/.mailrc
in the /etc/init.d/nagios service script.

What will be good is to have this captured in the nagios.deug. The nail utility actually complains if it can't find a password either in the parameters or in the mailrc. I think nagios does not capture the stdout and stderr of a command. It is good that it records all the actual commands it runs though.

Thanks for your immediate response.

Re: No email notification

Posted: Fri Aug 10, 2012 10:39 am
by agriffin
I'm glad you got things figured out, thanks for sharing the solution!