Skip to content

Instantly share code, notes, and snippets.

@velenux
Created August 5, 2010 23:20
Show Gist options
  • Save velenux/510573 to your computer and use it in GitHub Desktop.
Save velenux/510573 to your computer and use it in GitHub Desktop.
# encoding: utf-8
require 'rubygems'
require 'net/ping'
hosts = ['www.google.com',
'www.deviantart.com',
'www.facebook.com',
'www.twitter.com',
'www.yahoo.com',
'www.github.com',
'www.slashdot.org',
'www.digg.com']
sock = Net::Ping::TCP.new
sock.port = 80
hosts.sort.each do |h|
status = 'Unreachable'
if sock.ping?(h)
status = "%.1f ms" % (sock.duration * 1000).to_s
end
puts "#{h}: #{status}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment