jiabanl 发表于 2013-3-19 09:17:49

Nagios监控Windows server 2003 系统

一、Nagios监控主机配置# cp /usr/local/nagios/etc/nagios.cfg /usr/local/nagios/etc/nagios.cfgbak20130318   //备份nagios.cfg编辑nagios.cfg配置文件# vim /usr/local/nagios/etc/nagios.cfg把下面这行最前面的#号去掉:39 #cfg_file=/usr/local/nagios/etc/objects/windows.cfg修改为:#去掉这句话的注释39 cfg_file=/usr/local/nagios/etc/objects/windows.cfg 编辑windows.cfg配置 文件# vim /usr/local/nagios/etc/objects/windows.cfg################################################################################ WINDOWS.CFG - SAMPLE CONFIG FILE FOR MONITORING A WINDOWS MACHINE## Last Modified: 06-13-2007## NOTES: This config file assumes that you are using the sample configuration#      files that get installed with the Nagios quickstart guide.################################################################################################################################################################################################################################################ HOST DEFINITIONS################################################################################################################################################################ Define a host for the Windows machine we'll be monitoring# Change the host_name, alias, and address to fit your situationdefine host{      use             windows-server; Inherit default values from a template      host_name       winserver       ; The name we're giving to this host      alias         My Windows Server       ; A longer name associated with the host      address         10.10.10.252      ; IP address of the host      }################################################################################################################################################################ HOST GROUP DEFINITIONS################################################################################################################################################################ Define a hostgroup for Windows machines# All hosts that use the windows-server template will automatically be a member of this groupdefine hostgroup{      hostgroup_namewindows-servers ; The name of the hostgroup      alias         Windows Servers ; Long name of the group      }
################################################################################################################################################################ SERVICE DEFINITIONS################################################################################################################################################################ Create a service for monitoring the version of NSCLient++ that is installed# Change the host_name to match the name of the host you defined abovedefine service{      use                     generic-service      host_name               winserver      service_description   NSClient++ Version      check_command         check_nt!CLIENTVERSION      }
# Create a service for monitoring the uptime of the server# Change the host_name to match the name of the host you defined abovedefine service{      use                     generic-service      host_name               winserver      service_description   Uptime      check_command         check_nt!UPTIME      }
# Create a service for monitoring CPU load# Change the host_name to match the name of the host you defined abovedefine service{      use                     generic-service      host_name               winserver      service_description   CPU Load      check_command         check_nt!CPULOAD!-l 5,80,90      }
# Create a service for monitoring memory usage# Change the host_name to match the name of the host you defined abovedefine service{      use                     generic-service      host_name               winserver      service_description   Memory Usage      check_command         check_nt!MEMUSE!-w 80 -c 90      }
# Create a service for monitoring C:\ disk usage# Change the host_name to match the name of the host you defined abovedefine service{      use                     generic-service      host_name               winserver      service_description   C:\ Drive Space      check_command         check_nt!USEDDISKSPACE!-l c -w 80 -c 90      }
define service{      use                     generic-service      host_name               winserver      service_description   D:\ Drive Space      check_command         check_nt!USEDDISKSPACE!-l c -w 80 -c 90      }
# Create a service for monitoring the W3SVC service# Change the host_name to match the name of the host you defined above
define service{      use                     generic-service      host_name               winserver      service_description   W3SVC      check_command         check_nt!SERVICESTATE!-d SHOWALL -l W3SVC      }
# Create a service for monitoring the Explorer.exe process# Change the host_name to match the name of the host you defined abovedefine service{      use                     generic-service      host_name               winserver      service_description   Explorer      check_command         check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe      }
:wq 重启Nagios httpd 服务# service nagios restart# service httpd restart 二、Windows被监控主机配置NSClient++与Nagios服务器通信,主要使用Nagios服务器的check_nt插件。原理图如下
1、下载NSClient++插件http://nsclient.org/nscp/downloadshttp://files.nsclient.org/0.3.x/NSClient%2B%2B-0.3.9-Win32.ziphttp://files.nsclient.org/0.3.x/NSClient%2B%2B-0.3.9-x64.zip 2、NSClient++安装插件与配置解压到C盘:C:\NSClient++-0.3.9-Win32打开cmd 切换到C:\>cd C:\NSClient++-0.3.9-Win32执行NSClient++ /install进行安装Microsoft Windows [版本 5.2.3790](C) 版权所有 1985-2003 Microsoft Corp.C:\Documents and Settings\Administrator>cd C:\NSClient++-0.3.9-Win32C:\NSClient++-0.3.9-Win32>NSClient++ /installService NSClientpp installed...l NSClient++.cpp(233) Service installed!
执行nsclient++ SysTray 注意大小写,这一步是安装系统托盘,时间稍微有点长C:\NSClient++-0.3.9-Win32>NSClient++ SysTrayd NSClient++.cpp(1216) Enabling debug mode...Invalid command line argument: SysTrayUsage: -version, -about, -install, -uninstall, -start, -stop, -encryptUsage: [-noboot] <ModuleName> <commnd>
在运行里面输入services.msc打开”服务”看到下图就说明NSClient服务已经安装上了


双击打开,点”登录”标签,在”允许服务与桌面交互”前打勾

编辑C:\NSClient++-0.3.9-Win32下的nsc.ini文件
选项所有模块前面的注释都去掉,除了CheckWMI.dll and RemoteConfiguration.dll这两个;
选项password选项来设置密码,作用是在nagios连接过来时要求提供密码.这一步是可选的,我这里方便起见跳过它,不要密码;allowed_hosts选项的注释去掉,并且加上运行nagios的监控主机的IP.我改为如下:allowed_hosts=127.0.0.1/32,10.10.10.254 以逗号相隔.这个地方是支持子网的,如果写成192.168.0.0/24则表示该子网内的所有机器都可以访问.如果这个地方是空白则表示所有的主机都可以连接上来.注意是部分的,因为部分也有这个选项;
选项port选项去掉注释,并且它的值是'12489',这是NSClient的默认监听端口;
在CMD中执行NSClient++ /start启动服务,注意所在目录是C:\NSClient++-0.3.9-Win32C:\NSClient++-0.3.9-Win32>NSClient++ /startStarting NSClientpp
在cmd里面执行netstat –an可以看到已经开始监听tcp的12489端口了C:\NSClient++-Win32-0.3.5>netstat -anTCP    0.0.0.0:12489    0.0.0.0:0   LISTENING
已经正常启动了.注意服务默认设的是”自动”,也就是说是开机自动启动的.


这时在桌面右下角的系统托盘处会出现一个图标
这样被Windows server 2003监控机的配置完成,它就等待nagios发出某个监控请求,然后它执行请求将监控的结果发回到nagios监控主机上。 最后,在服务端监控端执行检测windows server 2003工作站nrpe信息# /usr/local/nagios/libexec/check_nrpe -H 10.10.10.252I (0.3.9.329 2011-09-02) seem to be doing fine... 验证通过,测试完成! 3、登录到WEB界面输入用户名密码:nagiosadmin123456http://localhost/nagiosServices


窝窝插件 发表于 2013-3-19 09:51:10

老天,你让夏天和冬天同房了吧?生出这鬼天气!

seemebaby 发表于 2013-5-16 10:09:09

所有的男人生来平等,结婚的除外。

lxy777 发表于 2013-5-17 15:04:20

微机原理闹危机,随机过程随机过,实变函数学十遍,汇编语言不会编!

haloi 发表于 2013-5-18 18:47:54

修养的艺术,其实就是说谎的艺术。

x625802392 发表于 2013-5-20 00:58:15

怀揣两块,胸怀500万!

cjcmay 发表于 2013-5-21 03:43:35

不在放荡中变坏,就在沉默中变态!
页: [1]
查看完整版本: Nagios监控Windows server 2003 系统