No Mail notifications on new nagios install.

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.
Locked
mbogucki
Posts: 3
Joined: Tue Jun 28, 2011 12:44 pm
Location: Chicago, Illinois

No Mail notifications on new nagios install.

Post by mbogucki »

Hi All,

I've recently installed nagios 3.2.3 on an ubuntu server. I've got it more-or-less running, where I'm monitoring 30+ servers; for various checks like mysql, cpu_stats, etc.

I've used the quick-install guide to get me going, and have checked various forums and such in order to get where I'm at.

However I am unable to get any email notifications from the present setup. I've installed and successfully tested mailx and msmtp. I can send emails out from the command line without any issues. Additionally I've made the necessary changes to commands.cfg file (( changing /bin/mail to /usr/bin/mailx. )) If I cut/n/paste one of those arguments I see the following email:

***** Nagios *****

Notification Type: $
Host: ip-10-117-73-218$
State: $
Address: $
Info: $

Date/Time: $

Obviously email is working.


I've intentionally disabled various services in order to get the nagios cgi to show various alerts, however from looking at /tmp/msmtp.log I cannot see any instances of messages being sent.

I've attached snippets of a few of the configuration files for examination.

commands.cfg

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/mailx -A gmail -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/mailx -A gmail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
        }
Contacts.cfg

Code: Select all


define contact{
        name                            generic-contact         ; The name of this contact template
        service_notification_period     24x7                    ; service notifications can be sent anytime
        host_notification_period        24x7                    ; host notifications can be sent anytime
        service_notification_options    w,c,r,f,u,s             ; send notifications for all service states, flapping events, and scheduled downtime events
        host_notification_options       r,f,u,s         ; send notifications for all host states, flapping events, and scheduled downtime events
        service_notification_commands   notify-service-by-email ; send service notifications via email
        host_notification_commands      notify-host-by-email    ; send host notifications via email
        register                        0                       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
        }

define contact{
        contact_name              nagiosadmin             ; Short name of user
        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Admin            ; Full name of user
        email                           alerts.zorotools@gmail.com      ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }

define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 nagiosadmin
        }
~
zorodev_webserver.cfg

Code: Select all

define host{
name linux-boxen3 
use generic-host 
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check_nrpe!check_host_alive_locally
notifications_enabled 1
notification_period 24x7
notification_interval 30
notification_options d,r,u,f
contact_groups admins
register 0
}

define contact{
name generic contact
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
service_notification_options w,c,r,f,u,s
host_notification_options r,f,u,s
register 0
}
 
define host{
use linux-boxen3
host_name ZoroDev_WebServer
alias ZoroDev_WebServer
address *.*.*.*  <--Intentionally obscured.
icon_image linux40.png 
statusmap_image linux40.gd2 
2d_coords 480,880
notifications_enabled 1
}

define service{
use generic-service
host_name ZoroDev_WebServer
service_description CPU Load
check_command check_nrpe!check_load 
notifications_enabled 1
}
 
define service{
use generic-service
host_name ZoroDev_WebServer
service_description Users
check_command check_nrpe!check_users
notifications_enabled 1
}
 
define service{
use generic-service
host_name ZoroDev_WebServer
service_description /dev/hda1 Free Space
check_command check_nrpe!check_hda1
notifications_enabled 1
}

define service{
use generic-service
host_name ZoroDev_WebServer
service_description Mysql Zoro DB Status
check_command check_nrpe!check_mysql_zoro
notifications_enabled 1
}

define service{
use generic-service
host_name ZoroDev_WebServer
service_description Check CPU Stats
check_command check_nrpe!check_cpu_stats
notifications_enabled 1
}

At this point I'd be happy with seeing an email if the host goes down. Rather discouraged...and needing help.

If there is anything else you need, let me know. Thank you in advanced.

--Mike
mbogucki
Posts: 3
Joined: Tue Jun 28, 2011 12:44 pm
Location: Chicago, Illinois

Re: No Mail notifications on new nagios install.

Post by mbogucki »

Wow... everyone must have been partying hard this weekend. ^_^
mbogucki
Posts: 3
Joined: Tue Jun 28, 2011 12:44 pm
Location: Chicago, Illinois

Re: No Mail notifications on new nagios install.

Post by mbogucki »

*bump*
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: No Mail notifications on new nagios install.

Post by mguthrie »

Hmm, it's behaving like it's passing the actual macro instead of the value. Do you have the same results when using /bin/mail?
catchacold
Posts: 1
Joined: Sun Oct 30, 2011 10:34 am

Re: No Mail notifications on new nagios install.

Post by catchacold »

Did you ever figure this out? I am having the exact same problem. I am able to send out command line. But, cant get the alerts to work to email from Nagios. Contacts and Contact Groups are set up right, service is set up right, mail is set up. Well, please let me know if you ever got it working been searching and reading for two days.

Thanks
Locked