zabbix3.0自定义告警配置
2016-06-24 15:15 magnes 阅读(244) 评论(0) 编辑 收藏 举报与zabbix2.4.7版本不同,zabbix3.0自定义消息配置需要加参数,如下图所示:
这样方可实现告警信息的发送。
以下为一个经测试可用的微信告警的脚本:
CropID='' 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" function body() { local int AppID=1 local UserID=$1 local PartyID=1 local Msg=$(echo "$@" | cut -d" " -f3-) printf '{\n' printf '\t"touser": "'"$User"\"",\n" printf '\t"toparty": "'"$PartyID"\"",\n" printf '\t"msgtype": "text",\n' printf '\t"agentid": "'" $AppID "\"",\n" printf '\t"text": {\n' printf '\t\t"content": "'"$Msg"\""\n" printf '\t},\n' printf '\t"safe":"0"\n' printf '}\n' } /usr/bin/curl --data-ascii "$(body $1 $2 $3)" $PURL