我已經通過EPEL存儲庫在新安裝的CentOS 7上部署了一個新的Nagios實例。所以Nagios Core版本是3.5.1。Nagios使用check_ping監控主機
在安裝nagios和nagios-plugins-all(通過yum)之後,我創建了一些主機和服務定義,已經用nagios -v /etc/nagios/nagios.cfg
測試了我的配置,並且讓Nagios啓動並運行!
不幸的是,我的主機檢查失敗(儘管我的服務檢查工作正常)。
在Nagios的網絡GUI /儀表板,如果我深入到一個主機頁面與「主機狀態信息」,我看到這是報道的「狀態信息」(刪除IP地址):
狀態信息:在/ usr/bin中/平-n -U -w 30 -c 5 {我的主機IP地址的}
嚴重 - 無法從ping命令解釋輸出
因此,在我的故障診斷中,我深入瞭解了Nagios插件目錄(/ usr/lib64/nagios/plugins),並使用check_ping插件與check-host-alive運行命令的方式一致地運行測試(請參閱下面我檢查主機活着命令定義):
./check_ping -H {my-ip-address} -w 3000.0,80% -c 5000.0,100% -p 5
這check_ping命令返回以下輸出:
PING確定 - 數據包丟失= 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_ping正確的輸出有什麼建議?
編輯
以下是完整定義主機{}模板,我使用:
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
}
你確定nagios用戶可以運行ping命令嗎? – MrCleanX 2014-11-05 18:49:35
您爲「狀態信息」顯示的內容不是它應該的樣子。在輸出中不應該引用/ usr/bin/ping,即使失敗也是如此。 – 2014-11-16 21:47:45
@MrCleanX - 我讀過幾篇博文,建議我檢查一下。我有點警惕chmod ping二進制文件(這是大多數博客文章的建議)。是否有另一個(更安全)的選項,比如添加Nagios用戶來ping羣組什麼的? – 2014-11-17 13:38:42