1. 程式人生 > >zabbix_QQ郵件告警部署(待續。。。。。。)

zabbix_QQ郵件告警部署(待續。。。。。。)

安裝sendmail

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

yum -y install perl-Net-SSLeay perl-IO-Socket-SSL

tar xf sendEmail-v1.56.tar.gz -C /usr/local/

cd /usr/local/sendEmail-v1.56/

/bin/cp -ra sendEmail /usr/local/bin/

chmod +x /usr/local/bin/sendEmail

登入qq郵箱進行設定:

測試郵件傳送

cd /usr/local/sendEmail-v1.56/

sendEmail -f 1450595701@qq.com -t 1450595701@qq.com -u "zabbix_server" -s smtp.qq.com -o message-content-type=html -o tls=no message-charset=utf8 -xu 1450595701@qq.com -xp zoyswlqfhxhricdf

 -m "郵件傳送成功"

編寫QQ郵件平臺報警指令碼

cd /usr/local/zabbix/share/zabbix/alertscripts

vim sendmail.sh

 

 

#!/bin/bash

# author:wei

to=$1

subject=$2

body=$3

[email protected]

smtp=smtp.qq.com

passwd=zoyswlqfhxhricdf #qq郵箱的兌換碼

/usr/local/bin/sendEmail -f "$from" -t "$to" -s "$smtp" -u "$subject" -o message-content-type=html -o tls=no message-charset=utf8 -xu "$from" -xp "$passwd" -m "$body"

chmod +x sendmail.sh

chown zabbix.zabbix sendmail.sh

測試郵件傳送

sh sendmail.sh [email protected] "hello world" "新.一天"