Nagios系统监控软件的安装设置(3)

五、被监控机(windows)系统的安装配置

NSClientnrpe最大的区别就是:

--被监控机上安装有nrpe,并且还有插件,最终的监控是由这些插件来进行的.当监控主机将监控请求发给nrpe,nrpe调用插件来完成监控.

--NSClient则不同,被监控机上只安装NSClient,没有任何的插件.当监控主机将监控请求发给NSClient,NSClient直接完成监控,所有的监控是由NSClient完成的.

 

1、在被监控机上面安装NSClient压缩包(下载地址http://sourceforge.net/projects/nscplus/files/nscplus/

1解压缩安装包“NSClient++-0.3.8-Win32.zip”到D:\NSClient

2)打开“开始”----“运行”命令行,输入cmd ,然后进入D:\NSClient 目录

3)执行D:\nsclient > nsclient++ /install进行安装

4)安装完成以后打开“管理工具”下面的“服务”,查看有无“NSClientpp (Nagios)”的服务

 

2、修改被控机上的NSClient配置文件nsc.ini

用记事本打开D:\NSClient下面的nsc.ini文件,根据下面要求修改配置:

  
  
  
  
  1. ;# NSCLIENT++ MODULES  
  2. ;# A list with DLLs to load at startup.  
  3. ;  You will need to enable some of these for NSClient++ to work.  
  4. ; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !  
  5. ; *                                                               *  
  6. ; * N O T I C E ! ! ! - Y O U   H A V E   T O   E D I T   T H I S *  
  7. ; *                                                               *  
  8. ; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !  
  9. ;FileLogger.dll  
  10. ;CheckSystem.dll  
  11. ;CheckDisk.dll  
  12. ;NSClientListener.dll  
  13. ;NRPEListener.dll  
  14. ;SysTray.dll  
  15. ;CheckEventLog.dll  
  16. ;CheckHelpers.dll  
  17. ;CheckWMI.dll    (这边前面的分号不去掉)  
  18. ;  
  19. ; Script to check external scripts and/or internal aliases.  
  20. ;CheckExternalScripts.dll  
  21. ;  
  22. ; NSCA Agent if you enable this NSClient++ will talk to NSCA hosts repeatedly (so dont enable unless you want to use NSCA)  
  23. ;NSCAAgent.dll  
  24. ;  
  25. ; LUA script module used to write your own "check deamon".  
  26. ;LUAScript.dll  
  27. ;  
  28. ; RemoteConfiguration IS AN EXTREM EARLY IDEA SO DONT USE FOR PRODUCTION ENVIROMNEMTS!  
  29. ;RemoteConfiguration.dll  (这边前面的分号不去掉)  
  30. ; Check other hosts through NRPE extreme beta and probably a bit dangerous! :)  
  31. ;NRPEClient.dll  
  32. ; Extreamly early beta of a task-schedule checker  
  33. ;CheckTaskSched.dll  
  34.  
  35. [Settings]  
  36. ;# PASSWORD  
  37. ;password=secret-password  (连接的密码设置,如果不用密码,这边的分号可不去掉)  
  38. allowed_hosts=127.0.0.1/32,192.168.0.100(前面的分号去掉,然后加上主控机的IP地址)  
  39.  (如果是内网192要监控公网的机器,在这边首先要查出主监控机网段出去的公网IP,可通过http://www.ip138.com查询到监控机网段出去的公网IP地址,写入到allowed_hosts中)  
  40.  
  41. [NSClient]  
  42.    ;# NSCLIENT PORT NUMBER  
  43. ;  This is the port the NSClientListener.dll will listen to.  
  44. port=12489 (前面的分号去掉,打开服务的12489端口,不然主控机没法访问过来) 

3、启动客户端服务并打开服务端口:

1)打开windows管理工具下面的“服务”,找到NSClient服务,并启动它。

2)如果“本地连接”有开启防火墙或是有设置硬件防火墙,注意都要开打“12489”的端口。

 

4、在主控机上面的nagios参数配置:

1)查看命令参数中的定义

[root@localhost ]# vim /usr/local/nagios/etc/objects/command.cfg

  
  
  
  
  1. define command{  
  2.        command_name    check_nt  
  3.        command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$  
  4.         }

2)打开主程序nagios.cfg中的参数文件调用设置

[root@localhost ]# vim /usr/local/nagios/etc/nagios.cfg

  
  
  
  
  1. # Definitions for monitoring a Windows machine  
  2. cfg_file=/usr/local/nagios/etc/objects/windows.cfg  (去掉前面的#号注释符)  

3)查看windows.cfg中的参数设置

[root@localhost ]# vim /usr/local/nagios/etc/objects/windows.cfg

  
  
  
  
  1. define host{  ;定义被控主机  
  2.     use            windows-server  
  3.     host_name      winserver   ;定义被控机的名称,可用IP地址来区分
  4.     alias          My Windows Server  
  5.     address        192.168.0.4     ;定义被控机的IP地址  
  6.         }  
  7. (说明:注意如果多台被控机要分多个define host来定义,不能写在一起用逗号来隔开)  
  8.  
  9. define hostgroup{  ;定义主机群组  
  10.     hostgroup_name  windows-servers   ;定义主机群组的名称 
  11.     alias           Windows Servers  
  12.     members         winserver    ;加入此组的成员主机名,多个用逗号隔开  
  13.         }  
  14.  
  15. define servicegroup{  ;定义服务群组  
  16.     servicegroup_name   web_server   ;定义服务群组的名称  
  17.     alias               web server  
  18.     members           192.168.100.15,HTTP:8080,192.168.100.21,HTTP:80 ;注意这边要写两个项目 
  19.         }                (主机名称)  (服务类型)  
  20.  
  21. define service{    ;定义的服务不包含的主机  
  22.    use                     generic-service  
  23.    host_name        !192.168.100.5,!192.168.100.100  ;在主机前面加!表示排除这台主机,因它没F盘。  
  24.    hostgroup_name          windows-servers                      
  25.    service_description     F:\ Drive Space  
  26.    check_command           check_nt!USEDDISKSPACE!-l f -w 80 -c 90  
  27.         }  

 

(监控命令说明如下:

1)check_command  check_nt!UPTIME  监控windows服务器运行的时间

2)check_command  check_nt!CPULOAD!-l 5,80,90  监控Windows服务器的CPU负载,如果5分钟超过80%则是warnig,如果5分钟超过90%则是critical

3)check_command  check_nt!MEMUSE!-w 80 -c 90  监控Windows服务器的内存使用情况,如果超过了80%则是warnig,如果超过90%则是critical.

4)check_command  check_nt!USEDDISKSPACE!-l c -w 80 -c 90  监控Windows服务器C:\盘的使用情况,如果超过

(注:-l后面接的参数用来指定盘符)  80%已经使用则是warning,超过90%则是critical

5)check_command  check_nt!USEDDISKSPACE!-l d -w 80 -c 90  监控Windows服务器D:\盘的使用情况,如果超过

80%已经使用则是warning,超过90%则是critical

6)check_command  check_nt!SERVICESTATE!-d SHOWALL -l W3SVC  监控Windows服务器的W3SVC服务的状态,如果

(说明:W3SVCwindowsIIS服务服务停止了,则是critical

7)check_command  check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe  监控Windows服务器的Explorer.exe进程的状态,如果进程停止了,则是critical

8)check_command  check_nt!PROCSTATE!-d SHOWALL -l oracle.exe  监控Windows服务器下的oracle数据库状态

 

9)check_command  check_nt!PROCSTATE!-d SHOWALL -l TNSLSNR.exe  监控Windows服务器下oracle数据库

listener监听状态

 

4)验证参数据修改是否正确,并重新加载

[root@localhost ]# /usr/local/nagios/bin/nagios  -v  /usr/local/nagios/etc/nagios.cfg

[root@localhost ]# service nagios reload

你可能感兴趣的:(nagios,系统监控)