Created
August 17, 2015 00:37
-
-
Save nad2000/e346cda2959327df1b9e to your computer and use it in GitHub Desktop.
This script tests a list of Apache mirrors for speed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# mirror_test.sh | |
# This script tests a list of Apache mirrors for speed | |
# | |
# The scrip is based on Lance Rushing's <lance_rushing AT hotmail DOT com> script | |
# http://ubuntuforums.org/showthread.php?t=251398 for Ubutnu mirrors | |
# | |
# This script is covered under the GNU Public License: http://www.gnu.org/licenses/gpl.txt | |
# @AUTHOR Rad Cirskis <nad2000 AT gmail DOT com> | |
# @SINCE 8/1/2015 | |
# | |
FILE=cassandra/2.2.0/apache-cassandra-2.2.0-bin.tar.gz | |
MIRRORS=$(curl "http://www.apache.org/dyn/closer.cgi?path=${FILE}&as_json=1" | grep -oE "((http|ftp):[^\"]*)" | |
) | |
## Number of seconds before the test is considered a failure | |
TIMEOUT="5" | |
## Sting to store results in | |
RESULTS="" | |
for MIRROR in $MIRRORS ; do | |
echo -n "Testing ${MIRROR} " | |
URL="${MIRROR}%{FILE}" | |
TIME=`curl --max-time $TIMEOUT --silent --output /dev/null --write-out %{time_total} $URL` | |
if [ "$TIME" == "0.000" ] ; then | |
echo $URL | |
echo "Fail"; | |
else | |
echo $TIME | |
RESULTS="${RESULTS}${TIME}\t${MIRROR}\n"; | |
fi | |
done; | |
echo "\nResults:" | |
echo -e $RESULTS | sort -n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment