Zabbix-3.2.6部署微信报警

1、准备数据

企业微信的:CorpID

企业应用的:AgentId

企业应用的:Secret

接收消息的部门ID

2、创建企业应用并设置好权限

3、微信接口调试工具网址

http://work.weixin.qq.com/api/devtools/devtool.php

4、准备报警脚本

vim /application/zabbix/scripts/weixin.sh

#!/bin/bash

CropID='  '

Secret='  '

 

GURL="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CropID&corpsecret=$Secret"

Gtoken=$(/usr/bin/curl -s -G $GURL)

a=`echo $Gtoken |awk -F ':"' '{print $3}'`

token=`echo $a |awk -F '".' '{print $1}'`

PURL="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$token"

 

function body() {

local int AppID=

local UserID=$1

local PartyID=

local Msg=$(echo "$@" | cut -d " " -f3-)

printf '{n'

printf 't"touser": "'"$UserID""",n"

printf 't"toparty": "'"$PartyID""",n"

printf 't"msgtype": "text",n'

printf 't"agentid": "'"$AppID """,n"

printf 't"text": {n'

printf 'tt"content": "'"$Msg"""n"

printf 't"},n'

printf 't"safe:":0n'

printf '}n'

}

/usr/bin/curl --data-ascii "$(body $1 $2 $3)" $PURL

5、脚本权限设置

chown zabbix.zabbix weixin.sh

chmod +x weixin.sh

6、测试脚本的可用性

bash weixin.sh "ChenShuiTao" "test" "hello world"

说明:ChenShuiTao是企业微信用户的帐号、test为发送的标题、hello world为发送的内容

技术分享图片


7、在Web管理页面创建媒体类型

技术分享图片


8、为Admin用户添加新创建的报警媒体

技术分享图片


9、创建动作并测试

技术分享图片




Zabbix-3.2.6部署微信报警

原文:http://blog.51cto.com/12098963/2092763

以上是Zabbix-3.2.6部署微信报警的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>