今天来介绍一下用NSClient++方式来监控Windows主机,此文默认你已经搭建好Nagios服务器,到http://sourceforge.net/projects/nscplus  下载最新的NSClient++,并且安装,安装的过程输入Nagios服务器的ip地址,密码不用谢,下面的选项全部勾上,除了倒数第二个,然后就不需要任何配置了,最新的软件是默认自动开启NSClient服务的,网上好多文章都要配置ns.ini文件和服务,最新软件完全没必要。

安装完成之后就要到nagios进行配置

vi /usr/local/nagios/etc/nagios.cfg
# Definitions for monitoring the local (Linux) host
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
# Definitions for monitoring a Windows machine
cfg_file=/usr/local/nagios/etc/objects/windows.cfg   #去掉这句话的注释

然后打开windows.cfg,只需要更改

define host{
        use             windows-server  ; Inherit default values from a template
        host_name       vm-test15       ; The name we're giving to this host
        alias           My Windows Server       ; A longer name associated with the host
        address         172.25.193.15   ; IP address of the host
        }

address 是你Windows 客户端的ip地址,然后更改host_name,可以在vim里使用命令

:%s/winserver/vm-test15/

然后重启Nagios就可以监控到Windows了。

如果是监控多台window server,就在nagios里复制windows.cfg 那行,然后在objects目录及建立相应的文件,并且更改host name和ip addr。