zabbix搭建微信报警

https://www.cnblogs.com/LuckWJL/p/9076510.html

#!/bin/bash
#set -x
#运维工程师 王初一
CorpID= "********"                    #我的企业下面的CorpID
Secret= "***************"             #创建的应用那有Secret
GURL= "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CorpID&corpsecret=$Secret"
Token=$( /usr/bin/curl  -s -G $GURL | awk  -F\":  '{print $4}' | awk  -F\"  '{print $2}' )
#echo $Token
PURL= "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$Token"
 
function  body(){
         local  int agentid=1000066    #改为AgentId 在创建的应用那里看
         local  UserID=$1              #发送的用户位于$1的字符串
         local  PartyID=35             #第一步看的通讯录中的部门ID
         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": "' "$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
测试 bash wechat.sh WangJinLong 告警测试 注意这是一条告警测试信息

转载于:https://www.cnblogs.com/lovedairan/p/11358039.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值