aloknet21
asked on
How to set email notification in Nagios?
I have setup Nagios on Centos 5. Added all my Linux Server and windows Server. Everything seems to be fine except Email Notification.
Please suggest me how to set Email Notification?
Already i have a Mail Server running on another system that is based on RHEL 5.
Please suggest me how to set Email Notification?
Already i have a Mail Server running on another system that is based on RHEL 5.
In yours commands.cfg what is your send notification command ?
I have installed ssmtp: it's a simple tool to configure your smtp account and so be able to send mail from linux command line with /usr/bin/mail command
http://www.linux.com/archi ve/feature /132006
my config:
cat /etc/ssmtp/ssmtp.conf
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=<smtpserver-ip-add ress>:25
AuthUser=<mailaccount>
AuthPass=<mailaccountpassw ord>
STARTSSL=YES
rewriteDomain=<yourdomain>
# The full hostname
hostname=<hostnameofnagios server>
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
Then configure mail command in command.cfg
# '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\nDate/Tim e: $LONGDATETIME$\n" | /usr/bin/mail -s "NAGIOS $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\nServ ice: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nAddition al Info:\n$SERVICEOUTPUT$\n\n Long Additional Info:\n$LONGSERVICEOUTPUT$ \n\nDate/T ime: $LONGDATETIME$\n\nDate/Tim e: $LONGDATETIME$" | /usr/bin/mail -s "NAGIOS $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
# }
http://www.linux.com/archi
my config:
cat /etc/ssmtp/ssmtp.conf
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=<smtpserver-ip-add
AuthUser=<mailaccount>
AuthPass=<mailaccountpassw
STARTSSL=YES
rewriteDomain=<yourdomain>
# The full hostname
hostname=<hostnameofnagios
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
Then configure mail command in command.cfg
# '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:
# }
# '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\nServ
# }
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
kosarajudeepak comment is exactly how i did it as well. quite simple :)
ASKER
thanks kosarajudeepak. it is working now.
Now i need to monitor My Firewall and Switches also. please suggest the steps for this.
Now i need to monitor My Firewall and Switches also. please suggest the steps for this.
in /etc/nagios3/commands.cfg
be sure you have defined
ts.cfg
c-host_nag ios2.cfg
in /etc/nagios3/conf.d/generi c-host_nag ios2.cfg
I'm using postfix with relayhost=[xxx.xxx.xxx.xxx ] option, pointed directly to my server. This solution have outgoing queue, so you not loose your notification if connection hang or you can setup mail routing for multiple destiantions.
be sure you have defined
define command{
command_name notify-host-by-email
......
}
define command{
command_name notify-service-by-email
.....
}
in /etc/nagios3/conf.d/contacdefine contactgroup{
contactgroup_name admins
alias Nagios Administrators
members it
}
define contact{
contact_name it
alias it
service_notification_period 24x7
host_notification_period hostmonitoringhours
host_notification_options d
service_notification_options n
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email user@domain
host_notifications_enabled 1
service_notifications_enabled 1
}
in /etc/nagios3/conf.d/generidefine host{
name generic-host ; The name of this host template
notifications_enabled 0 ; Host notifications are enabled
in /etc/nagios3/conf.d/generi
define service{
name generic-service ; The 'name' of this service template
notifications_enabled 1 ; Service notifications are enabled
I'm using postfix with relayhost=[xxx.xxx.xxx.xxx