Nagios wont send notification mails

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
jaxon
Posts: 9
Joined: Mon Sep 28, 2015 9:16 am

Nagios wont send notification mails

Post 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.
Last edited by jaxon on Tue Sep 29, 2015 1:14 am, edited 1 time in total.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Nagios wont send notification mails

Post by Box293 »

Do you have SELinux enabled?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
jaxon
Posts: 9
Joined: Mon Sep 28, 2015 9:16 am

Re: Nagios wont send notification mails

Post by jaxon »

I do not have SELinux enabled.
jaxon
Posts: 9
Joined: Mon Sep 28, 2015 9:16 am

Re: Nagios wont send notification mails

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Nagios wont send notification mails

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Nagios wont send notification mails

Post 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.
jaxon
Posts: 9
Joined: Mon Sep 28, 2015 9:16 am

Re: Nagios wont send notification mails

Post 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.
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Nagios wont send notification mails

Post 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.
jaxon
Posts: 9
Joined: Mon Sep 28, 2015 9:16 am

Re: Nagios wont send notification mails

Post 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.
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Nagios wont send notification mails

Post 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.
Locked