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$
}
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
}
~
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
}
If there is anything else you need, let me know. Thank you in advanced.
--Mike