nagios郵件警示設定

來源:互聯網
上載者:User

標籤:nagios   email   郵件警示   sendemail   

1、下載 sendEmail

   wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz

2、配置 sendEmail

   tar zxvf sendEmail-v1.56.tar.gz

   cd sendEmail-v1.56

   cp sendEmail /usr/local/bin

   chmod 777 /usr/local/bin/sendEmail

   發送測試郵件

   /usr/local/bin/sendEmail -f [email protected] -t [email protected] -s smtp.126.com -xu [email protected] -xp password -u "nagios" -m "tets"
解釋:
-f表示寄件者的郵箱
-t表示接收者的郵箱
-s表示SMTP伺服器的網域名稱或者ip
-u表示郵件的主題
-xu表示SMTP驗證的使用者名稱
-xp表示SMTP驗證的密碼
-m表示郵件的內容

3、配置contacts.cfg

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 ******

        }

4、配置commands.cfg

vi /usr/local/nagios/etc/objects/commands.cfg

註解# ‘notify-host-by-email‘ command definition 與# ‘notify-service-by-email‘ command definition下所有的設定

重新輸入以下內容

 

# ‘notify-host-by-email‘ command definition

define command{

       command_name    notify-host-by-email

       command_line    /usr/bin/printf "%b" "***** Nagios *****\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/local/bin/sendEmail -f [email protected] -t $CONTACTEMAIL$ -s smtp.126.com -u "**$HOSTALIAS$ is $HOSTSTATE$**"-xu [email protected] -xp password -o message-charset=utf8

       }

# ‘notify-service-by-email‘ command definition

define command{

       command_name    notify-service-by-email

  command_line    /usr/bin/printf "%b" "***** Nagios *****\nNotification Type: $NOTIFICATIONTYPE$\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n$SERVICEOUTPUT$\n" | /usr/local/bin/sendEmail -f [email protected] -t $CONTACTEMAIL$ -s smtp.126.com -u "**$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$**" -xu [email protected] -xp password -o message-charset=utf8

       }

5、重啟服務

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.