nagios郵件警示配置

來源:互聯網
上載者:User

標籤:警示系統   service   contact   郵件系統   start   

搭建nagios的目的就是為了他的警示系統,nagios據我所瞭解可以有三種警示:
  一、聲音警示
  二、電子郵件警示
  三、手機短訊警示
  下面是我的郵件警示的配置過程:
  1、開啟系統內建的sendmail郵件系統
  service sendmail start
  如果沒有安裝,可以yum一下
  yum install -y sendmail*
  service sendmail restart
  測試發送郵件:
  echo "test" | mail [email protected]
  我系統在關掉iptables和selinux前提下是正常的
  2、配置nagios中警示郵箱
  vi /usr/local/nagios/etc/objects/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
  email                           [email protected]   ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
  }
  在email那裡加上自己的郵箱,如果有多個可以用逗號隔開
  3、設定警示方式:
  vi /usr/local/nagios/etc/objects/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!
  }
  這兩個notify-service-by-email 和  notify-host-by-email    是在command.cfg那裡定義的,看看是怎麼定義的:
  # ‘notify-host-by-email‘ command definition
  define command{
  command_name    notify-host-by-email
  command_line    /usr/bin/printf "%b" "***** Nagios ***** Notification Type: $NOTIFICATIONTYPE$ Host: $HOSTNAME$ State: $HOSTSTATE$ Address: $HOSTADDRESS$ Info: $HOSTOUTPUT$ Date/Time: $LONGDATETIME$ " | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
  }
  # ‘notify-service-by-email‘ command definition
  define command{
  command_name    notify-service-by-email
  command_line    /usr/bin/printf "%b" "***** Nagios ***** Notification Type: $NOTIFICATIONTYPE$ Service: $SERVICEDESC$ Host: $HOSTALIAS$ Address: $HOSTADDRESS$ State: $SERVICESTATE$ Date/Time: $LONGDATETIME$ Additional Info: $SERVICEOUTPUT$ " | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
  }
  這裡已經預設配置好,我們不用修改直接調用就是了
  最後重啟服務:
  service nagios retart
  然後隨便關掉一些服務測試一下效果!


本文出自 “12336621” 部落格,請務必保留此出處http://12346621.blog.51cto.com/12336621/1905421

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.