2、 邮件报警的配置
一般而言,如果在整个系统中只有一个管理员,那么只需要在contact.cfg文件中,添加一下管理员的邮箱即可。但如果监控的内容中服务器有单独的管理员,那就需要定义多个contact(联系人),然后再通过contactgroup(联系组)对各个contact 进行分组。
(1) 修改contact.cfg
[root@server ~]# vim /usr/local/nagios/etc/objects/contacts.cfg
define contact{
contact_name nagios
use generic-contact
alias Nagios
email 159158*****@163.com,159158*****@139.com // 改为自己的邮箱地址即可
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagios
}
(2) 设置报警方式
[root@server ~]# vim /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, 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!
}