您的位置:首页 > 移动开发 > IOS开发

详解运维监控利器Nagios 系列(三)-配置Nagios监控系统 (3)

2013-02-06 09:39 771 查看

详解运维监控利器Nagios 系列(三)-配置Nagios监控系统 (3)

上接详解运维监控利器Nagios 系列(三)-配置Nagios监控系统 (2)

http://xmshuiyong.blog.51cto.com/1980172/1132416

(6) services.cfg文件

此文件默认也不存在,需要手动创建,services.cfg文件主要用于定义监控的服务和主机资源,例如监控http服务、ftp服务、主机磁盘空间、主机系统负载等等。
################# ixdba web #####################
define service{
use local-service #引用local-service服务的属性值,local-service在templates.cfg文件中进行了定义。
host_name web #指定要监控哪个主机上的服务,“web”在hosts.cfg文件中进行了定义。
service_description PING #对监控服务内容的描述,以供维护人员参考。
check_command check_ping!100.0,20%!500.0,60% #指定检查的命令,check_ping命令在commands.cfg中定义,后跟两个参数,命令与参数间用!分割。
}

define service{
use local-service
host_name web
service_description SSH
check_command check_ssh # check_ssh命令也在commands.cfg中定义。
}

define service{
use local-service
host_name web
service_description SSHD
check_command check_tcp!22
}

(7) contacts.cfg文件

contacts.cfg是一个定义联系人和联系人组的配置文件,当监控的主机或者服务出现故障,nagios会通过指定的通知方式(邮件或者短信)将信息发给这里指定的联系人或者使用者。

define contact{
contact_name sasystem #联系人名称
use generic-contact #引用generic-contact的属性信息,其中“generic-contact”在templates.cfg文件中进行定义
alias sa-system #联系人别名
email ixdba@126.com #联系人的邮件地址
}
define contactgroup {
contactgroup_name admins #联系人组名称
alias system administrator group #联系人组描述
members sasystem #联系人组成员,其中“sasystem”就是上面定义的联系人
}

(8) timeperiods.cfg文件

此文件只要用于定义监控的时间段,下面是一个配置好的实例:
#下面是定义一个名为24x7的时间段,即监控所有时间段
define timeperiod{
timeperiod_name 24x7
alias 24 Hours A Day, 7 Days 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
}
#下面是定义一个名为workhours的时间段,即工作时间段。
define timeperiod{
timeperiod_name workhours
alias Normal Work Hours
monday 09:00-17:00
tuesday 09:00-17:00
wednesday 09:00-17:00
thursday 09:00-17:00
friday 09:00-17:00
}

(9) cgi.cfg文件

此文件用来控制相关cgi脚本,如果想在nagios的web监控界面执行cgi脚本,例如重启nagios进程、关闭nagios通知、停止nagios主机检测等,这时就需要配置cgi.cfg文件了。
由于nagios的web监控界面验证用户为ixdba,所以只需在cgi.cfg文件中添加此用户的执行权限就可以了,需要修改的配置信息如下:
default_user_name=ixdba
authorized_for_system_information=nagiosadmin,ixdba
authorized_for_configuration_information=nagiosadmin,ixdba
authorized_for_system_commands=ixdba
authorized_for_all_services=nagiosadmin,ixdba
authorized_for_all_hosts=nagiosadmin,ixdba
authorized_for_all_service_commands=nagiosadmin,ixdba
authorized_for_all_host_commands=nagiosadmin,ixdba

(10) nagios.cfg文件

Nagios.cfg默认的路径为/usr/local/nagios/etc/nagios.cfg,是nagios的核心配置文件,所有的对象配置文件都必须在这个文件中进行定义才能发挥其作用,这里只需将对象配置文件在Nagios.cfg文件中进行引用即可。
log_file=/usr/local/nagios/var/nagios.log
“log_file”变量用来定义nagios日志文件的路径。
cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg
cfg_file=/usr/local/nagios/etc/commands.cfg
cfg_file=/usr/local/nagios/etc/contacts.cfg
cfg_file=/usr/local/nagios/etc/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/templates.cfg
“cfg_file”变量用来引用对象配置文件,如果有更多的对象配置文件,在这里依次添加即可。
object_cache_file=/usr/local/nagios/var/objects.cache
该变量用于指定一个“所有对象配置文件”的副本文件,或者叫对象缓冲文件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息