溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

nagios中怎么設(shè)置郵件報警

發(fā)布時間:2021-07-23 15:07:46 來源:億速云 閱讀:115 作者:Leah 欄目:移動開發(fā)

本篇文章為大家展示了nagios中怎么設(shè)置郵件報警,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。

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

   發(fā)送測試郵件

   /usr/local/bin/sendEmail -f test@126.com -t test@qq.com -s smtp.126.com -xu test@126.com -xp password -u "nagios" -m "tets"
解釋:
-f表示發(fā)送者的郵箱
-t表示接收者的郵箱
-s表示SMTP服務(wù)器的域名或者ip
-u表示郵件的主題
-xu表示SMTP驗證的用戶名
-xp表示SMTP驗證的密碼
-m表示郵件的內(nèi)容

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                           test@test.com   ; <<***** 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下所有的設(shè)置

重新輸入以下內(nèi)容

# '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 test@126.com -t $CONTACTEMAIL$ -s smtp.126.com -u "**$HOSTALIAS$ is $HOSTSTATE$**"-xu test@126.com -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 test@126.com -t $CONTACTEMAIL$ -s smtp.126.com -u "**$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$**" -xu test@126.com -xp password -o message-charset=utf8

       }

5、重啟服務(wù)

上述內(nèi)容就是nagios中怎么設(shè)置郵件報警,你們學(xué)到知識或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識儲備,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI