[last update 2014-11-14, before that 2013-7-29]
speedtest-cli new install script as the git repo changed for it alittle, also a little cool script to test local server and a few other servers and output results to screen and file.
HOW TO INSTALL SIMPLE WAY
sudo apt-get install git-core cd ~ git clone https://github.com/sivel/speedtest-cli.git
If get ssl error:
GIT_SSL_NO_VERIFY=true git clone https://github.com/sivel/speedtest-cli.git
The difference is that its not as deep nested now
cd speedtest-cli
Now to run script
./speedtest-cli.py
Now you are done, if you want to make this program permanent so its not sitting in your home folder. The best option is to move it to one of your PATH variablaes (linux constantly checks those when you type any command in to see if its there)
echo $PATH
I see that /usr/local/bin is one of my paths
cp ~/speedtest-cli/speedtest-cli /usr/local/bin
I dont need to chmod +x as this file already has all the right permissions
Now from any directory running speedtest-cli will do a test
Confirm it works:
cd / speedtest-cli
After you confirm it works delete the download directory
cd ~ rm -rf speedtest-cli
Okay now here is some usage
speedtest-cli --list
lists all of the ten billion million servers
test with anyone like this
speedtest-cli --server SERVERNUMBER
like to test with Optimum Online server in New York, NY USA
speedtest-cli --server 663
To get a picture of your results to share with the speedtest network or your friends/family/coworkers
speedtest --share
or
speedtest --server 663 --share
or instead of 663 any other valid server number
Next here is my script to list with a few servers plus the closest one to you (remember when not specifying a server it picks the closest one based on ping)
Get a list of servers like this
speedtest-cli --list | egrep -i "colorado|new york|britain|india|china|washington"
So then pick a few servers from the million numbers that outputs.
I picked 3864 2065 663 2789 2362 3047 1337 251 3927 2195 that kinda spans the world enough for me
So here is the awesome command, just type it out in notepad and then copy it out and paste it into your shell:
(echo "=====TESTING WITH: CLOSEST SERVER======"; speedtest-cli --share | egrep "load:|Hosted by|results"; for i in 3864 2065 663 2789 2362 3047 1337 251 3927 2195; do echo "======TESTING WITH: $i======="; speedtest-cli --share --server $i | egrep "load:|Hosted by|results"; done;) | tee ~/speedtests-`hostname`
Hopefully that doesnt have typos, I had to write it out, my googlesites kept crashing when I was trying to paste this in, and I am too lazy to fix it tommorow or do this tommorow so I am doing this now and had to type it out by hand…
Anyhow below is the old article there are a few other cool methods, this is just a rerendition of METHOD4 updated for how it is now, it might be different by the time you get to it.
Finally if you get any errors make sure you have the latest python requirements and google “speedtest-cli linux requirements”
UPDATE 2014-11-14: scriptlet to run speedtest-cli against many servers across the world
Here is a better script (just do the prereq steps listed, in comment section – they are not commented out so you can copy paste them). The main part of the script below the prereq script, is meant to work so you can copy paste it into a shell and run the test (you dont need to make a script out of this)
#!/bin/bash # test upload and download speed across the world # tests speedtest-cli speeds for upload and download from 1 site in each listed SITES ################################### # PreReq: ################################### ### --- install prereq --- ### apt-get update -y; apt-get install git-core -y cd ~ ### --- install speedtest-cli --- ### GIT_SSL_NO_VERIFY=true git clone https://github.com/sivel/speedtest-cli.git ### --- run the script to get the results --- ### cd speedtest-cli ################################### # Main: ################################### (SITES="colorado|new york|britain|india|china|washington" SPEEDTESTCLI="./speedtest_cli.py" OLDIFS=$IFS IFS="|" LIST=`$SPEEDTESTCLI --list` echo $LIST for i in $SITES; do NUMBER_OF_SITES=`echo $LIST | grep -i $i | wc -l` echo "##################################################### DATE `date` `date +%s`"; echo "## $i (number of sites: $NUMBER_OF_SITES - using first) ##"; SITELISTING=`echo $LIST | grep -i $i | head -n1` echo $SITELISTING ID=`echo $SITELISTING | cut -d")" -f1` $SPEEDTESTCLI --server $ID echo echo done IFS=$OLDIFS)
LINUX – TEST INTERNET CONNECTION – SPEED TEST – INTERNET SPEED TEST
METHOD1: wget
METHOD2: lftp
METHOD3: iperf
METHOD4: speedtest-cli
METHOD5: script that runs wgets
METHOD 1a
wget –O /dev/null http://ipv4.download.thinkbroadband.com/1GB.zip
another way just saves 9 keystrokes or so
wget –O /dev/null ipv4.download.thinkbroadband.com/1GB.zip
Then control C when you see the speed
METHOD 1b
wget -O /dev/null http://hostve.com/neobuntu/pics/Ubu1.avi wget --output-document=/dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip
METHOD 2
sudo apt-get install lftp
DOWNLOAD:
lftp -e 'pget http://mirror.anl.gov/pub/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-LiveCD.iso; exit; ' lftp -e 'pget http://hostve.com/neobuntu/pics/Ubu1.avi ; exit; ' lftp -e 'pget http://speedtest.example.com/500M.bin; exit; ' lftp -e 'pget http://speedtest.wdc01.softlayer.com/downloads/test500.zip; exit; '
UPLOAD:
lftp -u userName ftp.example.com -e 'put largecd1.avi; bye' lftp -u userName,passWord ftp.example.com -e 'put largecd1.avi; bye' lftp -u userName,passWord ftp.example.com -e 'put /path/to/large.iso; bye'
METHOD 2 – Good for local tests too
ON SERVER & CLIENT: apt-get install iperf
BASIC IDEA:
SERVER: iperf -s or iperf -s -p PORT
CLIENT: iperf -c SERVERIP or iperf -c SERVERIP -p PORT
SERVER HAS A PUBLIC IP:
-B on server is optional it binds to specific interface, in this case the WAN IP is on the SERVER
ON SERVER:
iperf -s -B 202.54.1.1ON CLIENT:
iperf -c 202.54.1.1 -d -t 60 -i 10SERVER BEHIND PUBLIC IP / GOOD WITH LOCAL TESTS JUST CHANGE IPS:
WITH PORT 44444 PORT FORWARDED @ SERVER NETWORK TO SERVER:
ON SERVER:
iperf -s -p 55555ON CLIENT:
iperf -c 202.54.1.1 -p 55555 -d -t 60 -i 10IPERF OPTIONS FROM http://doc.pfsense.org/index.php/Iperf_man_page
GENERAL OPTIONS -f, --format == [kmKM] format to report: Kbits, Mbits, KBytes, MBytes -h, --help == print a help synopsis -i, --interval n == pause n seconds between periodic bandwidth reports -l, --len n[KM] == set length read/write buffer to n (default 8 KB) -m, --print_mss == print TCP maximum segment size (MTU - TCP/IP header) -o, --output <filename> == output the report or error message to this specified file -p, --port n == set server port to listen on/connect to to n (default 5001) -u, --udp == use UDP rather than TCP -w, --window n[KM] == TCP window size (socket buffer size) -B, --bind <host> == bind to <host>, an interface or multicast address -C, --compatibility == for use with older versions does not sent extra msgs -M, --mss n == set TCP maximum segment size (MTU - 40 bytes) -N, --nodelay == set TCP no delay, disabling Nagle's Algorithm -v, --version == print version information and quit -V, --IPv6Version == Set the domain to IPv6 -x, --reportexclude == [CDMSV] exclude C(connection) D(data) M(multicast) S(settings) V(server) reports -y, --reportstyle C|c == if set to C or c report results as CSV (comma separated values) SERVER SPECIFIC OPTIONS -s, --server == run in server mode -U, --single_udp == run in single threaded UDP mode -D, --daemon == run the server as a daemon CLIENT SPECIFIC OPTIONS -b, --bandwidth n[KM] == set target bandwidth to n bits/sec (default 1 Mbit/sec). Thissetting requires UDP (-u). -c, --client <host> == run in client mode, connecting to <host> -d, --dualtest == Do a bidirectional test simultaneously -n, --num n[KM] == number of bytes to transmit (instead of -t) -r, --tradeoff == Do a bidirectional test individually -t, --time n == time in seconds to transmit for (default 10 secs) -F, --fileinput <name> == input the data to be transmitted from a file -I, --stdin == input the data to be transmitted from stdin -L, --listenport n == port to recieve bidirectional tests back on -P, --parallel n == number of parallel client threads to run -T, --ttl n == time-to-live, for multicast (default 1) -Z, --linux-congestion <algo> == set TCP congestion control algorithm (Linux only)
METHOD 3
See the top of the article for speedtest-cli from git
METHOD 4
WRITE THIS SCRIPT: netspeed.sh
#!/usr/bin/env bash # bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2011-10-09 # # _______________| netspeed : check download speed via command line. # # Usage: netspeed [tokyo, london, usw, use, east, west, URL] # ^default U.S. west coast. # [ -speed_KB/sec ] # ^negation activates the Mbps converter. # # First try it out without any arguments. # # Dependencies: wget # (rate displayed in Kilobytes per second, # whereas speed tests usually adopt Megabits.) # # Example units: Download Speed: 659 kbps (82.4 KB/sec transfer rate) # Upload Speed: 317 kbps (39.6 KB/sec transfer rate) # kb=kilobits KB=Kilobytes # So 0.007813 Mb = 8 kilobits = 1 Kilobyte # since 1 Mb = 1024 kilobits = 128 Kilobytes # # Units: b stands for bit and B stands for byte. In the context of # data rate units, one byte refers to 8 bits. For example, # when a 1 Mbps connection is advertised, it usually means # that the maximum achievable download bandwidth is # 1 megabit/s (million bits per second), which is actually # 0.125 MB/s (megabyte per second), or about # 0.1192 MiB/s (mebibyte per second). # http://en.wikipedia.org/wiki/Mbit/s#megabit_per_second # CHANGE LOG get LATEST version from https://bitbucket.org/rsvp/gists/src # # 2011-10-09 Add rate conversion to Mbps using negated first argument. # 2011-10-08 Add URL as possible arg. Clarify rate units. # Public as gist to https://gist.github.com/1272488 # 2011-10-07 First version based on wget, though curl also works: # http://stackoverflow.com/questions/426272 # Command line alternative to http://www.speedtest.net # _____ Prelims set -u # ^ unbound (i.e. unassigned) variables shall be errors. set -e # ^ error checking :: Highly Recommended (caveat: you can't check $? later). # # _______________ :: BEGIN Script :::::::::::::::::::::::::::::::::::::::: site=${1:-'usw'} case $site in 'london') test='http://london1.linode.com/100MB-london.bin' ;; 'tokyo') test='http://tokyo1.linode.com/100MB-tokyo.bin' ;; 'usw') test='http://fremont1.linode.com/100MB-fremont.bin' ;; # US West: Fremont, California 'use') test='http://newark1.linode.com/100MB-newark.bin' ;; # US East: Newark, New Jersey 'east') test='http://speedtest.wdc01.softlayer.com/downloads/test500.zip' ;; # US East: Washington, D.C. 'west') test='http://speedtest.sjc01.softlayer.com/speedtest/speedtest/random500x500.jpg' ;; # US West: San Jose, California *) test=$1 ;; # valid URL assumed, else wget will give any error message. esac # Sources: # 2011-10-07 http://www.linode.com/speedtest/ for file URL. # http://speedtest.wdc01.softlayer.com for actual testing. if [ $test = -${test#-} ] ; then # ^check for negative sign in the first argument. echo "`awk "END { print ($test * -0.007813) }" /dev/null` Mbps" # awk as nice floating-point calculator! else echo ' :: Rate in Kilobytes/sec; industry usually adopts megabits/sec: ' echo ' :: 1 Kilobytes/sec (K/s) = 0.007813 megabits/sec (Mbps).' echo ' :: To convert, use negated rate as first argument to netspeed. ' echo ' :: [Terminate netspeed by control-C] [ cf. http://speedtest.net ] ' echo ' :: ' # MAIN wget --output-document=/dev/null $test fi # If --output-file for wget was used to log results... # # --2011-10-07 21:38:27-- # Resolving speedtest.sjc01.softlayer.com... 50.23.64.58 # Connecting to speedtest.sjc01.softlayer.com|50.23.64.58|:80... connected. # HTTP request sent, awaiting response... 200 OK # Length: 505544 (494K) [image/jpeg] # Saving to: `/dev/null' # # 0K .......... .......... .......... .......... .......... 10% 80.9K 5s # 50K .......... .......... .......... .......... .......... 20% 78.5K 5s # 100K .......... .......... .......... .......... .......... 30% 80.8K 4s # 150K .......... .......... .......... .......... .......... 40% 78.8K 4s # 200K .......... .......... .......... .......... .......... 50% 80.8K 3s # 250K .......... .......... .......... .......... .......... 60% 78.5K 2s # 300K .......... .......... .......... .......... .......... 70% 78.8K 2s # 350K .......... .......... .......... .......... .......... 81% 80.8K 1s # 400K .......... .......... .......... .......... .......... 91% 78.5K 1s # 450K .......... .......... .......... .......... ... 100% 81.9K=6.2s # # 2011-10-07 21:38:33 (79.8 KB/s) - `/dev/null' saved [505544/505544] exit 0 # _______________ EOS :: END of Script :::::::::::::::::::::::::::::::::::::::: # # Alternative to wget... # curl -o /dev/null $test # # curl is less verbose than wget. Speed is displayed as bytes per second: # # # # % Total % Received % Xferd Average Speed Time Time Time Current # # Dload Upload Total Spent Left Speed # # 0 500M 0 4931k 0 0 80993 0 1:47:53 0:01:02 1:46:51 81520
It’s actually a great and useful piece of information. I am satisfied that
you shared this useful info with us. Please stay us up to date like
this. Thanks for sharing.