zabbix系列之十——添加短信告警

zabbix添加短信告警

1、查看zabbix-server脚本存放路径:

[root@GYQ-Prod-Zabbix ~]# grep AlertScriptsPath /etc/zabbix/zabbix_server.conf
### Option: AlertScriptsPath
# AlertScriptsPath=${datadir}/zabbix/alertscripts
AlertScriptsPath=/usr/lib/zabbix/alertscripts

 2、在这个路径下新建名为sendSMS.sh告警脚本:

[root@GYQ-Prod-Zabbix alertscripts]# cat sendSMS.sh 
#!/bin/bash

# 脚本的日志文件
LOGFILE="/var/log/zabbix/sms.log"
:>"$LOGFILE"
exec 1>"$LOGFILE"
exec 2>&1


# 手机号码
MOBILE_NUMBER=$1
# 短信内容
MESSAGE_UTF8=$2
XXD="/usr/bin/xxd"
CURL="/usr/bin/curl"
TIMEOUT=5

# 短信内容要经过URL编码处理,除了下面这种方法,也可以用curl的--data-urlencode选项实现。
MESSAGE_ENCODE=$(echo "$MESSAGE_UTF8" | ${XXD} -ps | sed 's/\(..\)/%\1/g' | tr -d '\n')

URL="http://10.90.2.118:7003/dps_mi/smsCommon.do?responseFormat=JSON&smsRecipient=${MOBILE_NUMBER}&smsText=${MESSAGE_ENCODE}"

# Send it
set -x
${CURL} -s --connect-timeout ${TIMEOUT} "${URL}"

 3、添加zabbix服务端报警媒介

4、添加users

5、添加action

 6、结果

 

 

 



posted @ 2019-01-27 10:19  西门运维  阅读(757)  评论(1编辑  收藏  举报