標籤:nagios 監控
Nagios自訂警示時間
遇到需要自訂檢查和警示時間的,總結一下。大家集思廣益,不斷完善。
常調用的模板設定檔:
efine service{
name generic-service ; 定義一個服務名稱
active_checks_enabled 1 ; Activeservice checks are enabled
passive_checks_enabled 1 ; Passiveservice checks are enabled/accepted
parallelize_check 1 ; Activeservice checks should be parallelized;
; (disabling this can lead to major performance problems)
obsess_over_service 1 ; Weshould obsess over this service (if necessary)
check_freshness 0 ; Defaultis to NOT check service ‘freshness‘
notifications_enabled 1 ; Servicenotifications are enabled
event_handler_enabled 1 ; Serviceevent handler is enabled
flap_detection_enabled 1 ; Flapdetection is enabled
failure_prediction_enabled 1 ; Failureprediction is enabled
process_perf_data 1 ; Processperformance data
retain_status_information 1 ; Retainstatus information across program restarts
retain_nonstatus_information 1 ; Retainnon-status information across program restarts
is_volatile 0 ; Theservice is not volatile
check_period 24x7 ; 這裡的check_period告訴nagios檢查服務的時間段。
max_check_attempts 3 ; nagios對服務的最大檢查次數。
normal_check_interval 5 ; 此選項是用來設定服務檢查時間間隔,也就是說,nagios這一次檢查和下一次檢查之間所隔的時間;
; 這裡是5分鐘。
retry_check_interval 2 ; 重試檢查時間間隔,單位是分鐘。
contact_groups admin ; 指定連絡人群組
notification_options w,u,c,r ; 這個定義的是“通知可以被發出的情況”。w即warn,表示警告狀態;
; u即unknown,表示不明狀態;
; c即criticle,表示緊急狀態,r即recover,表示恢複狀態;
; 也就是在服務出現警告狀態、未知狀態、緊急狀態和重新恢複後都發送通知給使用者。
notification_interval 10 ; Re-notify aboutservice problems every hour
notification_period 24x7 ; 指定“發送通知”的時間段,也就是可以在什麼時候發送通知給使用者。
register 0 ; DONT REGISTERTHIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}
define service{
name local-service ; The name of this service template
use generic-service ; Inherit default values from thegeneric-service definition
max_check_attempts 4 ; Re-check theservice up to 4 times in order to determine its final (hard) state
normal_check_interval 5 ; Check the service every 5 minutes undernormal conditions
retry_check_interval 1 ; Re-check theservice every minute until a hard state can be determined
register 0 ; DONT REGISTER THISDEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}
[[email protected] objects]# cattimeperiods.cfg
………………….
define timeperiod{
timeperiod_name 24x7
alias 24 Hours A Day, 7Days A Week
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}
自訂檢查和警示時間:
define timeperiod{
timeperiod_name rd_bus_engine_time
alias rd_bus_engine_time
monday 07:55-08:05
tuesday 07:55-08:05
wednesday 07:55-08:05
thursday 07:55-08:05
friday 07:55-08:05
saturday 07:55-08:05
sunday 07:55-08:05
}
defineservice{
use local-service
host_name 10.19.190.22_bus_engine
service_description compile_critical_log
contact_groups rd-bus-engine-group
check_period rd_bus_engine_time
notification_period rd_bus_engine_time
notification_options w,u,c,r
check_command check_nrpe!check_log
}
檢查重啟。
本文出自 “love笨笨的部落格” 部落格,請務必保留此出處http://6622951.blog.51cto.com/6612951/1413510