#!/bin/bash
# 查询主播汇总信息
# author caozhi,last update on 2017-10-20,16:16:16
# version:1.0
# value: 0:正常;
# 1:servant-openapi 接口错误;
# 5:dashboard接口error;
# 9:获取的stramname 超过10次wget fail
function post_curl () {
curl -X POST -d "[{\"metric\": \"$metric\", \"endpoint\": \"$endpoint\", \"timestamp\": $ts,\"step\": 600,\"value\": $value,\"counterType\": \"GAUGE\",\"tags\": \"\"}]" http://127.0.0.1:1988/v1/push
}
i=1
whether=1
until [ $whether -eq 0 ]
do
[ $i -ge 10 ] && value=9 && post_curl && exit 1
curl -o /home/caozhi/result --connect-timeout 5 --retry 2 -m 5 -s "http://haha.enen.cdn.com/v2/stat" -w "http_code=%{http_code}" | grep "http_code=200"
[ $? -ne 0 ] && value=5 post_curl && exit 1
stramname=`head -c 1024 /home/caozhi/result | grep -Eio "\"[^\"]*?\":\{\"address" | awk -F '"' '{print $2}' | sed 's/_mid//g' | grep -Ev 20170424 |tail -n 1`
wget -SO /dev/null --spider "http://flv15.haha.tv/live/$stramname.flv" 2>&1 | grep "HTTP/1.1 200 OK"
[ $? -eq 0 ] && whether=0 || whether=1
let i++
done
cat > /home/caozhi/emmby/jsqm.json <<-EOF
{
"UniqueName":"haha",
"App":"live",
"Stream":"$stramname"
}
EOF
curl -X POST -o /home/caozhi/StreamsInfo --connect-timeout 6 --retry 3 -m 10 -s "http://10.66.96.107:8881/app/2017-01-01" -d @/home/caozhi/emmby/jsqm.json
grep '"RetCode":0' /home/caozhi/StreamsInfo
cat /home/caozhi/StreamsInfo;echo
[ $? -eq 0 ] && value=`echo 0` || value=`echo 1`
post_curl
rm -f /home/caozhi/StreamsInfo
rm -f /home/caozhi/result
rm -f /home/caozhi/emmby/jsqm.json
穿透监控-查询主播汇总信息接口
猜你喜欢
转载自blog.csdn.net/xiaozhiit/article/details/78370638
今日推荐
周排行