Problem with mail notifications
Problem with mail notifications
Running Nagios 4.0.8 on Debian 7. Mail notifications are not being sent. I can send test email from the command line. Checked commands.cfg to check the path to mail and it is correct. Where can I look to troubleshoot? I've done it many times before with no issue, but this one is puzzling. If you want to suggest a never fail mailer to install, I'm ok with that.
Re: Problem with mail notifications
What command are you using from the command line to send mail, and as what user? What command do you have defined in Nagios to send mail? Are you able to run the first command as nagios instead of as root?
Former Nagios employee
Re: Problem with mail notifications
As root or nagios:
I'm using the defaults in Nagios.
Code: Select all
root@nagios:~# mail to [email protected]
Cc:
Subject: test
root@nagios:~#
-
slansing
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: Problem with mail notifications
Can you share your nagios command which is responsible for sending notifications out? An let us know what guide (if any) you were following for this? The more info you can give us on how you set your mailer up, the better...
Re: Problem with mail notifications
Here are the notify commands - defaults. In troubleshooting I've also tried pointing to /bin/mail depending on the mailer.
I wrote my own guide about five years ago that I've been following (link). I've had to adapt it for Debian 7 and it seems the mail part doesn't work as I'm used to. In my troubleshooting I've tried postfix, exim4, and sendmail with bsd-mailx, heirloom-mailx. I don't care which one is used, I just need something to work. If there is a start-to finish guide I'm willing to try anything.
Code: Select all
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: Problem with mail notifications
Is the mail server you intend to send to, on an internal or external network to the nagios system? Just wondering if you need to bother with spam filtering or if this is going straight through.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Re: Problem with mail notifications
I switched back to sendmail and bsd-mailx. I find that it works to send to external recipients, but not internal. I think the problem is that I'm sending to [email protected], but the nagios host is nagios.domain.com so maybe it's trying to deliver locally. What do I need to tweak?
Re: Problem with mail notifications
Can you post a tail of the maillog after a failed send?
Code: Select all
tail -15 /var/log/maillogFormer Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Problem with mail notifications
I got it working.
I added the following to /etc/mail/sendmail.mc
EDIT: Locked, glad you have it working.
I added the following to /etc/mail/sendmail.mc
Code: Select all
define(`MAIL_HUB', `domain.com.')dnl
define(`LOCAL_RELAY', `domain.com.')dnl
EDIT: Locked, glad you have it working.