Nagios was built for his alarm system, and Nagios, as far as I know, there are three types of alarms:
first, sound alarm
Second, e-mail alarm
third, mobile phone SMS alarm
Here is the configuration process for my mail alert:
1. Open the system with SendMail mail system
Service SendMail Start
if not installed, you can yum
Yum install-y sendmail*
Service SendMail Restart
Test Send message:
echo "Test" | Mail[email protected]
my system is normal on the premise of shutting down Iptables and SELinux.
2, configure the mailbox in Nagios alarm
vi/usr/local/nagios/etc/objects/contacts.cfg
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[email protected]; <<***** change this to YOUR EMAIL ADDRESS ******
}
add your own email address, if there are multiple can be separated by commas
3, set the alarm mode:
vi/usr/local/nagios/etc/objects/templates.cfg
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, a nd 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 no a REAL contact, JUST a template!
}
these two notify-service-by-email and notify-host-by-email are defined in command.cfg, and see how they are defined:
# ' notify-host-by-email ' command definition
define command{
command_name Notify-host-by-email
command_line/usr/bin/printf "%b" "* * * * * * * * * Nagios * * * * * Notification Type: $NOTIFICATIONTYPE $ Host: $HOSTNAME $ Stat E: $HOSTSTATE $ Address: $HOSTADDRESS $ Info: $HOSTOUTPUT $ date/time: $LONGDATETIME $ "| /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 * * * * * Notification Type: $NOTIFICATIONTYPE $ Service: $SERVICEDESC $ Host: $HOSTALIAS $ Address: $HOSTADDRESS $ state: $SERVICESTATE $ date/time: $LONGDATETIME $ Additional Info: $SERVICEOUTPU t$ "| /bin/mail-s "* * $NOTIFICATIONTYPE $ Service Alert: $HOSTALIAS $/$SERVICEDESC $ is $SERVICESTATE $ * *" $CONTACTEMAIL $
}
This is already configured by default, so we don't have to modify the direct call.
Last restart Service:
Service Nagios Retart
then turn off some of the services to test the effect!
This article is from the "12336621" blog, please be sure to keep this source http://12346621.blog.51cto.com/12336621/1905421
Nagios Mail Alert configuration