nagios,难搞死。
看了几天有点头疼,看明白了也就那么回事。
下面说说我的心得(我的nagios是自己编译的,所有文件都在/usr/local/nagios/etc下面)
cgi.cfg:
所有有关web界面的配置都在这里,参见http://ihipop.info/2010/11/1785.html#cgi
resource.cfg:
不必修改,定义了一些库文件的位置
nagios.cfg:
主配置文件,由于他的引用,objects下配置文件才得以生效,例如:
# Definitions for monitoring a Windows machine
#cfg_file=/usr/local/nagios/etc/objects/windows.cfg
去掉第二行的#,objects下的windows.cfg才生效。
windows.cfg:
看注释:
###############################################################################
# WINDOWS.CFG - SAMPLE CONFIG FILE FOR MONITORING A WINDOWS MACHINE
#
# Last Modified: 06-13-2007
#
# NOTES: This config file assumes that you are using the sample configuration
# files that get installed with the Nagios quickstart guide.
#
##############################################################################################################################################################
###############################################################################
#
# 主机定义
#
###############################################################################
################################################################################ 定义将要检测的主机
# 修改 host_name, alias, and address 来完成配置define host{
use windows-server ; 从模板里面继承windows-server大类的默认值(可以在templates.cfg里面看到)
host_name BS_Server ; 定义主机名
alias backup-server ; 主机别名
address x.x.x.x; 主机地址
}###############################################################################
###############################################################################
#
# 主机组定义
#
###############################################################################
################################################################################定义windows主机组
# 所有使用 windows-server 模板的主机会自动成为该组成员define hostgroup{
hostgroup_name windows-servers ; 主机组名
alias Windows Servers ; 别名
}###############################################################################
###############################################################################
#
# 服务器细节定义
#
###############################################################################
################################################################################ 检测 NSCLient++ 版本
# 修改 host_name 保持和上面一致define service{
use generic-service ; 从模板里面继承generic-service大类的默认值,比如测试次数等。
host_name BS_Server
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}# 开机时间监测
# Change the host_name to match the name of the host you defined abovedefine service{
use generic-service
host_name BS_Server
service_description Uptime
check_command check_nt!UPTIME
}# 检测 CPU 负债
# Change the host_name to match the name of the host you defined abovedefine service{
use generic-service
host_name BS_Server
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90; 5分钟内负载平均达到80%为warning,负载达到90%为critical
}# 监测内存使用率
# Change the host_name to match the name of the host you defined abovedefine service{
use generic-service
host_name BS_Server
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90; #内存使用到达80%则warning,到达90%则Critical
}# 检测 C 盘空间变化
# Change the host_name to match the name of the host you defined abovedefine service{
use generic-service
host_name BS_Server
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}# 检测 D 盘空间变化
# Change the host_name to match the name of the host you defined abovedefine service{
use generic-service
host_name BS_Server
service_description D:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l d -w 80 -c 90
}# 检测 e 盘空间变化
# Change the host_name to match the name of the host you defined abovedefine service{
use generic-service
host_name BS_Server
service_description e:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l e -w 80 -c 90
}# 检测 W3SVC 服务
# Change the host_name to match the name of the host you defined abovedefine service{
use generic-service
host_name BS_Server
service_description W3SVC
check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}# 检测 Explorer.exe 进程状态
# Change the host_name to match the name of the host you defined abovedefine service{
use generic-service
host_name BS_Server
service_description Explorer
check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
}# 检测 Ping 服务状态
# Change the host_name to match the name of the host you defined abovedefine service{
use generic-service ; Name of service template to use
host_name BS_Server
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}# 检测登录用户状态
# 大于 2 用户,警告,大于3个用户, criticaldefine service{
use generic-service ; Name of service template to use
host_name BS_Server
service_description Current Users
check_command check_local_users!2!3
}# 检测Http 服务
# Disable notifications for this service by default, as not all users may have HTTP enabled.define service{
use generic-service ; Name of service template to use
host_name BS_Server
service_description HTTP
check_command check_http
;notifications_enabled 0
}
有密码怎么办?
check_nt这个命令是在commands.cfg里定义的,对于不同的,除了可以直接在这个地方用-s定义密码之外,为了实现不同主机使用不同密码,可以定义多个check_nt_xx命令,对应不同的主机,同时把密码写进去。