当前位置: > Linux服务器 > 监控工具 >

nagios的常用监控策略

时间:2014-10-26 01:01来源:linux.it.net.cn 作者:it

一、定义主机模板
 

复制代码代码如下:
define host {
#模板名称
name etnet
#该模板的父模板
use generic-host
#最大尝试次数
max_check_attempts 3
#正常检测的时间间隔
normal_check_interval 3
#当检测到监控对象不在线时,尝试检测的次数
retry_check_interval 1
#监测的时间段7X24
check_period 24x7
#报警的时间段
notification_period 24x7
#报警的时间间隔,如果是短信报警的换,意思就是说多长时间用短信通知系统管理员一次
notification_interval 60
#当监控对象出现什么样的状态时发短信通知您
notification_options d,r,u,f
#监测命令 check_command check-host-alive
#联系人 contact_groups admins register 0
}

注: Notification_options d ,r,u,f
d 代表当监控对象出现down 是发送通知
r 当监控对象recoveries 时发送通知
f 当主机启动或者停机时发送通知
u 当有unreachable 状态时发送通知

复制代码代码如下:

#定义主机组
 define hostgroup{
hostgroup_name mysql alias mysql-group
#该组的成员 members linux141,linux134
}

define host {
#继承etnet模板
use etnet
host_name linux141
alias mysql41
address 192.168.3.141
}

二、定义service 模板
###define service###
 

复制代码代码如下:
define service {
# 定义service的名称
name tomcat
use generic-service
max_check_attempts 2
normal_check_interval 1
retry_check_interval 1
check_period 24x7
notification_period 24x7
notification_interval 60
notification_options w,u,c,f
contact_groups admins
register 0
}

注: notification_options w,u,c,f
C 代表critival 状态时发送通知,同主机模板中代表的含义是相同的
例如:
 

复制代码代码如下:
define hostgroup{
hostgroup_name Memcached
alias Memcache
members Memcache137
}
define host {
use etnet
host_name Memcache137
alias linux137
address 192.168.3.137
}
define service{
use tomcat
host_name Memcache137
service_description CPU Load
check_command check_nrpe!check_load
}

注:一般情况先定义监控service 时,是离不开定义host的 。

 
(责任编辑:IT)
------分隔线----------------------------