shell实现微信报警

第一步:
注册企业微信,登录后台。
地址:https://work.weixin.qq.com/wework_admin/register_wx?from=loginpage
技术分享图片
技术分享图片
二. 添加子部门,添加成员
技术分享图片
技术分享图片
三. 创建应用
技术分享图片
技术分享图片
技术分享图片
四.获取企业ID、部门ID、应用ID、安全码
技术分享图片
技术分享图片
技术分享图片
五、编写脚本
Function sendmag(){
CorpID="wwa0834289c96787e1"
Secret="dN1wAk5ZxFwFlEmVwGtdjsc9T8p6IAocZ6daoxIPMz4"
agentid=1000002

GURL="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CorpID&corpsecret=$Secret"
Gtoken=$(/usr/bin/curl -s -G $GURL|awk -F" ‘{print $10}‘)

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

Ip=$(ip a |grep ens33 |grep inet|awk -F "/" ‘{ print $1 }‘ |awk -F " " ‘{ print $2 }‘)

/usr/bin/curl --data-ascii ‘{
"touser": "@all",
"toparty": "2",
"msgtype": "text",
"agentid": "1000002",
"text": {"content": "‘"警告:[$msg]n主机:[uname -n]n日期:[$(date +%F-%T)]n地址:[$Ip]"‘"},
"safe":"0"

}‘ $PURL >/dev/null 2>&1
}
a=100
b=200
mag="web is down"
if [ $a -lt $b ]
then sendmsg
fi

六。测试
技术分享图片

shell实现微信报警

原文:https://blog.51cto.com/14241151/2363346

以上是shell实现微信报警的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>