金笛后花园

金笛工业手机官方博客

金笛只为您,一切全为您

CentOS 7.2 Zabbix 2.8 + 微信、邮件、短信猫等报警

转载 http://www.codexiu.cn/linux/blog/11726/

1、邮件的脚本

#!/bin/bash
SMTP_server=’smtp.126.com’
username=’xxxxx’
password=’xxxxx’to_email_address=”$1″
message_subject_utf8=”$2″
message_body_utf8=”$3″
message_subject_gb2312=`iconv -t GB2312 -f UTF-8 << EOF
$message_subject_utf8
EOF`
[ $? -eq 0 ] && message_subject=”$message_subject_gb2312″ || message_subject=”$message_subject_utf8″
message_body_gb2312=`iconv -t GB2312 -f UTF-8 << EOF
$message_body_utf8
EOF`
[ $? -eq 0 ] && message_body=”$message_body_gb2312″ || message_body=”$message_body_utf8″
sendEmail=’/usr/local/bin/sendEmail’
$sendEmail -s “$SMTP_server” -xu “$username” -xp “$password” -f “$from_email_address” -t “$to_email_address” -u “$message_subject” -m “$message_body” -o message-content-type=text -o message-charset=gb2312

2、短信猫的脚本、测试使用金笛短信猫硬件
#!/bin/bash
#SMS with gnokii
PATH=/bin:/sbin/:/usr/bin:/usr/sbin:/usr/local/bin/:/usr/local/gnokii/bin/
export.UTF-8
LOGFILE=’/tmp/zabbix_sms.log’
DT=$(date +%F’ ‘%T)
echo “***************************START:$DT************************************” >> $LOGFILE
echo ‘Recipient=’$1” >> $LOGFILE
echo ‘Subject=’$2” >> $LOGFILE
echo ‘Message=’$3” >> $LOGFILE
echo “ >> $LOGFILE
MOBILE_NUMBER=`echo “$1″`
# Log it
echo ‘Send Command:’ >> $LOGFILE
echo ‘echo $3 | gnokii –sendsms $MOBILE_NUMBER ‘ >> $LOGFILE
echo “ >> $LOGFILE
# Send it
echo ‘Sending Process:’ >> $LOGFILE
echo “$3″ | gnokii –sendsms “$MOBILE_NUMBER” 1>>$LOGFILE 2>&1
#EOF
DT=$(date +%F’ ‘%T)
echo “***************************STOP:$DT************************************” >> $LOGFILE
echo -e ‘\n’ >> $LOGFILE

 

2018/04/24 0 / /
标签:  暂无标签

7 + 3 =

回到顶部