大主播 上下線通知 程式

NO IMAGE

直播cdn 大主播頻寬突發很快,寫了 多個主播上下線的通知指令碼

#!/bin/bash
# 大主播上下線 通知
# author caozhi,completed on 2017-11-24,last update on 2017-12-03,16:16:16
# version:3.0
export PATH=/home/caozhi/ven_work/bin:/usr/local/java/bin:/usr/local/java/jre/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/ksyun/bin:/home/caozhi/bin
function dingding () {
curl -X POST "https://oapi.dingtalk.com/robot/send" -d @/home/abc.json -H 'Content-Type: application/json'
}
function json () {
cat > /home/abc.json <<-EOF
{
"msgtype": "text",
"text": {
"content": "$status"
},
"at": {
"atMobiles": [
"15888888888",
"18866666666"
],
"isAtAll": false
}
}
EOF
}
function check () {
/bin/grep "\b$name\b" /home/statu
if [[ $? -eq 0 ]]
then
status="$mes 上線了"
button=1
grep $button /home/last_status$name
if [[ $? -eq 0 ]]
then
continue
else
json
dingding
fi
else
status="$mes 下線了"
button=0
grep $button /home/last_status$name
if [[ $? -eq 0 ]]
then
continue
else
json
dingding
fi
fi
echo $button > /home/last_status$name
}
curl -s http://interface.com/v2/stat -w "http_code=%{http_code}" > /home/stat
curl -s http://interface.com/v2/stat -w "http_code=%{http_code}" >> /home/stat
num=$(/bin/grep "http_code=200" /home/stat | wc -l)
[ $num -ne 2 ] && status=dashboard_doesnt_work && dingding && exit 1
/bin/grep -Eio "\"[^\"]*?\":\{\"address" /home/stat | awk -F '"' '{print $2}'  > /home/statu
cat /home/statu
for mes in 主播1-2333 主播2-666 
do
name=`echo $mes | awk -F '-' '{print $2}'`
sleep 1
check
done