define service { host_name host_name service_description service_description servicegroups servicegroup_names is_volatile [0/1] #是否啟用“volatile”模式。這個模式的含義是說名這個服務是不穩定的,或者說是危險的。只要其狀態改變了,就不會再自己被恢復回來。這個參數很少使用,等到使用的時候我們再來細說。 check_command command_name max_check_attempts # 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] } |
ok,還是讓我們來舉例說明一下吧。
1、隨時監控Web.TEST主機上的HTTP服務(80端口),發生兩次不能訪問及認定是發生故障,故障累計3次告警,聯系人組是mygroup。告警之后每兩分鐘再進行一次檢查,如果10分鐘之后仍然沒有恢復,再發送一次告警。
define service { host_name Web.TEST service_description check_tcp 80 check_period 24x7 max_check_attempts 2 normal_check_interval 3 retry_check_interval 2 contact_groups mygroup notification_interval 10 notification_period 24x7 notification_options w,u,c,r check_command check_tcp!80 } |
如果要檢測其他服務,則將代碼中藍色的兩行修改即可。例如,要檢查默認的ssh服務是否開啟:
define service { host_name Web.TEST service_description check_ssh check_period 24x7 …… check_command check_ssh } |
在測試服務的時候,要充分發揮插件的功能,如何安裝和使用插件,請看這篇文章。