shell监控脚本-监控CDN 首页
#!/bin/bash
cdnstatus=$(echo "http://$/cdninfo.json" | nc -v)
CDN_VERSION=$(jq -r ".latest.cdnName" <<< $cdnstatus | cut -d '}' -f 2)
CDN_STATUS=$(echo $cdnstatus | jq -r ".status")
case $CDN_STATUS in
"0")
CDN_ERROR="CDN 健康检查失败,状态信息:"
CDN_ERROR+="状态码:"
CDN_ERROR+=$(echo $cdnstatus | jq -r ".errorcode")
CDN_ERROR+="错误信息:"
CDN_ERROR+=$(echo $cdnstatus | jq -r . | jq -r ".error | join('')")
CDN_ERROR+=""
echo "$"
;;
*)
CDN_LOGFILE="/tmp/cdn.log"
mkdir -p $(dirname $CDN_LOGFILE)
echo $CDN_VERSION >> $CDN_LOGFILE
cat $CDN_LOGFILE >> CDN_VERSION
echo "CDN 健康检查通过,状态信息:" >> CDN_LOGFILE
echo "版本:$" >> CDN_LOGFILE
fi
领取专属 10元无门槛券
手把手带您无忧上云