2.3 nagios 配置郵件警示

來源:互聯網
上載者:User

標籤:nagios   郵件   警示   

       目前nagios只能在瀏覽器上查看各個機器各個服務的狀態,當某個機器宕掉或者某個服務宕掉時,我們是不知道的,因為我們不可能時時盯著服務看。這時,就需要用到警示系統了,讓它自動化,當發現問題時及時通知我們。下面配置使用發郵件的方式來實現警示。

       在服務端操作!

       首先定義郵件接受者。

[[email protected] ~]# vim /etc/nagios/objects/contacts.cfgdefine contact{        contact_name                    test1        use                             generic-contact        alias                           email1        email                           [email protected]}define contact{        contact_name                    test2        use                             generic-contact        alias                           email2        email                           [email protected]}define contactgroup{        contactgroup_name               common        alias                           common        members                         test1,test2}

        說明:contact.cfg 裡面既可以定義user也可以定義group,先定義兩個user test1和test2,然後把這兩個user加入到common組裡面。發郵件時就發給common組就可以了,這時[email protected]和[email protected]都會收到郵件。

        然後在需要警示的服務裡加上contactgroup

[[email protected] ~]# vim /etc/nagios/conf.d/192.168.56.128.cfg

        針對check_load服務增加警示配置

define service{   use            generic-service   host_name      192.168.56.128   service_description  check_load   check_command    check_nrpe!check_load   max_check_attempts   5   normal_check_interval   1   contact_groups   common   notifications_enabled  1   notification_period   24x7   notification_options  w,u,c,r}

       說明:notifications_enabled 1 表示是否開啟提醒功能。1 為開啟,0 為禁用。一般,這個選項會在主設定檔(nagios.cfg)中定義,效果相同。notification_period 24x7 表示發送提醒的時間段。如果不在定義的時間段內,無論什麼問題都不會發送提醒。notification_options:w,u,c,r 表示service的狀態。w 為 warning,u 為unknown,c 為critical,r 為recovery。類似的還有一個host對應的狀態:d,u,r,f,n。 d 狀態表示DOWN,u 為UNREACHABLE,r 狀態恢複為 OK,f 為flapping,n 為不發送提醒。需要加入到 host 的定義配置裡生效。

      編輯完設定檔後,重啟nagios服務

[[email protected] ~]# service nagios restartRunning configuration check...done.Stopping nagios: done.Starting nagios: done.



本文出自 “散宜生的學習筆記” 部落格,請務必保留此出處http://sanyisheng.blog.51cto.com/11154168/1795726

2.3 nagios 配置郵件警示

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.