Nagios core3.2 读取内存数据不对
今天老板问我,为啥米nagios上面显示windows的内存和实际内存不符合,经过仔细研究,发现之前的配置文件有一个bug,check_nt对于64位的windows显示的内存其实是windows的实际内存加page file之和。
这个是原先配置的服务
define service{
use generic-service
hostgroup_name AU-WIN-HOSTS
service_description MemoryUsage
check_command check_nt!MEMUSE!-w 90 -c 95
servicegroups AU-WIN-SERVICES
}
他显示的值为 Physical Memory + Page file
如何更正了,很简单,首先在command.cfg中增加一个新的命令定义
# CheckWindowsPhysical Mem command definition
define command {
command_name CheckWindowsPhysicalMem
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckMEM -a MaxWarn=$ARG1$% MaxCrit=$ARG2$% ShowAll type=physical
}
$USER1$/check_nrpe 会查询定义在resources.cfg里的路径,指向Nrpe plugin的安装路径 /usr/local/nagios/libexec/
-H 指向远处服务器 -p 定义端口 -c 后面是远程服务器在nsclient.ini中定义的命令(指向内置或者外部的脚本),$ARG1%和$ARG2$是定义services需要手动输入的参数,当然也可以直接在这里给个固定值,type可以指向虚拟内存,页面文件或者是物理内存
然后在对应的windows.cfg中添加一个检测物理内存的服务
define service{
use generic-service
service_description Physical Memory
check_command CheckWindowsPhysicalMem!94!98
hostgroup_name AU-WIN-HOSTS
servicegroups AU-WIN-SERVICES
}
检测语法错误
sudo nagios3 -v /etc/nagios3/nagios.cfg
重启
sudo /etc/init.d/nagios3 restart
对于客户端,如果有安装例如TMG之类的防火墙,还需要给nrpe服务打开5666端口;