Nagios3 Won't Send Email Notifications

I’m sure this is a very common question, but searching the forum for “won’t send email” says the terms are too common, so please don’t flame me.

I’ve been working on migrating an old Nagios2 install to a new server. I have everything working except for it sending out notifications. The web interface works; it shows when I take a service down and also when it comes back up. I took the existing nagios2 config files and then massaged them to work with the Ubuntu install. Now if I could get it to send email alerts I’d be a happy camper. :slight_smile:

I’m monitoring a little over 100 services and here is an example from the config files (lightly sanitized):

define contact{
contact_name ken
alias ken
service_notification_period 24x7
host_notification_period 24x7
service_notification_options c,r
host_notification_options d,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email [email protected]
}
define contactgroup{
contactgroup_name byte
alias byte group
members ken,ken-pager,kenshome
}
define host{
use generic-host ; Name of host template to use
host_name ns3
alias Byte NS3
address 63.xx.yy.zz
parents router1
check_command check-host-alive
max_check_attempts 10
contact_groups byte
notification_interval 120
notification_period awakehours
notification_options d,u,r
}
define service{
use generic-service ; Name of service template to use
host_name ns3
service_description DNS
is_volatile 0
check_period 24x7
max_check_attempts 5
normal_check_interval 5
retry_check_interval 1
contact_groups byte
notification_interval 120
notification_period 24x7
notification_options c,r
check_command check_dns
}

I found a post where someone recommended changing the debug level (I set it to: debug_level=32 to get notifications) and it gives this for output:

[1305575960.082269] [032.0] [pid=1455] ** Service Notification Attempt ** Host: ‘ns3’, Service: ‘DNS’, Type: 0, Options: 0, Current State: 2, Last Notification: Mon May 16 13:59:18 2011
[1305575960.082338] [032.0] [pid=1455] Notification viability test passed.
[1305575960.082350] [032.1] [pid=1455] Current notification number: 37 (incremented)
[1305575960.082367] [032.1] [pid=1455] Service notification will NOT be escalated.
[1305575960.082384] [032.1] [pid=1455] Adding normal contacts for service to notification list.
[1305575960.178453] [032.0] [pid=1455] 6 contacts were notified. Next possible notification time: Mon May 16 17:59:20 2011
[1305575960.178496] [032.0] [pid=1455] 6 contacts were notified.

The odd thing is that even though it says “6 contacts were notified” there is no email that is sent. This box uses Postfix so looking at /var/log/mail.info shows that there hasn’t been an email sent out in 5 days and that email was a manual test by me via the command line (I got this test message).

The new server is a Ubuntu 10.10 install on to virtual private server. Nagios is installed via the apt package.

So, I guess I’m at a loss as to where to check next. I’d be grateful for any direction any one could provide.

Thanks!
-ken

root@nagios:/etc/nagios3# dpkg -l | grep -i nagios
ii nagios-images 0.7 Collection of images and icons for the nagios system
ii nagios-plugins 1.4.14-5ubuntu3 Plugins for the nagios network monitoring and management system
ii nagios-plugins-basic 1.4.14-5ubuntu3 Plugins for the nagios network monitoring and management system
ii nagios-plugins-standard 1.4.14-5ubuntu3 Plugins for the nagios network monitoring and management system
ii nagios3 3.2.1-2ubuntu1 A host/service/network monitoring and management system
ii nagios3-cgi 3.2.1-2ubuntu1 cgi files for nagios3
ii nagios3-common 3.2.1-2ubuntu1 support files for nagios3
ii nagios3-core 3.2.1-2ubuntu1 A host/service/network monitoring and management system core files
root@nagios:/etc/nagios3#

first things first: apt is bad. compile from source. (you can reuse the config files).

Check the command used to notify for service failures in commands.cfg, fill the variables and see what happens from command line as user nagios. You are probably trying to send mail with a wrong mail command

That’s exactly what I needed! I expanded out the ‘notify-by-email’ filling in the variables and found out that Ubuntu installs ‘mail’ in /usr/bin instead of /bin/mail where it was set in the config file. So I just created a symlink to it in /bin and all is well.

Thanks for the pointer!
-ken