天天看點

Zabbix郵件報警

Zabbix監控服務端、用戶端都已經部署完成,被監控主機已經添加,Zabiix監控運作正常。

實作目的:

在Zabbix服務端設定郵件報警,當被監控主機當機或者達到觸發器預設值時,會自動發送報警郵件到指定郵箱。

具體操作:

以下操作在Zabbix監控服務端進行

備注:Zabbix監控服務端

作業系統:CentOS

主機名:zabbix.osyunwei.com

郵件報警有兩種情況:

1、Zabbix服務端隻是單純的發送報警郵件到指定郵箱,發送報警郵件的這個郵箱賬号是Zabbix服務端的本地郵箱賬号(例如:[email protected]),隻能發送,不能接收外部郵件。

2、使用一個可以在網際網路上正常收發郵件的郵箱賬号(例如:[email protected]),通過在Zabbix服務端中設定,使其能夠發送報警郵件到指定郵箱。

第一種:使用Zabbix服務端本地郵箱賬号發送郵件

一、安裝sendmail或者postfix

yum install sendmail #安裝

service sendmail start #啟動

chkconfig sendmail on #設定開機啟動

yum install postfix

service postfix start

chkconfig postfix on

CentOS 5.x 預設已經安裝好sendmail

CentOS 6.x 預設已經安裝好postfix

sendmail和postfix隻需要安裝一個即可并開啟服務即可。

修改:AlertScriptsPath=/usr/local/zabbix/alertscripts

echo "zabbix test mail" |mail -s "zabbix" [email protected]

vim /usr/local/zabbix/etc/zabbix_server.conf

AlertScriptsPath=/usr/local/zabbix/alertscripts

vim /usr/local/zabbix/alertscripts/SendEmail.sh

to=$1

subject=$2

body=$3

/usr/local/bin/sendEmail -f [email protected] -t "$to" -s smtp.126.com -u "$subject" -o message-content-type=html -o message-charset=utf8 -xu [email protected] -xp gongjiaxin123 -m "$body"

報警媒介類型

腳本

SendEmail.sh

參數:

{ALERT.SENDTO}

{ALERT.SUBJECT}

{ALERT.MESSAGE}

配置動作

繼續閱讀