Skip to content

Instantly share code, notes, and snippets.

@rwjblue
Forked from rondale-sc/test_connection.rb
Created January 3, 2013 19:30
Show Gist options
  • Save rwjblue/4446291 to your computer and use it in GitHub Desktop.
Save rwjblue/4446291 to your computer and use it in GitHub Desktop.
class TestConnection
def repeat_test
while true do
if packet_loss > 0
`say 'link down'`
end
end
end
def packet_loss
ping_google.split(",").last =~ /(\d+\.\d+)\%/
$1.to_i
end
def ping_google
`ping -t 5 -q google.com`
end
end
if __FILE__ == $0
tc = TestConnection.new
tc.repeat_test
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment