經過shell腳本配置經過微信進行告警方式發送:shell
1、在zabbix的發送告警的的目錄下新建sendWebChat.shvim
cd /usr/lib/zabbix/alertscriptsapi
vim sendWeChat.sh
bash
2、腳本內容(須要企業號的CropID和Secret)微信
#!/bin/bashcurl
# Filename: sendWeChat.sh
# Revision: 1.0
# Date: 2015/09/08
# Author: Json
# Description: zabbix微信告警腳本
# Notes: WeCaht告警
#
CropID=企業號的CropIDide
Secret=企業號的Secreturl
GURL="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CropID&corpsecret=$Secret"
Gtoken=$(/usr/bin/curl -s -G $GURL | awk -F\" '{print $4}')
PURL="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$Gtoken"
Content=$3spa
/usr/bin/curl --data-ascii '{ "touser": "@all", "toparty": " @all ","msgtype": "text","agentid": "1","text": {"content": "'${Content}'"},"safe":"0"}' $PURLorm