检查服务是否启动正常,执行如下命令
netstat-nltp |grep 5666
测试远程:
在监控主机(200)上执行:
/usr/local/nagios/libexec/check_nrpe-H 192.168.30.150 #安装nrpe的被监控主机
如果成功会显示:
NRPE v2.13
11.编写测试代码(监控150负载均衡)
在监控主机上(200)编辑/usr/local/nagios/etc/objects/commands.cfg,加入如下命令:
# 'check_nrp' command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
在/usr/local/nagios/etc/objects中添加文件150.cfg,对于每一台机器可以添加一个文件
define host{
use generic-host
host_name 150
alias 150
address 192.168.30.150 ;被测试机ip
max_check_attempts 10
check_command check-host-alive ; Default command to check if servers are "alive"
}
define service{
use generic-service
host_name 150
service_description nrpe_load
check_command check_nrpe!check_load
}
修改/usr/local/nagios/etc/nagios.cfg,大概在30行左右,添加如下代码,主要是为了导入刚才写的文件
cfg_file=/usr/local/nagios/etc/objects/150.cfg
检测配置是否正确后,重启nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios restart
即可看到如下界面:
150 为新添加的监控项。