2013-08-21 33 views
4

我想設置nagios發送電子郵件通知。 我可以手動發送電子郵件通知,單擊nagios Web界面中的「發送自定義服務通知」。通知正在創建,並且電子郵件正在成功發送和發送。 但nagios不會自動發送通知。我已經測試過關閉機器上的PING服務(echo 1>/proc/sys/net/ipv4/icmp_echo_ignore_all)。 Nagios將PING服務設置爲CRITICAL狀態,但不發送通知郵件。Nagios不發送電子郵件

這是我的配置文件:

templates.cfg

define contact{ 
     name       generic-contact  ; The name of this contact template 
     service_notification_period  24x7   ; service notifications can be sent anytime 
     host_notification_period  24x7   ; host notifications can be sent anytime 
     service_notification_options w,u,c,r,f,s  ; send notifications for all service states, flapping events, and scheduled downtime events 
     host_notification_options  d,u,r,f,s  ; send notifications for all host states, flapping events, and scheduled downtime events 
     service_notification_commands notify-service-by-email ; send service notifications via email 
     host_notification_commands  notify-host-by-email ; send host notifications via email 
     register      0    ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE! 
} 

contacts.cfg的部分

define contact{ 
     contact_name     nagiosadmin  ; Short name of user 
     use        generic-contact  ; Inherit default values from generic-contact template (defined above) 
     alias       Nagios Admin  ; Full name of user 
     service_notification_options w,u,c,r,f,s 
     host_notification_options  d,u,r,f,s 
     email       [email protected]  ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** 
} 

define contactgroup{ 
     contactgroup_name  admins 
     alias     Nagios Administrators 
     members     nagiosadmin 
} 

的部分

仿製host_nagios2.cfg

define host{ 
     name       generic-host ; The name of this host template 
     notifications_enabled   1  ; Host notifications are enabled 
     event_handler_enabled   1  ; Host event handler is enabled 
     flap_detection_enabled   1  ; Flap detection is enabled 
     failure_prediction_enabled  1  ; Failure prediction is enabled 
     process_perf_data    1  ; Process performance data 
     retain_status_information  1  ; Retain status information across program restarts 
     retain_nonstatus_information 1  ; Retain non-status information across program restarts 
     check_command     check-host-alive 
     max_check_attempts    10 
     notification_interval   1 
     notification_period    24x7 
     notification_options   d,u,r,f,s 
     contact_groups     admins 
     register      0  ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE! 
} 

仿製service_nagios2.cfg

define service{ 
     name       generic-service ; The 'name' of this service template 
     active_checks_enabled   1  ; Active service checks are enabled 
     passive_checks_enabled   1  ; Passive service checks are enabled/accepted 
     parallelize_check    1  ; Active service checks should be parallelized (disabling this can lead to major performance problems) 
     obsess_over_service    1  ; We should obsess over this service (if necessary) 
     check_freshness     0  ; Default is to NOT check service 'freshness' 
     notifications_enabled   1  ; Service notifications are enabled 
     event_handler_enabled   1  ; Service event handler is enabled 
     flap_detection_enabled   1  ; Flap detection is enabled 
     failure_prediction_enabled  1  ; Failure prediction is enabled 
     process_perf_data    1  ; Process performance data 
     retain_status_information  1  ; Retain status information across program restarts 
     retain_nonstatus_information 1  ; Retain non-status information across program restarts 
     notification_interval   1  ; Only send notifications on status change by default. 
     is_volatile      0 
     check_period     24x7 
     normal_check_interval   5 
     retry_check_interval   1 
     max_check_attempts    4 
     notification_period    24x7 
     notification_options   w,u,c,r,f,s 
     contact_groups     admins 
     register      0  ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE! 
} 

我怎麼能強迫的nagios發送通知郵件?

回答

3

檢查主要的nagios.cfg文件並確保notifications_enabled = 1。同時驗證您的基本聯繫人模板也具有notifications_enabled = 1。

+3

我的'nagios.cfg'中的設置被稱爲'enable_notifications'。 –

4

我有類似的問題。原來是兩個問題的組合:

1)我沒有等待足夠長的警報。爲服務添加normal_check_interval和retry_check_interval * max_check_attempts,您將看到在獲得通知之前,您必須等待長達9分鐘。如果您必須更快地瞭解服務故障,請減少normal_check_interval和max_check_attempts。請注意,使用默認的Nagios配置可能需要15分鐘纔會通知您。

2)linux-server的默認配置是在工作時間通知你,但有問題的服務器是UTC。確保無處不在的notification_period變量是24x7。

祝你好運。

2

請考慮flap_detection_enabled設置。如果啓用此設置並確定存在震盪,則Nagios不會通知。撲動是服務經常在OK,軟和正常狀態之間變化的想法。在測試過程中,當我們測試時,服務通常會「翻動」以確保一切正常。測試期間,在主機和服務配置文件中禁用flap_detection_enabled設置。