which is available as a gem with gem install net-pingrequire 'rubygems'require 'net/ping'if Net::PingExternal.new('http://www.google.com/').ping puts "Pong!"else puts "No response"end