查看bm-cdn当前状态

查看bm-cdn当前状态

#!/bin/bash
# Author : royoy
# Ver    : v2 
# Date   : 10/2019

salt_bin=/bin/salt
cdn_node=${1:-front_web}
exec_script=scripts/examine_cdn_domainName.sh
cdn_conf=/data/shell/cdn_config/cdn_domainName.property
local_domainName=`awk -F= '/^domainName/{print $2;exit}' $cdn_conf`

font -b -srw 20 "主机" -srw 28 "前缀" -srw 17 "三目" -t -t -f 4 " " -slw 4 "域名" -srw 25 "状态" -n
$salt_bin -N $cdn_node cmd.script salt://$exec_script check_info |sed -n '/bm/{h;:z;n;/stdout:/!bz;{n;H;g;s/\n//;p}}' | awk -F'[ |=>|?]+' '{print $1,$2,$3,$4}' |sort | while read host prefix value domainName
do
        if [ x$local_domainName != x`echo $domainName | grep -Po '(?<=https://)[^/]+'` ];then color1=-cyan;color2=-red;else color1="";color2="";fi
        if [[ ! "$prefix" =~ "//" ]] && [ "$value" -eq 1 ];then
                font -srw 30 "$host" -srw 20 "$prefix" -grw 8 "$value" -t -slw 35 "$domainName" -green -srw 4 "开启" -r -n
        else
                font $color1 -srw 30 "$host" -r -srw 20 "$prefix" -grw 8 "$value" -t $color2 -slw 35 "$domainName" -r -red -srw 4 "关闭" -r -n
        fi
done