微信企业号报警脚本:
#!/bin/bash
CropID=''#企业号id
Secret=''#企业号管理密码
GURL="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CropID&corpsecret=$Secret"
Gtoken=$(/usr/bin/curl -s -G $GURL|awk -F\" '{print$10}' )
PURL="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$Gtoken"
function body() {
local int AppID=1
local UserID=$1
local PartyID=1
local Msg=$(echo "$@" | cut -d" "-f3-)
printf '{\n'
printf '\t"touser":"'"$UserID"\"",\n" #联系人人id
printf '\t"toparty": "1",\n' #联系人部门id
printf '\t"totag": "1",\n'
printf '\t"msgtype": "text",\n'
printf '\t"agentid":"'"$AppID"\"",\n" #应用id
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
钉钉报警脚本:
#!/bin/bash
Gtoken="https://oapi.dingtalk.com/robot/send?access_token=0f2d4ab13bcf17b55b403862463215970f1286702ecccdc0d01a60ddddddd"#钉钉号接口
function test(){
printf '{'
printf '"msgtype":"text",'
printf '"text":{'
printf'"content":"'"$1"\"""
printf '}}'
}
Text="$(test $1)"
Json="Content-Type:application/json"
/usr/bin/curl $Gtoken -H $Json -d $Text
#/usr/bin/curl --data-ascii $Text $Gtoken
来源:CSDN
作者:有个大2B
链接:https://blog.csdn.net/hzx1464138068/article/details/78212581