define service { host_name host_name service_description service_description servicegroups servicegroup_names is_volatile [0/1] #是否啟用“volatile”模式。這個(gè)模式的含義是說(shuō)名這個(gè)服務(wù)是不穩(wěn)定的,或者說(shuō)是危險(xiǎn)的。只要其狀態(tài)改變了,就不會(huì)再自己被恢復(fù)回來(lái)。這個(gè)參數(shù)很少使用,等到使用的時(shí)候我們?cè)賮?lái)細(xì)說(shuō)。 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,還是讓我們來(lái)舉例說(shuō)明一下吧。
1、隨時(shí)監(jiān)控Web.TEST主機(jī)上的HTTP服務(wù)(80端口),發(fā)生兩次不能訪問(wèn)及認(rèn)定是發(fā)生故障,故障累計(jì)3次告警,聯(lián)系人組是mygroup。告警之后每?jī)煞昼娫龠M(jìn)行一次檢查,如果10分鐘之后仍然沒(méi)有恢復(fù),再發(fā)送一次告警。
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 } |
如果要檢測(cè)其他服務(wù),則將代碼中藍(lán)色的兩行修改即可。例如,要檢查默認(rèn)的ssh服務(wù)是否開(kāi)啟:
define service { host_name Web.TEST service_description check_ssh check_period 24x7 …… check_command check_ssh } |
在測(cè)試服務(wù)的時(shí)候,要充分發(fā)揮插件的功能,如何安裝和使用插件,請(qǐng)看這篇文章。