Linux-Zabbix 郵件警示設定

來源:互聯網
上載者:User

標籤:subject   linu   lin   主題   span   init.d   郵件   targe   服務端   

系統內容Ubuntu 16.04在Zabbix伺服器端                                                                        

安裝sendmail

sudo apt install sendmail

測試發送郵件

echo "本文!" | mail -s 標題 [email protected]

成功後繼續安裝郵件伺服器。 Ubuntu系統中為heirloom-mailx

apt-get install heirloom-mailx
#yum install mailx //CentOS中為mailx,CentOS安裝後還需要改設定檔詳見

安裝好後開始配置.sh發送指令碼

mkdir /etc/zabbix/alertscripts vim /etc/zabbix/zabbix_server.conf                  //修改alert scripts為以下路徑AlertScriptsPath=/etc/zabbix/alertscripts/etc/init.d/zabbix_server restart            //重新啟動zabbix服務端#vim /etc/zabbix/alertscripts/sendmail.sh            //編寫郵件發送指令碼messages=`echo $3 | tr ‘\r\n‘ ‘\n‘`subject=`echo $2 | tr ‘\r\n‘ ‘\n‘`echo "${messages}" | mail -s "${subject}" $1 >>/tmp/sendmail.log 2>&1

增加可執行許可權

chown zabbix.zabbix /etc/zabbix/alertscripts/sendmail.shchmod +x /etc/zabbix/alertscripts/sendmail.sh

測試指令碼

su - zabbix/etc/zabbix/alertscripts/sendmail.sh [email protected] " 測試郵件標題" "測試郵件內容" //看是否可以由zabbix使用者執行調用
接下來進行伺服器web端設定                                                               

1、配置---動作  啟用;這一步詳細設定裡可以編輯發送郵件的內容和格式。

2、管理---警示媒介類型-建立媒介類型  如:

  添加3個指令碼參數:

  {ALERT.SENDTO},{ALERT.SUBJECT},{ALERT.MESSAGE}

  3個參數,分別對應sendEmail.sh指令碼需要的3個參數:收件者地址、主題、詳細內容

3、設定接受警示的郵箱-啟用

測試是否成功,在任意用戶端輸入                                                                           
/etc/init.d/zabbix_agentd stop

  查看是否正常收到警示郵件!完成。

 

Linux-Zabbix 郵件警示設定

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.