<b>nagios配置解釋</b>
notifications_enabled [0/1] ; 是否開啟提醒功能。"1" 為開啟,"0" 為禁用。一般,這個選項會在主配置檔案 (nagios.cfg) 中定義,效果相同。
stalking_options [o,d,u] ; 持續狀态檢測參數,o = 持續的 UP 狀态 , d = 持續的 DOWN 狀态 , u = 持續的 UNREACHABLE 狀态
}
服務監控的配置
define service {
host_name host_name
service_description service_description
servicegroups servicegroup_names
is_volatile [0/1]
check_command command_name
max_check_attempts
normal_check_interval
retry_check_interval
active_checks_enabled [0/1]
passive_checks_enabled [0/1]
check_period timeperiod_name
parallelize_check [0/1]
obsess_over_service [0/1]
check_freshness [0/1]
freshness_threshold
event_handler command_name
event_handler_enabled [0/1]
low_flap_threshold
high_flap_threshold
flap_detection_enabled [0/1]
process_perf_data [0/1]
retain_status_information [0/1]
retain_nonstatus_information [0/1]
notification_interval
notification_period timeperiod_name n
otification_options [w,u,c,r,f]
notifications_enabled [0/1]
contact_groups contact_groups
stalking_options [o,w,u,c]
服務監控的配置和主機監控的配置較為相似,就不一一說明了。
間隔時間的計算方法為:
normal_check_interval x interval_length 秒
retry_check_interval x interval_length 秒
notification_interval x interval_length 秒
主機監控配置的例子
define host {
host_name web1
alias web1
address 192.168.0.101
contact_groups admins
check_command check-host-alive
max_check_attempts 5
notification_interval 0
notification_period 24x7
notification_options d,u,r
對主機 web1 進行 24x7 的監控,預設會每 10 秒檢查一次狀态,累計五次失敗就發送提醒,并且不再重複發送提醒。
服務監控配置的例子
service_description check_http
check_period 24x7
max_check_attempts 3
normal_check_interval 30
retry_check_interval 15
notification_interval 3600
notification_options w,u,c,r
check_command check_http
配置解釋: 24x7 監控 web1 主機上的 HTTP 服務,檢查間隔為 30 秒, 檢查失敗後每 15 秒再進行一次檢查,累計三次失敗就認定是故障并發送提醒。
聯系人組是 admins 。提醒後恢複到 30 秒一次的 normal_check_interval 檢查。如果服務仍然沒有被恢複,每個小時發送一次提醒。
如果要檢測其他服務,例如,要檢查 ssh 服務是否開啟,更改如下兩行:
service_description check_ssh
check_command check_ssh
為友善管理,對配置檔案的分布做了如下修改:
nagios.cfg 中增加了:
cfg_dir=/usr/local/nagios/etc/hosts
cfg_dir=/usr/local/nagios/etc/services
在 hosts 目錄中,為不同類型的主機建立了配置檔案,如: app.cfg cache.cfg mysql.cfg web.cfg
并建立了 hostgroup.cfg 檔案對主機進行分組,如:
define hostgroup {
hostgroup_name app-hosts
alias APP Hosts
members app1,app2
在 services 目錄中建立了各種服務的配置檔案,如: disk.cfg http.cfg load.cfg mysql.cfg
并建立了 servicegroup.cfg 檔案對服務進行分組,如:
define servicegroup {
servicegroup_name disk
alias DISK
members cache1,check_disk,cache2,check_disk
本文轉自 holy2009 51CTO部落格,原文連結:http://blog.51cto.com/holy2010/329232