一,安装nagios被监控端(Windows)
下载nsclient++ http://sourceforge.net/projects/nscplus
将下载的文件解压到C盘,并改名为"NSClient++"
二,安装NSClient服务
进入cmd命令行,切换到C:\NSClient++,执行命令 NSClient++.exe /install,这样nsclient就会安装到windows services中;
三,配置NSClient
修改 C:\NSClient++\nsc.ini
去掉以下注释(将前面的分号去掉)
[modules]
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
NSClientListener.dll
NRPEListener.dll
SysTray.dll
CheckEventLog.dll
CheckHelpers.dll
NSCAAgent.dll
LUAScript.dll
NRPEClient.dll
CheckTaskSched.dll
[Settings]
allowed_hosts= 192.168.5.0/24 (里面的192.168.5.0/24表示允许5网段的所有机器访问)
use_file=1
[log]
debug=1
file=nsclient.log
date_mask=%Y-%m-%d %H:%M:%S
[NSClient]
allowed_hosts= 192.168.5.0/24 (里面的192.168.5.0/24表示允许5网段的所有机器访问)
port=12489
[NRPE]
port=5666
allowed_hosts=192.168.5.0/24 (里面的192.168.5.0/24表示允许0网段的所有机器访问)
script_dir=scripts\
[NSCA Agent]
interval=5
hostname=Host31 (本机名)
nsca_host=192.168.5.30 (nagios服务端IP)
nsca_port=5666 (nrpe服务端端口)
[NSCA Commands]
my_cpu_check=checkCPU warn=80 crit=90 time=20m time=10s time=4
my_mem_check=checkMem MaxWarn=80% MaxCrit=90% ShowAll type=page
my_svc_check=checkServiceState CheckAll exclude=wampmysqld exclude=MpfService
host_check=check_ok
四,启动NSClient,
进入windows 服务管理,启动NSClient,并设置成自动启动;
查看NSClient是否启动,
在cmd里面执行netstat –an是否已经开始监听tcp的12489端口
桌面右下角,会有NSClient的托盘图标(像三个十字架叠加的图标)
五,配置nagios服务端.
1,定义命令
在 "/usr/local/nagios/etc/objects/commands.cfg" 定义一条命令;
# 'check_nt' command definition
define command{
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$
}
2,配置
define host{
use windows-server ; Inherit default values from a template
host_name 192.168.5.31 ; The name we're giving to this host
alias Host31 ; A longer name associated with the host
address 192.168.5.31 ; IP address of the host
}
define hostgroup{
hostgroup_name windows-servers ; The name of the hostgroup
alias Windows Servers ; Long name of the group
}
# 监控系统运行时间
define service{
use generic-service
host_name 192.168.5.31
service_description Uptime
check_command check_nt!UPTIME
}
# 监控 CPU 负载
define service{
use generic-service
host_name 192.168.5.31
service_description Load Average
check_command check_nt!CPULOAD!-l 5,80,90
}
# 监控 内存
define service{
use generic-service
host_name 192.168.5.31
service_description Memory
check_command check_nt!MEMUSE!-w 80 -c 90
}
#监控 C 盘使用情况
define service{
use generic-service
host_name 192.168.5.31
service_description C Disk
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
#监控 HTTP
define service{
use generic-service
host_name 192.168.5.31
service_description HTTP
check_command check_http
}
3,重启nagios
六,收工,看看效果