通過shell腳本配置通過微信進行告警方式發送:
一、在zabbix的發送告警的的目錄下新建sendWebChat.sh
cd /usr/lib/zabbix/alertscripts
vim sendWeChat.sh
二、腳本內容(需要企業號的CropID和Secret)
#!/bin/bash
# Filename: sendWeChat.sh
# Revision: 1.0
# Date: 2015/09/08
# Author: Json
# Description: zabbix微信告警腳本
# Notes: WeCaht告警
#
CropID=企業號的CropID
Secret=企業號的Secret
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=$3
/usr/bin/curl --data-ascii '{ "touser": "@all", "toparty": " @all ","msgtype": "text","agentid": "1","text": {"content": "'${Content}'"},"safe":"0"}' $PURL