Created
August 23, 2012 12:34
-
-
Save vderyagin/3436243 to your computer and use it in GitHub Desktop.
Test network by investigating connection to servers in different geographical locations.
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/bin/env ruby | |
=begin | |
Test network by investigating connection to servers in different geographical | |
locations. | |
Prints results to stdout. | |
Shells out to mtr(1) (http://www.bitwizard.nl/mtr/). | |
=end | |
MTR = '/usr/sbin/mtr' | |
PINGS_COUNT = String 100 | |
SITES = %w( | |
109.te.ua meta.ua interfax.com.ua | |
lenta.ru lib.ru yandex.ru | |
kernel.org europa.eu google.com | |
) | |
separator = '=' * 80 | |
mtr_version = IO.popen [MTR, '--version'] do |process| | |
process.read | |
end | |
out = STDOUT | |
out.puts Time.now | |
out.puts mtr_version | |
SITES.each do |site| | |
command = [] | |
command << MTR | |
command << '--report' | |
command << '--report-cycles' << PINGS_COUNT | |
command << '--order' << 'LSRDNBAW' | |
command << site | |
out.puts separator | |
out.puts "#{site}:" | |
out.puts | |
IO.popen command do |process| | |
out.puts process.read | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment