-
-
Save rwjblue/4446291 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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