指令碼之CDN中,測試整個cache平臺nginx的https是否生效
read -p “domain: ” domain
read -p “url(except domain): ” url
read -p “reload or not ?(NEED reload please enter /”reload/”): ” reload
pingtai=dig $domain.cloudglb.com @8.8.8.8 |grep $domain.cloudglb.com|grep CNAME|awk '{print $5}'|awk -F '.' '{print $1"."$2}'
rm -f /work/caozhi/520/*
dev -p $pingtai > /work/caozhi/node.list
cd /work/caozhi/puppet_new/
svn update 2>&;1 >/dev/null
##### 批量執行reload
[ “$reload” = reload ] &;&; sudo pssh -x -p12321 -t 600 -h /work/caozhi/node.list -P “/etc/init.d/nginx reload” 2>&;1 >/dev/null
cermd5=md5sum /work/caozhi/puppet_new/modules/automatic/files/ssl/$pingtai/auto_$domain/(0/).* |awk '{print $1}'
keymd5=md5sum /work/caozhi/puppet_new/modules/automatic/files/ssl/$pingtai/auto_$domain/(1/).key |awk '{print $1}'
nginxmd5=md5sum /work/caozhi/puppet_new/modules/automatic/files/$pingtai/$domain.autoconf |awk '{print $1}'
#### 遍歷 autoconf cer key md5
sudo dev -l /work/caozhi/node.list –cmd “md5sum /opt/nginx/ssl/auto_domain/(0/).*/opt/nginx/ssl/auto_domain/(0/).* /opt/nginx/ssl/auto_domain(1).key /etc/nginx/conf.d/$domain.autoconf” 2>&;1 >/work/caozhi/520/resultconfigure
#### 校驗 nginx reload 時間
sudo dev -l /work/caozhi/node.list –cmd “ps aux |grep nginx |grep worker|grep -v shutting|awk ‘$1~/nginx/{print $9}’|sort -u” 2>&;1 > /work/caozhi/520/result
awk ‘{print $5}’ /work/caozhi/520/result|sort -u|sort -n|head > /work/caozhi/520/timestamp
###### 校驗 autoconf cer key md5
cat /work/caozhi/520/resultconfigure |awk ‘{if (NR % 3) printf 0;elseprint0;else print 0}’|grep “No such file or directory”|awk ‘{print 2,”/033[31mthisserverhasnoconfigure/033[0m”}’>/work/caozhi/520/error
cat/work/caozhi/520/resultconfigure|grep-v“Nosuchfileordirectory”|awk‘{if(NR%3)printf$0;elseprint$0}’|grep-v2,”/033[31m this server has no configure /033[0m”}’ > /work/caozhi/520/error
cat /work/caozhi/520/resultconfigure |grep -v “No such file or directory”|awk ‘{if (NR % 3) printf $0;else print $0}’|grep -v nginxmd5|awk '{print 2,”/033[31mthisserverhaserrorautoconf/033[0m”}’>>/work/caozhi/520/error
cat/work/caozhi/520/resultconfigure|grep-v“Nosuchfileordirectory”|awk‘{if(NR%3)printf$0;elseprint$0}’|grep-v2,”/033[31m this server has error autoconf /033[0m”}’ >> /work/caozhi/520/error
cat /work/caozhi/520/resultconfigure |grep -v “No such file or directory”|awk ‘{if (NR % 3) printf $0;else print $0}’|grep -v cermd5 |awk '{print 2,”/033[31mthisserverhaserrorcer/033[0m”}’>>/work/caozhi/520/error
cat/work/caozhi/520/resultconfigure|grep-v“Nosuchfileordirectory”|awk‘{if(NR%3)printf$0;elseprint$0}’|grep-v2,”/033[31m this server has error cer /033[0m”}’>> /work/caozhi/520/error
cat /work/caozhi/520/resultconfigure |grep -v “No such file or directory”|awk ‘{if (NR % 3) printf $0;else print $0}’|grep -v keymd5 |awk '{print $2,”/033[31m this server has error key /033[0m”}’>> /work/caozhi/520/error
cat /work/caozhi/520/error
grep . /work/caozhi/520/error
if [ $? -eq 0 ]
then
echo -e “/e[35;40;1mconfigure(autoconf,cer and key) is ERROR!!!/e[0m”
else
echo -e “/e[35;40;1mconfigure(autoconf,cer and key) is correct/e[0m”
fi
##### 遍歷校驗 https 訪問
for i in cat /work/caozhi/node.list
do
curl -I -o /dev/null -S -s https://i/i/url -H “Host:domain"−k−−retry−delay2−−connect−timeout10−m15−w"httpcode=domain" -k --retry-delay 2 --connect-timeout 10 -m 15 -w "http_code=%{http_code}"|awk -v tt="i” ‘1!~/200/{print1!~/200/{print 0,tt}’ 2>&;1 |tee -a /work/caozhi/520/http > /dev/null
done
grep . /work/caozhi/520/http
if [ $? -eq 0 ]
then
echo -e “/e[33;40;1mhttps is ERROR!!!/e[0m”
else
echo -e “/e[33;40;1mhttps is correct/e[0m”
fi
