- 论坛徽章:
- 0
|
6)配置各种配置文件
定义监控时间段,创建配置文件timeperiods.cfg :
# vi timeperiods.cfg
define timeperiod{
timeperiod_name 24x7 //时间段的名称,这个地方不要有空格
alias 24 Hours A Day,7Days A Week
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}
定义了一个监控时间段,它的名称是24x7,监控的时间是每天全天24小时:
定义联系人,创建配置文件contacts.cfg
# vi contacts.cfg
define contact{
contact_name test //联系人的名称,这个地方不要有空格
alias sys admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email tfhudong@sohu.com
pager 1391119xxxx
}
创建了一个名为test的联系人,下面列出其中重要的几个选项做说明:
service_notification_period 24x7
服务出了状况通知的时间段,这个时间段就是上面在timeperiods.cfg中定义的.
host_notification_period 24x7
主机出了状况通知的时间段, 这个时间段就是上面在timeperiods.cfg中定义的
service_notification_options w,u,c,r
当服务出现w—报警(warning),u—未知(unkown),c—严重(critical),或者r—从异常情况恢复正常,在这四种情况下通知联系人.
host_notification_options d,u,r
当主机出现d —当机(down),u—返回不可达(unreachable),r—从异常情况恢复正常,在这3种情况下通知联系人
service_notification_commands notify-by-email
服务出问题通知采用的命令notify-by-email,这个命令是在commands.cfg中定义的,作用是给联系人发邮件.
host_notification_commands host-notify-by-email
同上,主机出问题时采用的也是发邮件的方式通知联系人
email yahoon@test.com
很明显,联系的人email地址
Pager 137xxxxxxxxxxxxxx //电话
}
下面就可以将多个联系人组成一个联系人组,创建文件contactgroups.cfg :
# vi contactgroups.cfg
define contactgroup{
contactgroup_name sagroup //联系人组的名称,同样不能空格
alias System Administrators //别名
members test
//组的成员,来自于上面定义的contacts.cfg,如果有多个联系人则以逗号相隔
}
定义被监控主机,创建文件hosts.cfg :
# vi hosts.cfg
define host{
host_name nagios //被监控主机的名称,最好别带空格
alias nagios //别名
address 192.168.1.240 //被监控主机的IP地址
check_command check-host-alive
//监控的命令check-host-alive,这个命令来自commands.cfg,用来监控主机是否存活
max_check_attempts 5 //检查失败后重试的次数
check_period 24x7
//检查的时间段24x7,同样来自于我们之前在timeperiods.cfg中定义的
contact_groups sagroup
//联系人组,上面在contactgroups.cfg中定义的sagroup
notification_interval 10
//提醒的间隔,每隔10秒提醒一次
notification_period 24x7
//提醒的周期, 24x7,同样来自于我们之前在timeperiods.cfg中定义的
notification_options d,u,r
//指定什么情况下提醒
}
|
|