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
No email notification
Re: No email notification
Are any errors showing up in /var/log/messages around the time the mail is supposed to be sent?
Nicholas Scott
Former Nagios employee
Former Nagios employee
Re: No email notification
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
/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
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
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.
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/.mailrcWhat 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
I'm glad you got things figured out, thanks for sharing the solution!