quinta-feira, 5 de dezembro de 2019

Check your link speed to all servers in location

So I had same problems with my local xDSL provider.

To be able to test the speed of connection we can use the speedtest site or a bash script from a GitHub developer, but I created the following bash script which will use the speedtest script to test the speed on all the servers in my city and save it to a log file.

#!/bin/bash
#
# speedtest all my city servers
#
# Author: braselectron.com 05/DEZ/2019
#
#
# ref: 

# curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -
#
# dependencies: 

#
#  1) wget https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
#

#  2) ubuntu 18.04
#

#  2.1) GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
#

#  3) http://ipinfo.io/ip   # for external IP fetch
#

#
targetcity="Miami"

# if target city name has spaces change it for grep \s like 
# this: "Salt\sLake\sCity"
gtarget=$( echo "$targetcity" | sed "s/ /\\\s/g )
#
servers=$( python speedtest.py --list | grep $gtarget )
# debug:
# echo -e "I found these servers:\n$servers"
servnum=$( echo -e "$servers" | cut -d ')' -f 1 )

# debug:
# echo -e "These are the server numbers:\n$servnum"
tot=$( echo -e "$servnum" | wc -l )
echo -e "\nRunning, please wait $tot servers to go:\n"

#
echo -e "Speedtest "$( wget -qO - http://ipinfo.io/ip )" "$( date +%F )"\n" > speedtest_$( date +%F ).log
#

i=1
#

for serv in $servnum
   do
     echo -e "$i of $tot - ($serv): "
     python speedtest.py --server $serv 2>&1 | grep ':' |\
     sed "s/$targetcity/$serv/g" |\
     sed "s/.*ERROR.*/Server is not responding/g" |\
     tee -a speedtest_$( date +%F ).log
     echo -e "" | tee -a speedtest_$( date +%F ).log
     sleep 1
     ((i++))
     #
   done
echo ""
Cheers!

Um comentário:

  1. Clicktots International Technologies offers high-quality SEO services. Our services quality has made our clients call us the Best & Top SEO Company/Agency in Chennai.

    Best SEO Company in Chennai

    ResponderExcluir