详细请参考:yahoon兄的博客 http://yahoon.blog.51cto.com/13184/41897
我这里只做了些个人修改
1.下载NSClient 相当于 nrpe
http://sourceforge.net/projects/nscplus
2.MSDOS下
E:\soft\NSClient_2B%2B-0.3.8-Win32>nsclient++ /install
3.查看服务是否有NSClient 开始-运行-services.msc
MSI版本的话就直接安装好了,可以省略上面:
4.修改NSC.ini文件
将 [modules]部分的所有模块前面的注释都去掉,除了CheckWMI.dll and RemoteConfiguration.dll这两个 FileLogger.dll CheckSystem.dll CheckDisk.dll NSClientListener.dll NRPEListener.dll SysTray.dll CheckEventLog.dll CheckHelpers.dll ;CheckWMI.dll |
在[Settings]部分设置'password'选项来设置密码,作用是在nagios连接过来时要求提供密码.这一步是可选的,我这里方便起见跳过它,不要密码.看最后
|
将[Settings]部分'allowed_hosts'选项的注释去掉,并且加上运行nagios的监控主机的IP.我改为如下这样
allowed_hosts=127.0.0.1/32,192.168.68.55
以逗号相隔.这个地方是支持子网的,如果写成
192.168.0.0/24则表示该子网内的所有机器都可以访问.如果这个地方是空白则表示所有的主机都可以连接上来.注意是[Settings]部分的,因为[NSClient]部分也有这个选项.
|
必须保证[NSClient]的'port'选项并没有被注释,并且它的值是'12489',这是NSClient的默认监听端口 ;# NSCLIENT PORT NUMBER ; This is the port the NSClientListener.dll will listen to. port=12489 |
5. 在CMD中执行 nsclient++ /start 启动服务
顺便再服务里设置NSClient自动启动服务
检测: netstat -an 12489
6. 增加监控项目
#添加
define host {
host_name 192.168.68.79
alias squid1
address 192.168.68.79
contact_groups doggroup
check_command check-host-alive
check_period 24x7
max_check_attempts 5
notification_interval 10
notification_period 24x7
notification_options d,u,r
}
vi /usr/local/nagios/etc/services.cfg
define service{
host_name 192.168.68.79
service_description check-CPU
check_command check_nt!CPULOAD!-l 5,80,90
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24x7
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
contact_groups doggroup
}
host_name 192.168.68.79
service_description check-Cdrive
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24x7
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
contact_groups doggroup
}
host_name 192.168.68.79
service_description check-Mem
check_command check_nt!MEMUSE!-w 80 -c 90
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24x7
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
contact_groups doggroup
}
关于增加密码:
修改nsc.ini
[Settings]
;# OBFUSCATED PASSWORD
; This is the same as the password option but here you can store the password in an obfuscated manner.
; *NOTICE* obfuscation is *NOT* the same as encryption, someone with access to this file can still figure out the
; password. Its just a bit harder to do it at first glance.
;obfuscated_password=Jw0KAUUdXlAAUwASDAAB
;
;# PASSWORD
; This is the password (-s) that is required to access NSClient remotely. If you leave this blank everyone will be able to access the daemon remotly.
password=My2Secure$Password
--------------------------------------------------------------------------------------------------------------------------
vi command.cfg 修改
define command{
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s My2Secure$Password -v $ARG1$ $ARG2$
}