天天看点

zabbix微信报警设置

第一步:申请企业微信应用

申请后需要记住申请的三个参数(CorpID、Secret、AgentId )

第二步:放置脚本在/usr/lib/zabbix/alertscripts文件夹下,脚本内容如下

[[email protected] alertscripts] # cat Email.weixin.sh

#!/bin/bash

CorpID=‘ww685aa8e14a1dbc9d’ #我的企业下面的CorpID

Secret=‘zA0KVMhYplLLnIFLKz8myrbqT0Q5H73OEszRjzE35io’ #创建的应用那有Secret

GURL=“https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=KaTeX parse error: Expected 'EOF', got '&' at position 7: CorpID&̲corpsecret=Secret”

Token=$(/usr/bin/curl -s -G $GURL |awk -F": ‘{print $4}’ |awk -F" ‘{print $2}’)

#echo T o k e n P U R L = " h t t p s : / / q y a p i . w e i x i n . q q . c o m / c g i − b i n / m e s s a g e / s e n d ? a c c e s s t o k e n = Token PURL="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token= TokenPURL="https://qyapi.weixin.qq.com/cgi−bin/message/send?accesst​oken=Token"

function body(){

local int agentid=1000002 #改为AgentId 在创建的应用那里看

local UserID=“XXXXXXX” #发送的用户位于KaTeX parse error: Expected 'EOF', got '#' at position 42: …D=2 #̲第一步看的通讯录中的部门ID …(echo “KaTeX parse error: Undefined control sequence: \n at position 39: … printf '{\̲n̲' print…UserID”"",\n"

printf ‘\t"toparty": "’“KaTeX parse error: Can't use function '\"' in math mode at position 9: PartyID"\̲"̲",\n" p…agentid”"",\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

第三步:脚本编写完成之后需要为脚本添加执行权限

[[email protected] alertscripts] # chmod 777 Email.weixin.sh

第四步:在web界面添加报警媒介类型

zabbix微信报警设置

第五步:关联用户报警

zabbix微信报警设置

第六步:设置关联动作

zabbix微信报警设置

此操作与邮件报警添加相同(一个是添加邮箱报警,一个是添加邮件报警)

继续阅读