加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

shell脚本实现企业微信报警

发布时间:2020-12-15 22:56:40 所属栏目:安全 来源:网络整理
导读:function sendmsg() { CorpID="ww3c6298264d839e2f" Secret="YvyMQpMRIoXtdQRWo0RNkMBTZnHWKvBwC3ILkyuCsKQ" agentid=1000002 GURL="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CorpIDcorpsecret=$Secret" Gtoken=$(/usr/bin/curl -s -G $GURL|a
function sendmsg() {

CorpID="ww3c6298264d839e2f"
Secret="YvyMQpMRIoXtdQRWo0RNkMBTZnHWKvBwC3ILkyuCsKQ"
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}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读