sendmail 发送邮件 zabbix 自定义报警

配合zabbix 触发脚本 达到自定义报警目的

#!/bin/bash
# Created : 2015.12.08
# Updated : 2015.12.08
# Author : sanmuyan
# Description : send_mail_to_jason_where_overdue.sh


SMTP_server='mail.qq.com:465'    # SMTP服务器,变量值需要自行修改
username='support@qq.com'     # 用户名,变量值需要自行修改
password='123'             # 密码,变量值需要自行修改
from_email_address='support@qq.com' # 发件人Email地址,变量值需要自行修改
to_email_address=yong.zhou@qq.com,sen.zhang@qq.com
mail_content_path='/etc/zabbix/scripts/data/box_disk_80.txt'  #邮件正文


# Get data by quering the script #


echo "-------------------------------------------------" >>$mail_content_path
echo "List of hard disk usage exceeding 80%" >>$mail_content_path
echo "-------------------------------------------------" >>$mail_content_path

# 发送邮件
sendEmail='/usr/local/bin/sendEmail'
set -x
if [ `cat $mail_content_path | wc -l` -gt 3 ];
then
$sendEmail -s "$SMTP_server" -xu "$username" -xp "$password" -f "$from_email_address" -t "$to_email_address" -u "Box-Free-Space-Alarm"  -m -o message-content-type=text -o message-charset=utf8 -o tls=auto -o message-file=$mail_content_path
fi    

  

posted @ 2017-06-29 17:52  三木燕  阅读(320)  评论(0编辑  收藏  举报