潇湘夜雨移动版

主页 > 系统 >

nagios监控部署(一)(9)

如果还希望在监控远程Linux主机时还能向其传递参数,则可以使用类似如下方式进行:
 
定义监控远程Linux主机disk资源的命令:
define command
{
command_name check_swap_nrpe
command_line $USER1$/check_nrpe –H "$HOSTADDRESS$" -c "check_swap" -a $ARG1$ $ARG2$
}
 
定义远程Linux主机的swap资源:
define service
{
use generic-service
host_name linuxserver1,linuxserver2
hostgroup_name linux-servers
service_description SWAP
check_command check_swap_nrpe!20!10
normal_check_interval 30
}
 
 
 
五、基于NSClinet++监控Windows主机
安装NSClient.-0.3.4-Win32.msi
1、基于check_nt
 
Windows端要启用的模块:
[modules]
CheckSystem.dll
CheckDisk.dll
FileLogger.dll
NSClientListener.dll
 
[settings]
 
password=123456
allowed_hosts=192.168.0.105/24 #允许192.168.0.0网段的主机访问
allowed_hosts=192.168.0.105/32 #只允许192.168.0.105访问
注意:这里允许的ip地址是安装nsclient的主机ip
[NSClient]
port=12489
修改配置后要重启服务:
在程序和服务中双击打开NSClinet++,点“登录”标签,在“允许服务与桌面交互”前打勾。
 
nsclient++ /stop
nsclient++ /start
 
 
 
在nagios端使用如下命令测试:
 
check_nt -H <client ip> -p <port> -v <command> ...
 
# check_nt -H 192.168.0.105 -p 12489 -v CPULOAD -w 80 -c 90 -l 5,80,90
 
注意:CRITICAL - Socket timeout after 10 seconds
可能是防火墙或其他安全软件阻止的原因。
 
 
 
# vim /usr/local/nagios/etc/objects/windows.cfg
 
 
define host 
use windows-server
host_name winserver
alias My Windows machine
address 172.16.100.66
}
 
define service{
use generic-service
host_name winserver
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}
 
define service {
use generic-service
host_name winserver
service_description Uptime
check_command check_nt!UPTIME
}
 
define service {
use generic-service
host_name winserver
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}
 
define service{
use generic-service
host_name winserver
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}
 
Password Protection
 
 
 
If you specified a password in the NSClient++ configuration file on the Windows machine, you'll need to modify the check_nt command definition to include the password. Open the commands.cfg file for editing. (责任编辑:liangzh)