5.3.2 Nagios 服务器监控主机端的配置
对监控主机的配置
与之前的nrpe的过程类似,在监控主机上做的就3件事情
1.安装监控windows的插件(已经默认安装了,check_nt)
2.定义命令
3.定义要监控的项目
第一种方法:如果只是定义一台windows主机,那么可以使用templates.cfg里面的windows配置板,此处我只定义一台windows主机,所以我使用模板
1.首先更改nagios.cfg配置文件,让其支持windows.cfg定义对象,找到41行,去掉前面#
2.查看nagios的命令配置定义对象,看是否有check_nt的定义,如果没有,自行加入(此处commands.cfg文件中已有定义,不用自己编写)
3.定义主机,编辑objects/windows.cfg文件,此文件中,只需更改29行的ip地址即可,改成被监控端windows的(由于此文件中已经写好要监控的东西,所以不用再另行编写,如果想定义此文件中没有的内容,可自动编写)
Vim /usr/local/nagios/etc/objects/windows.cfg
define host{
use windows-server,hosts-pnp ; Inherit default values from a template
host_name zangwinserver ; The name we're giving to this host
alias My Windows Server ; A longer name associated with the host
address 192.168.77.1; IP address of the host
process_perf_data 1
action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
define hostgroup{
hostgroup_name windows-servers ; The name of the hostgroup
alias Windows Servers ; Long name of the group
}
define service{
use generic-service
host_name zangwinserver
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}
define service{
use generic-service,services-pnp
host_name zangwinserver
service_description Uptime
check_command check_nt!UPTIME
}
define service{
use generic-service,services-pnp
host_name zangwinserver
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}
define service{
use generic-service,services-pnp
host_name zangwinserver
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}
define service{
use generic-service,services-pnp
host_name zangwinserver
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
define service{
use generic-service,services-pnp
host_name zangwinserver
service_description W3SVC
check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}
define service{
use generic-service,services-pnp
host_name zangwinserver
service_description Explorer
check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
}
4.最后检查配置是否正确,并重启nagios服务。