I know I am a bit late, but I was on vacation and I figured I should spend time with my family rather than the computer. Sorry
Anyway, I was looking for something like this back in November and came up short, but I ended up finding a script on an
Ubuntu forum by Lance Rushing to check download times for Ubuntu mirrors. His originally tried to time the download, but it didn't seem to provide accurate results, so I ended up modifying it to grab the speed of the download, format it with numfmt (for those of you who remember, this is where I found how to use numfmt, which Pat then incorporated into the installer to determine partition sizes), and then sort the results by speed. If the speeds come in at under 10KiBps, I consider the mirror as a failure as it is likely downloading an index.html file and the mirror is currently not active (not perfect, but pretty accurate in my testing).
I had originally intended on doing some more cleanup of the code before I posted, but I can do that later. I did some cleaning tonight and added colors for the failure and speed to make them more distinguishable while testing. The results are cleanly formatted and sorted by speed. .
The default list of servers in the script are just the US-based servers I grabbed out of /etc/slackpkg/mirrors. You can change them as needed for your location. But I figured it was better to try and limit how many mirrors it will attempt to ensure you're not sitting for 30 minutes as it checks all the servers, but if you want all of them, feel free
PHP Code:
#!/bin/bash
# mirror_test.sh
# Originally written for Ubuntu by Lance Rushing <lance_rushing@hotmail.com>
# Dated 9/1/2006
# Taken from http://ubuntuforums.org/showthread.php?t=251398
# This script is covered under the GNU Public License: http://www.gnu.org/licenses/gpl.txt
# Modified for Slackware by Jeremy Brent Hansen <jebrhansen -at- gmail.com>
# Modified 2015/11/06
# Add or change mirrors from /etc/slackpkg/mirrors as desired (these are the US mirrors)
MIRRORS="ftp://carroll.aset.psu.edu/pub/linux/distributions/slackware/slackware64-current/
http://carroll.aset.psu.edu/pub/linux/distributions/slackware/slackware64-current/
ftp://ftp.gtlib.gatech.edu/nv/ao2/lxmirror/ftp.slackware.com/slackware64-current/
ftp://ftp.osuosl.org/.2/slackware/slackware64-current/
http://ftp.osuosl.org/.2/slackware/slackware64-current/
ftp://hpc-mirror.usc.edu/pub/linux/distributions/slackware/slackware64-current/
http://hpc-mirror.usc.edu/pub/linux/distributions/slackware/slackware64-current/
ftp://marmot.tn.utexas.edu/pub/slackware/slackware64-current/
http://marmot.tn.utexas.edu/slackware/slackware64-current/
ftp://mirror.cs.princeton.edu/pub/mirrors/slackware/slackware64-current/
http://mirror.metrocast.net/slackware/slackware64-current/
ftp://mirrors.easynews.com/linux/slackware/slackware64-current/
http://mirrors.easynews.com/linux/slackware/slackware64-current/
http://mirrors.kingrst.com/slackware/slackware64-current/
ftp://mirrors.us.kernel.org/slackware/slackware64-current/
http://mirrors.us.kernel.org/slackware/slackware64-current/
ftp://mirrors.xmission.com/slackware/slackware64-current/
http://mirrors.xmission.com/slackware/slackware64-current/
http://slackbuilds.org/mirror/slackware/slackware64-current/
http://slackware.cs.utah.edu/pub/slackware/slackware64-current/
http://slackware.mirrorcatalogs.com/slackware64-current/
http://slackware.mirrors.pair.com/slackware64-current/
ftp://slackware.mirrors.tds.net/pub/slackware/slackware64-current/
http://slackware.mirrors.tds.net/pub/slackware/slackware64-current/
ftp://slackware.virginmedia.com/mirrors/ftp.slackware.com/slackware64-current/
http://slackware.virginmedia.com/slackware64-current/
ftp://spout.ussg.indiana.edu/linux/slackware/slackware64-current/
http://spout.ussg.indiana.edu/linux/slackware/slackware64-current/
ftp://teewurst.cc.columbia.edu/pub/linux/slackware/slackware64-current/
http://teewurst.cc.columbia.edu/pub/linux/slackware/slackware64-current/"
# Use any adequetly sized file to test the speed. This is ~7MB.
# The location should be based on the relative location within
# the slackware64-current tree. I originally tried a smaller
# file (FILELIST.TXT ~1MB), but I was seeing slower speed results
# since it didn't have time to fully max my connection. Depending
# on your internet speed, you may want to try different sized files.
FILE="kernels/huge.s/bzImage"
# Number of seconds before the test is considered a failure
TIMEOUT="5"
# String to store results in
RESULTS=""
# Set color variables to make results and echo statements cleaner
RED="\e[31m"
GREEN="\e[32m"
NC="\e[0m" #No color
for MIRROR in $MIRRORS ; do
echo -n "Testing ${MIRROR} "
URL="${MIRROR}${FILE}"
SPEED=$(curl --max-time $TIMEOUT --silent --output /dev/null --write-out %{speed_download} $URL)
if (( $(echo "$SPEED < 10000.000" | bc -l) )) ; then
echo -e "${RED}Fail${NC}";
else
SPEED="$(numfmt --to=iec-i --suffix=B --padding=7 $SPEED)ps"
echo -e "${GREEN}$SPEED${NC}"
RESULTS="${RESULTS}\t${SPEED}\t${MIRROR}\n";
fi
done;
echo -e "\nResults:"
echo -e $RESULTS | sort -hr
The results would look like:
Code:
jbhansen@dead-therapist:~$ sh mirror_test.sh
Testing ftp://carroll.aset.psu.edu/pub/linux/distributions/slackware/slackware64-current/ Fail
Testing http://carroll.aset.psu.edu/pub/linux/distributions/slackware/slackware64-current/ Fail
Testing ftp://ftp.gtlib.gatech.edu/nv/ao2/lxmirror/ftp.slackware.com/slackware64-current/ Fail
Testing ftp://ftp.osuosl.org/.2/slackware/slackware64-current/ 1.9MiBps
Testing http://ftp.osuosl.org/.2/slackware/slackware64-current/ 3.8MiBps
Testing ftp://hpc-mirror.usc.edu/pub/linux/distributions/slackware/slackware64-current/ Fail
Testing http://hpc-mirror.usc.edu/pub/linux/distributions/slackware/slackware64-current/ Fail
Testing ftp://marmot.tn.utexas.edu/pub/slackware/slackware64-current/ 3.2MiBps
Testing http://marmot.tn.utexas.edu/slackware/slackware64-current/ 4.8MiBps
Testing ftp://mirror.cs.princeton.edu/pub/mirrors/slackware/slackware64-current/ 1.4MiBps
Testing http://mirror.metrocast.net/slackware/slackware64-current/ 299KiBps
Testing ftp://mirrors.easynews.com/linux/slackware/slackware64-current/ 2.2MiBps
Testing http://mirrors.easynews.com/linux/slackware/slackware64-current/ 3.6MiBps
Testing http://mirrors.kingrst.com/slackware/slackware64-current/ 6.2MiBps
Testing ftp://mirrors.us.kernel.org/slackware/slackware64-current/ 2.3MiBps
Testing http://mirrors.us.kernel.org/slackware/slackware64-current/ 2.4MiBps
Testing ftp://mirrors.xmission.com/slackware/slackware64-current/ 2.0MiBps
Testing http://mirrors.xmission.com/slackware/slackware64-current/ 4.5MiBps
Testing http://slackbuilds.org/mirror/slackware/slackware64-current/ 5.0MiBps
Testing http://slackware.cs.utah.edu/pub/slackware/slackware64-current/ 2.0MiBps
Testing http://slackware.mirrorcatalogs.com/slackware64-current/ Fail
Testing http://slackware.mirrors.pair.com/slackware64-current/ 5.9MiBps
Testing ftp://slackware.mirrors.tds.net/pub/slackware/slackware64-current/ 4.5MiBps
Testing http://slackware.mirrors.tds.net/pub/slackware/slackware64-current/ 6.9MiBps
Testing ftp://slackware.virginmedia.com/mirrors/ftp.slackware.com/slackware64-current/ Fail
Testing http://slackware.virginmedia.com/slackware64-current/ Fail
Testing ftp://spout.ussg.indiana.edu/linux/slackware/slackware64-current/ 3.2MiBps
Testing http://spout.ussg.indiana.edu/linux/slackware/slackware64-current/ 999KiBps
Testing ftp://teewurst.cc.columbia.edu/pub/linux/slackware/slackware64-current/ 197KiBps
Testing http://teewurst.cc.columbia.edu/pub/linux/slackware/slackware64-current/ 235KiBps
Results:
6.9MiBps http://slackware.mirrors.tds.net/pub/slackware/slackware64-current/
6.2MiBps http://mirrors.kingrst.com/slackware/slackware64-current/
5.9MiBps http://slackware.mirrors.pair.com/slackware64-current/
5.0MiBps http://slackbuilds.org/mirror/slackware/slackware64-current/
4.8MiBps http://marmot.tn.utexas.edu/slackware/slackware64-current/
4.5MiBps http://mirrors.xmission.com/slackware/slackware64-current/
4.5MiBps ftp://slackware.mirrors.tds.net/pub/slackware/slackware64-current/
3.8MiBps http://ftp.osuosl.org/.2/slackware/slackware64-current/
3.6MiBps http://mirrors.easynews.com/linux/slackware/slackware64-current/
3.2MiBps ftp://spout.ussg.indiana.edu/linux/slackware/slackware64-current/
3.2MiBps ftp://marmot.tn.utexas.edu/pub/slackware/slackware64-current/
2.4MiBps http://mirrors.us.kernel.org/slackware/slackware64-current/
2.3MiBps ftp://mirrors.us.kernel.org/slackware/slackware64-current/
2.2MiBps ftp://mirrors.easynews.com/linux/slackware/slackware64-current/
2.0MiBps http://slackware.cs.utah.edu/pub/slackware/slackware64-current/
2.0MiBps ftp://mirrors.xmission.com/slackware/slackware64-current/
1.9MiBps ftp://ftp.osuosl.org/.2/slackware/slackware64-current/
1.4MiBps ftp://mirror.cs.princeton.edu/pub/mirrors/slackware/slackware64-current/
999KiBps http://spout.ussg.indiana.edu/linux/slackware/slackware64-current/
299KiBps http://mirror.metrocast.net/slackware/slackware64-current/
235KiBps http://teewurst.cc.columbia.edu/pub/linux/slackware/slackware64-current/
197KiBps ftp://teewurst.cc.columbia.edu/pub/linux/slackware/slackware64-current/