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!
}
[root@SHUBEI-34-223 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