Skip to content

Instantly share code, notes, and snippets.

@yuinore
Created December 12, 2017 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuinore/16b5b0249f3b627cc52c755ac8c01a32 to your computer and use it in GitHub Desktop.
Save yuinore/16b5b0249f3b627cc52c755ac8c01a32 to your computer and use it in GitHub Desktop.
#!/bin/bash
start_time=$(date '+%Y/%m/%d %H:%M:%S.%3N')
postfix="7.4.1708/dotnet/x86_64/Packages/rh-dotnet20-clang-3.9.1-3.el7.x86_64.rpm"
url_list=$(cat centos_mirror_pickup.txt | tr -d '\r' | grep -ioP 'https?://.+' | awk "{print \$0 \"$postfix\"}")
stat_param="%{http_code},%{time_total},%{time_connect},%{time_appconnect},%{time_pretransfer},%{speed_download},%{size_download},%{url_effective}"
for url in $url_list; do
echo $url
current_time=$(date '+%Y/%m/%d %H:%M:%S.%3N')
randnum=$(date '+%Y%m%d%H%M%S%3N')
statistics=$(curl -L "$url?rand=$randnum" -o /dev/null -w $stat_param);
echo "$start_time,$current_time,direct,$statistics,$url" | tee -a statistics.csv;
current_time=$(date '+%Y/%m/%d %H:%M:%S.%3N')
randnum=$(date '+%Y%m%d%H%M%S%3N')
statistics=$(curl -x proxy.example.com:800080 -L "$url?rand=$randnum" -o /dev/null -w $stat_param);
echo "$start_time,$current_time,proxy,$statistics,$url" | tee -a statistics.csv;
current_time=$(date '+%Y/%m/%d %H:%M:%S.%3N')
randnum=$(date '+%Y%m%d%H%M%S%3N')
statistics=$(ssh username@proxy.example.com -i ~/20170832000000.pem -p 222222 curl -L "$url?rand=$randnum" -o /dev/null -w $stat_param);
echo "$start_time,$current_time,proxy_to_remote,$statistics,$url" | tee -a statistics.csv;
current_time=$(date '+%Y/%m/%d %H:%M:%S.%3N')
randnum=$(date '+%Y%m%d%H%M%S%3N')
statistics=$(curl -L "http://proxy.example.com/$postfix?rand=$randnum" -o /dev/null -w $stat_param);
echo "$start_time,$current_time,local_to_proxy,$statistics,$url" | tee -a statistics.csv;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment