nagios应用1- 监控windows服务器

1、监控windows服务器

nagios监控windows系统主机有三种实现方式:SNMP,NSClient++,NRPE,后面两种方式都须要在windows上安装agent。html


1. 安装NSClient++ (版本:NSClient++-0.3.9-x64)

 

使用ZIP包,解压后进入解压后的目录,修改nsc.ini:ios

把除“CheckWMI.dll”和“RemoteConfiguration.dll”的外全部模块的注释去掉;
[Settings]
        password=password               #链接密码
	allowed_hosts=192.168.8.211	#nagios服务器IP
	shared_session=1		#启用NSClient++ Systary
		
[NSClient]
	port=12489			#NSClient++端口
		
[NRPE]
	port=5666			#NRPE端口

[NSCA Agent]
	interval=10                     #每10秒发送一次信息
	encryption_method=1             #数据传输加密方式
	password=password               #链接密码
	nsca_host=192.168.8.211         #nagios服务器IP
	nsca_port=5667                  #nagios服务器接受端口


从DOS窗口中进入NSClient++所在目录:windows

NSClient++  /install   #把NSClient++注册为服务,默认的服务名为NSClientpp服务器

NSClient++  /start          #启动NSClient++session

Netstat –an                        #查看12489端口是否打开this

 

在Nagios服务器中验证NSClient++运行正常:加密

# cd /usr/local/nagios/libexec/        #进入nagios服务器spa

        #./check_nt -H 192.168.8.80 -p 12489 -s password -v CPULOAD -l 5,80,90      #检查CPULOAD命令rest

出现CPU Load19% (5 min average) |   '5 min avgLoad'=19%;80;90;0;100表示NSClient++运行正常,能够获取CPU负载信息。code

 

 配置nagios监控文件

#vi /usr/local/nagios/etc/objects/192.168.8.80-NSClient.cfg

###########################################################################

         definehost{

                  use windows-server         ; Inherit default values from atemplate

                  host_name 192.168.8.80-NSClient ; The name we're giving to this host

               alias My Windows Server         ; A longer name associated with the host

                  address    192.168.8.80   ; IP address of the host

         }

 

         definehostgroup{

                  hostgroup_name     windows-servers     ; Thename of the hostgroup

                  alias Windows Servers     ; Long name of the group

                  }

 

         defineservice{

                  use                     generic-service

                  host_name                192.168.8.80-NSClient

                  service_description CPU Load

                  check_command               check_nt!CPULOAD!-l 5,80,90

                  }

###########################################################################

 

#vi /usr/local/nagios/etc/nagios.cfg                 编辑nagiso配置文件

加入cfg_file=/usr/local/nagios/etc/objects/192.168.8.80-NSClient.cfg

 

#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg    检查nagios配置没有问题

#service nagios restart                       没有错误重启nagios服务



2. 安装NRPE

配置nagios监控文件

#vi /usr/local/nagios/etc/objects/192.168.8.80-NRPE.cfg

###########################################################################

        definehost{

              use   windows-server      

              host_name    192.168.8.80-NRPE   

              alias         192.168.8.80NRPE   

              address       192.168.8.80 

       }

 

       define service{

               use                           generic-service

               host_name                    192.168.8.80-NRPE

               service_description       CPU Load

               check_command               nrpe!alias_cpu

         }

###########################################################################

 

#vi /usr/local/nagios/etc/nagios.cfg                 编辑nagiso配置文件

加入cfg_file=/usr/local/nagios/etc/objects/192.168.8.80-NRPE.cfg

 

#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg    检查nagios配置没有问题

#service nagios restart                       没有错误重启nagios服务