zabbix中通过shell脚本进行微信监控告警
通过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
本文出自 “PETER-疏狂少年” 博客,请务必保留此出处http://petervip.blog.51cto.com/3790959/1693335