zabbix3.2邮件报警

1、sendEmail安装
cd /usr/local/src/
wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
yum install perl-Net-SSLeay perl-IO-Socket-SSL -y
tar -xvf sendEmail-v1.56.tar.gz 
cd sendEmail-v1.56/
cp -ra sendEmail /usr/local/bin/
chmod +x /usr/local/bin/sendEmail
ls -d /usr/local/bin/sendEmail

2、测试sendEmail
参数说明:
/usr/local/bin/sendEmail        命令主程序
-f from@163.com                 发件人邮箱
-t to@163.com                   收件人邮箱
-s smtp.163.com                 发件人邮箱的smtp服务器
-u "我是邮件主题"               邮件的标题
-o message-content-type=html    邮件内容的格式,html表示它是html格式
-o message-charset=utf8         邮件内容编码
-xu from@163.com                发件人邮箱的用户名
-xp 123456                      发件人邮箱密码
-m "我是邮件内容"               邮件的具体内容

/usr/local/bin/sendEmail -f test@qq.com -t test@qq.com -s test@qq.com -u "zabbxitest" -o message-content-type=html -o message-charset=utf8 -xu test@qq.com -xp 123456 -m "我是邮件内容"
3,zabbix自定义的指定目录
/usr/lib/zabbix/alertscripts/
默认是开启的
grep -n ^[a-Z] /etc/zabbix/zabbix_server.conf 
38:LogFile=/var/log/zabbix/zabbix_server.log
49:LogFileSize=0
72:PidFile=/var/run/zabbix/zabbix_server.pid
91:DBName=zabbix
107:DBUser=zabbix
115:DBPassword=xxxxx
287:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
413:Timeout=4
455:AlertScriptsPath=/usr/lib/zabbix/alertscripts
465:ExternalScripts=/usr/lib/zabbix/externalscripts
501:LogSlowQueries=3000

4、编辑发邮件脚本
cd /usr/lib/zabbix/alertscripts/
vim sendEmail.sh
#!/bin/bash
to=$1
subject=$2
body=$3
from=test@qq.com
smtp=smtp.qq.com
passwd=testpasswd
/usr/local/bin/sendEmail  -f "$from" -t "$to" -s "$smtp" -u "$subject" -o message-content-type=html -o message-charset=utf8 -xu "$from"  -xp "$passwd" -m "$body"

chmod +x sendEmail.sh
chown zabbix.zabbix sendEmail.sh



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值