Last active
August 20, 2018 01:04
-
-
Save codatory/f0c7156d7ad71e10c58f to your computer and use it in GitHub Desktop.
This file contains 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
#! /usr/local/env ruby | |
require "uri" | |
##################### | |
## ____ _ _ | |
## / ___|___ _ __ ___| |_ __ _ _ __ | |_ ___ | |
## | | / _ \| '_ \/ __| __/ _` | '_ \| __/ __| | |
## | |__| (_) | | | \__ \ || (_| | | | | |_\__ \ | |
## \____\___/|_| |_|___/\__\__,_|_| |_|\__|___/ | |
## | |
##################### | |
LOGFILE = File.new("#{Dir.pwd}/netcheck.txt", 'a') | |
LOGFILE.sync = true | |
SERVERS = [ | |
{ | |
:name => "Cachefly", | |
:url => "http://cachefly.cachefly.net/100mb.test" | |
}, | |
{ | |
:name => "Linode, Atlanta, GA, USA", | |
:url => "http://speedtest.atlanta.linode.com/100MB-atlanta.bin" | |
}, | |
{ | |
:name => "Linode, Dallas, TX, USA", | |
:url => "http://speedtest.dallas.linode.com/100MB-dallas.bin" | |
}, | |
{ | |
:name => "Vultr, Chicago, IL", | |
:url => "http://il-us-ping.vultr.com/vultr.com.100MB.bin" | |
}, | |
{ | |
:name => "Vultr, NY/NJ", | |
:url => "http://nj-us-ping.vultr.com/vultr.com.100MB.bin" | |
}, | |
{ | |
:name => "OVH, BHS", | |
:url => "http://bhs.proof.ovh.net/files/100Mio.dat" | |
}, | |
{ | |
:name => "FDC Chicago", | |
:url => "http://lg.chi.fdcservers.net/100MBtest.zip" | |
}, | |
{ | |
:name => "FDC Chicago (Cogent)", | |
:url => "http://lg.chi2-1.fdcservers.net/100MBtest.zip" | |
}, | |
{ | |
:name => "Leaseweb, Manassas, VA, USA", | |
:url => "http://mirror.us.leaseweb.net/speedtest/100mb.bin" | |
}, | |
{ | |
:name => "DigitalOcean (NYC3)", | |
:url => "http://speedtest-nyc3.digitalocean.com/100mb.test" | |
}, | |
{ | |
:name => "DigitalOcean (NYC2)", | |
:url => "http://speedtest-nyc2.digitalocean.com/100mb.test" | |
}, | |
{ | |
:name => "Softlayer, Seattle, WA, USA", | |
:url => "http://speedtest.sea01.softlayer.com/downloads/test100.zip" | |
}, | |
{ | |
:name => "Softlayer, San Jose, CA, USA", | |
:url => "http://speedtest.sjc01.softlayer.com/downloads/test100.zip" | |
}, | |
{ | |
:name => "Softlayer, Washington, DC, USA", | |
:url => "http://speedtest.wdc01.softlayer.com/downloads/test100.zip" | |
}, | |
{ | |
:name => "Softlayer, Dallas, TX, USA", | |
:url => "http://speedtest.dal01.softlayer.com/downloads/test100.zip" | |
}, | |
{ | |
:name => "Facebook Mirror", | |
:url => "http://mirror.facebook.net/debian-cd/current/i386/iso-cd/debian-update-7.6.0-i386-CD-1.iso" | |
}, | |
{ | |
:name => "USSG @ IU Mirror", | |
:url => "http://ftp.ussg.iu.edu/linux/fedora/fullfilelist" | |
} | |
] | |
SERVERS.each do |server| | |
uri = URI.parse(server[:url]) | |
puts "Performing traceroute to #{server[:name]}" | |
puts trace = `mtr -rw #{uri.hostname}` | |
puts "Performing HTTP speed test" | |
puts speed =`wget -O /dev/null #{server[:url]} 2>&1 | awk '/\\/dev\\/null/ {speed=\$3 \$4} END {gsub(/\\(|\\)/,"",speed); print speed}'` | |
puts "Appending logfile..." | |
LOGFILE << "#{Time.now} - #{server[:name]} \n" | |
LOGFILE << trace | |
LOGFILE << "\n" | |
LOGFILE << speed | |
LOGFILE << "\n\n" | |
LOGFILE << "=====================================================\n\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment