zabbix微信报警设置

第一步:申请企业微信应用
申请后需要记住申请的三个参数(CorpID、Secret、AgentId )

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

[root@zabbix 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/cgibin/message/send?accesstoken=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

第三步:脚本编写完成之后需要为脚本添加执行权限
[root@zabbix alertscripts] # chmod 777 Email.weixin.sh

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

第五步:关联用户报警
在这里插入图片描述

第六步:设置关联动作
在这里插入图片描述
此操作与邮件报警添加相同(一个是添加邮箱报警,一个是添加邮件报警)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值