Email notification from Nagios
Posted: Mon May 19, 2014 8:49 am
hi,
I am trying to enable email notification for Nagios. I am running Nagios core 4.0.6 on CentOS6.5.
Below are the configurations of the files I have changed to setup notification but I still didn't get any email. Do I have to do something Special on CentOS as well? for example postfix?
IN Commands.cfg
IN Contacts.cfg
In Template.cfg
I am trying to enable email notification for Nagios. I am running Nagios core 4.0.6 on CentOS6.5.
Below are the configurations of the files I have changed to setup notification but I still didn't get any email. Do I have to do something Special on CentOS as well? for example postfix?
Code: Select all
[nagios@xyz objects]$ which mail
/bin/mailCode: 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" | /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" |/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}Code: Select all
define contact{
contact_name nagiosadmin
use generic-contact
alias Nagios Admin
email [email protected]
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}
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,u,c,r,f,s ; send notifications for all service states, flapping events, and scheduled downtime events
host_notification_options d,u,r,f,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!
}