nagios nrpe监控远程主机(3)
发布时间:2021-06-05
发布时间:2021-06-05
echo "cfg_file=/usr/local/nagios/etc/objects/hostA.cfg" >> /usr/local/nagios/etc/nagios.cfg
如果要再添加B机器方法炮制就可以了
hostA.cfg
define host{
use generic-server
host_name A
alias A
address A 的IP
}
define service{
use generic-service
host_name A
service_description load
check_command check_nrpe!check_load
#使用自定参数
#check_command check_nrpe!check_load!6.0,5.0,4.0!15.0,8.0,6.0
}
重启监控机nagios
service nagios reload
访问http://localhost/nagios就可以看到新增的机器了
如何修改nrpe端口
被监控机nrpe.cfg修改server_port为15666
server_port=15666
重启nrpe
监控机commands.cfg增加-p 15666
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 15666 -c $ARG1$ }
重启nagios就可以了
Connection refused or timed out
检查nrpe 端口
检查nrpe.cfg中allowed_hosts是否包含监控机ip地址
检查/etc/hosts.allow文件中监控机ip地址nrpe:192.168.1.91
检查iptables
开放5666端口
iptables -L
iptables -A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 5666 -j ACCEPT
#注意顺序
iptables -L
service iptables save
service iptables restart