五、被监控机(windows)系统的安装配置
NSClient与nrpe最大的区别就是:
--被监控机上安装有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文件,根据下面要求修改配置:
- ;# NSCLIENT++ MODULES
- ;# A list with DLLs to load at startup.
- ; You will need to enable some of these for NSClient++ to work.
- ; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
- ; * *
- ; * N O T I C E ! ! ! - Y O U H A V E T O E D I T T H I S *
- ; * *
- ; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
- ;FileLogger.dll
- ;CheckSystem.dll
- ;CheckDisk.dll
- ;NSClientListener.dll
- ;NRPEListener.dll
- ;SysTray.dll
- ;CheckEventLog.dll
- ;CheckHelpers.dll
- ;CheckWMI.dll (这边前面的分号不去掉)
- ;
- ; Script to check external scripts and/or internal aliases.
- ;CheckExternalScripts.dll
- ;
- ; NSCA Agent if you enable this NSClient++ will talk to NSCA hosts repeatedly (so dont enable unless you want to use NSCA)
- ;NSCAAgent.dll
- ;
- ; LUA script module used to write your own "check deamon".
- ;LUAScript.dll
- ;
- ; RemoteConfiguration IS AN EXTREM EARLY IDEA SO DONT USE FOR PRODUCTION ENVIROMNEMTS!
- ;RemoteConfiguration.dll (这边前面的分号不去掉)
- ; Check other hosts through NRPE extreme beta and probably a bit dangerous! :)
- ;NRPEClient.dll
- ; Extreamly early beta of a task-schedule checker
- ;CheckTaskSched.dll
- [Settings]
- ;# PASSWORD
- ;password=secret-password (连接的密码设置,如果不用密码,这边的分号可不去掉)
- allowed_hosts=127.0.0.1/32,192.168.0.100(前面的分号去掉,然后加上主控机的IP地址)
- (如果是内网192要监控公网的机器,在这边首先要查出主监控机网段出去的公网IP,可通过http://www.ip138.com查询到监控机网段出去的公网IP地址,写入到allowed_hosts中)
- [NSClient]
- ;# NSCLIENT PORT NUMBER
- ; This is the port the NSClientListener.dll will listen to.
- port=12489 (前面的分号去掉,打开服务的12489端口,不然主控机没法访问过来)
3、启动客户端服务并打开服务端口:
(1)打开windows管理工具下面的“服务”,找到NSClient服务,并启动它。
(2)如果“本地连接”有开启防火墙或是有设置硬件防火墙,注意都要开打“12489”的端口。
4、在主控机上面的nagios参数配置:
(1)查看命令参数中的定义
[root@localhost ]# vim /usr/local/nagios/etc/objects/command.cfg
- define command{
- command_name check_nt
- command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$
- }
(2)打开主程序nagios.cfg中的参数文件调用设置
[root@localhost ]# vim /usr/local/nagios/etc/nagios.cfg
- # Definitions for monitoring a Windows machine
- cfg_file=/usr/local/nagios/etc/objects/windows.cfg (去掉前面的#号注释符)
(3)查看windows.cfg中的参数设置
[root@localhost ]# vim /usr/local/nagios/etc/objects/windows.cfg
- define host{ ;定义被控主机
- use windows-server
- host_name winserver ;定义被控机的名称,可用IP地址来区分
- alias My Windows Server
- address 192.168.0.4 ;定义被控机的IP地址
- }
- (说明:注意如果多台被控机要分多个define host来定义,不能写在一起用逗号来隔开)
- define hostgroup{ ;定义主机群组
- hostgroup_name windows-servers ;定义主机群组的名称
- alias Windows Servers
- members winserver ;加入此组的成员主机名,多个用逗号隔开
- }
- define servicegroup{ ;定义服务群组
- servicegroup_name web_server ;定义服务群组的名称
- alias web server
- members 192.168.100.15,HTTP:8080,192.168.100.21,HTTP:80 ;注意这边要写两个项目
- } (主机名称) (服务类型)
- define service{ ;定义的服务不包含的主机
- use generic-service
- host_name !192.168.100.5,!192.168.100.100 ;在主机前面加!表示排除这台主机,因它没F盘。
- hostgroup_name windows-servers
- service_description F:\ Drive Space
- check_command check_nt!USEDDISKSPACE!-l f -w 80 -c 90
- }
(监控命令说明如下:)
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服务的状态,如果
(说明:W3SVC是windows的IIS服务) 服务停止了,则是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