- 在被监控的Windows server 主机上安装NSClinet++
下载地址:https://www.nsclient.org/download/
32bit:http://files.nsclient.org/released/NSCP-0.4.3.143-Win32.msi
64bit:http://files.nsclient.org/released/NSCP-0.4.3.143-x64.msi
安装过程中会提示填写监控端的IP地址和密码,以及勾选所有的Modules,如下图所示:
按win + R 键,输入:services.msc, 若NSClient++服务已启动则运行正常。
默认安装目录为:C:\Program Files\NSClient++, nsclient.ini为NSClient的配置文件,当监控服务器IP改变时,需要修改此文件
注意,防火墙需要开通TCP的12489端口,否则Nagios检查此服务会提示错误 - 修改监控端服务器
检查windows server 监控能否正常工作
cd /usr/lib64/nagios/plugins
./check_nt -H 10.10.0.124 -p 12489 -s Hello2014 -v USEDDISKSPACE -w 80 -c 90 -l C
./check_nt -H 10.10.0.124 -p 12489 -s Hello2014 -v UPTIME
./check_nt -H 10.10.0.124 -p 12489 -s Hello2014 -v MEMUSE
./check_nt -H 10.10.0.142 -p 12489 -s Hello2014 -v USEDDISKSPACE -l c -w 80 -c 90
定义windows执行命令
vi /etc/nagios/objects/commands.cfg# vi commands.cfg define command{ command_name check_win command_line $USER1$/check_nt -H "$HOSTADDRESS$" -p 12489 -s 123456 -v $ARG1$ $ARG2$ } # $..$表示系统内置的宏,也就是所谓的变量 # $USER1$表示插件所在的目录 # -H 指定主机地址 # $HOSTADDRESS$ 应用到哪个主机,就用哪个主机的地址 # $ARG1$传递的参数,形参 # -s指定密码,如果有需要加,如上面安装时设置了密码为123456
定义主机
define host{ use generic-host host_name windows-server alias win server address 10.10.0.124 }
定义服务
define service{ use generic-service host_name windows_server service_description NSClient++ Version check_command check_win!CLIENTVERSION } define service{ use generic-service host_name windows_server service_description Uptime check_command check_win!UPTIME } define service{ use generic-service host_name windows_server service_description CPU Load check_command check_win!CPULOAD! -l 20,30,50 } define service{ use generic-service host_name windows_server service_description Memory Usage check_command check_win!MEMUSE! -w 80 -c 90 } define service{ use generic-service host_name windows_server service_description C: Drive Space check_command check_win!USEDDISKSPACE -l c -w 80 -c 90 } define service{ use generic-service host_name windows_server service_description D: Drive Space check_command check_win!USEDDISKSPACE -l d -w 80 -c 90 } define service{ use generic-service host_name windows_server service_description TCP check_command check_tcp!80 }
检查配置是否正常,重启nagios
参考文档:http://skypegnu1.blog.51cto.com/8991766/1533590
来源:https://www.cnblogs.com/Mrhuangrui/p/4588918.html