Page 1 of 2

Nagios wont send notification mails

Posted: Mon Sep 28, 2015 9:40 am
by jaxon
Hi,

I am using nagios3 with my ubuntu server.

I configured notification method by both sms and mail, but if there is any service or host problem occurs, mail method doesn't work. and at same time i am getting below log in my nagios.debug log files

Code: Select all

/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: RECOVERY\n\nService: Current Users\nHost: ast5\nAddress: 192.168.98.234\nState: OK\n\nDate/Time: Mon Sept 28 19:18:46 IST 2015\n\nAdditional Info:\n\nUSERS OK - 0 users currently logged in\n" | /usr/local/bin/mail -s "** RECOVERY Service Alert: srv5/Current Users is OK **" [email protected]
above command can send mail without any issues when i am running manually with su - nagios -s /bin/bash, Please help me to solve this issue.

Re: Nagios wont send notification mails

Posted: Mon Sep 28, 2015 2:40 pm
by Box293
Do you have SELinux enabled?

Re: Nagios wont send notification mails

Posted: Tue Sep 29, 2015 1:10 am
by jaxon
I do not have SELinux enabled.

Re: Nagios wont send notification mails

Posted: Tue Sep 29, 2015 7:42 am
by jaxon
Today I tried complete re-installation of nagios by using below How-to guide.
https://www.digitalocean.com/community/ ... untu-14-04

Still not getting notifications. is this something related to postfix then?. But i already checked that nagios user can send mail with mail, mailx, mutt commands without any issues.

Re: Nagios wont send notification mails

Posted: Tue Sep 29, 2015 2:07 pm
by scottwilkerson
Can you run the following to determine the location to you mail program

Code: Select all

which mail
Then, nake sure the path in the notification command matches the location in the which command provides. Then you will need to restart the nagios service

Re: Nagios wont send notification mails

Posted: Tue Sep 29, 2015 2:08 pm
by jdalrymple
9 times out of 10 when you can run the command OK from the command line but it doesn't work as Nagios it is selinux or perhaps apparmor in the case of Ubuntu.

The only other sensible reason would be if user nagios couldn't execute the mail command. You might also double and triple check the path to the mail binary. It's in a nonstandard location on Debian based distributions.

Re: Nagios wont send notification mails

Posted: Wed Sep 30, 2015 12:39 am
by jaxon

Code: Select all

nagios@fs:~$ which mail
/usr/bin/mail

Code: Select all

root@fs:~# /etc/init.d/apparmor status
apparmor module is loaded.
5 profiles are loaded.
5 profiles are in enforce mode.
   /sbin/dhclient
   /usr/lib/NetworkManager/nm-dhcp-client.action
   /usr/lib/connman/scripts/dhclient-script
   /usr/sbin/mysqld
   /usr/sbin/tcpdump
0 profiles are in complain mode.
1 processes have profiles defined.
1 processes are in enforce mode :
   /usr/sbin/mysqld (7911)
0 processes are in complain mode.
0 processes are unconfined but have a profile defined.
apparmor is not blocking mail command anywhere also path for mail command looks correct, I checked tailf /var/log/audit/audit.log for apparmor blockage in realtime with nagios notifications but still no luck, none of logs showing errors.

Re: Nagios wont send notification mails

Posted: Wed Sep 30, 2015 2:19 pm
by jdalrymple
jaxon wrote:nagios@fs:~$ which mail
/usr/bin/mail
jaxon wrote:/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: RECOVERY\n\nService: Current Users\nHost: ast5\nAddress: 192.168.98.234\nState: OK\n\nDate/Time: Mon Sept 28 19:18:46 IST 2015\n\nAdditional Info:\n\nUSERS OK - 0 users currently logged in\n" | /usr/local/bin/mail -s "** RECOVERY Service Alert: srv5/Current Users is OK **" [email protected]
You answered your own question.

Re: Nagios wont send notification mails

Posted: Wed Sep 30, 2015 10:59 pm
by jaxon
Sorry for my typo,

correct screenshot is below,

Code: Select all

/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: PROBLEM\n\nService: Total Processes\nHost: sast5\nAddress: 192.168.1.234\nState: CRITICAL\n\nDate/Time: Thu Oct 1 09:24:25 IST 2015\n\nAdditional Info:\n\nConnection refused by host\n" | /usr/bin/mail -s "** PROBLEM Service Alert: ast5/Total Processes is CRITICAL **" [email protected]
I was testing by changing actual path of mail command but that didn't worked, correct command is above.

Re: Nagios wont send notification mails

Posted: Thu Oct 01, 2015 9:47 am
by jdalrymple
Either way this is a system thing. We're here to help, but if the nagios.debug file indicates that it did `printf "somestuff" | /some/path/mail [email protected]` then that is indeed what it did. If you copy and paste that to the command line logged on as Nagios and it works then there is something "systemy" at play. Make sense?

If you don't believe me try replacing your mail command with `printf "somestuff" > /some/path/nagios/can/write/to/somefile`. Also, if you're thinking that maybe the mail command is running and the problem is actually beyond that, just tail your /var/log/maillog while sending your test notification.