企微告警代码
因为server端不能联网,所以需要squid代理
网络要求:
server端能够访问squid代理服务的3128端口,单向即可。
squid代理能够访问外网企微。
在下述代码中涉及curl的位置加上参数 -x ip:port 指定代理即可。
#!/bin/bash
#
CorpID="ww537eed578cbd61bfb1" #我的企业下面的CorpID
Secret="urGuMdY8lvn9xATfvdZdJ6tmnkxsL7X0FpMDljN2220Gg" #创建的应用那有Secret
GURL="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CorpID&corpsecret=$Secret"
Token=$(/usr/bin/curl -x 192.168.111.22:3128 -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=1000002 #改为AgentId 在创建的应用那里看
local UserID=$XuFeiFei #发送的用户位于$1的字符串
local PartyID=1 #第一步看的通讯录中的部门ID
local Msg=$(echo &