我已经通过EPEL存储库在全新安装的CentOS 7上部署了一个新的Nagios实例 . 所以Nagios Core版本是3.5.1 .
在安装了nagios和nagios-plugins-all(通过yum)之后,我创建了许多主机和服务定义,用 nagios -v /etc/nagios/nagios.cfg
测试了我的配置,并启动并运行了Nagios!
不幸的是,我的主机检查失败了(尽管我的服务检查工作正常) .
在Nagios Web GUI / Dashboard中,如果我深入查看具有“主机状态信息”的主机页面,我会看到报告“状态信息”(已删除IP地址):
状态信息:/ usr / bin / ping -n -U -w 30 -c 5 CRITICAL - 无法解释ping命令的输出
因此,在我的故障排除中,我深入了解Nagios插件目录(/ usr / lib64 / nagios / plugins),并使用check_ping插件运行测试,该插件与check-host-alive运行命令的方式一致(请参阅下面的检查) -host-alive命令定义):
./check_ping -H {my-ip-address} -w 3000.0,80% -c 5000.0,100% -p 5
此check_ping命令返回以下输出:
PING OK - 数据包丢失= 0%,RTA = 0.63 ms | rta = 0.627000ms; 3000.000000; 5000.000000; 0.000000 pl = 0%; 80; 100; 0
我没有改变check_ping如何工作的定义,并且只要命令的运行方式与check-host-alive运行命令一样,我就可以确认我得到了“PING OK”,所以我无法弄清楚是什么上!
以下是check-host-alive和check_ping的命令定义 .
# 'check-host-alive' command definition
define command{
command_name check-host-alive
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
}
{snip}
# 'check_ping' command definition
define command{
command_name check_ping
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
}
有关如何修复check-host-alive命令定义以正常工作并正确评估check_ping输出的任何建议?
Edit
以下是我正在使用的完整定义主机{}模板:
define host {
host_name myers ; The name of this host template
alias Myers
address [redacted]
check_command check-host-alive
contact_groups admins
notifications_enabled 0 ; Host notifications are enabled
event_handler_enabled 1 ; Host event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
notification_period 24x7 ; Send host notifications at any time
register 1
max_check_attempts 2
}
3 回答
我在/ usr / bin / ping上找不到ping
最后运行以下命令,
对于遇到此问题的任何其他人,除了更改ping权限之外,还有另一种选择 . 只需更改host check命令即可使用
check_host
而不是check_ping
. 虽然功能上肯定存在一些差异,但总体最终结果是相同的 .有些人会说这不是一个好的选择,因为能够对
check_ping
命令进行测距,但应该记住,主机检查对测试吞吐量并不感兴趣,有很多更好的方法来处理它而不是依赖在ICMP
上,这是网络上优先级最低的流量类型 .我确信OP现在还处于其他方面,但希望有这个问题的其他人也会受益 .
我相当肯定运行
chmod U+s /usr/bin/ping
会解决问题,但我(并且仍然)对chmod的系统文件保持警惕 . 在我看来,必须有一种更安全的方式来做到这一点 .然而,最后,这就是我所做的 - 而且它有效 . 从安全的角度来看,我不喜欢它,但也许我在这个问题上得到了我的“内裤” .