Created
January 13, 2009 22:42
-
-
Save outoftime/46665 to your computer and use it in GitHub Desktop.
Script to repetitively open connections with starling and report lag time or error
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
gem 'starling-starling' | |
require 'starling' | |
unless ARGV.length == 1 | |
STDERR.puts('Usage: starping <host>:<port>') | |
exit(1) | |
end | |
host = ARGV[0] | |
while true | |
time = Time.now | |
begin | |
Starling.new(host).stats | |
lag = Time.now - time | |
puts "Connected to #{host} in #{lag}s." | |
sleep(1.0 - lag) | |
rescue => e | |
puts "Could not connect: [#{e.class.name}] #{e.message.inspect}" | |
sleep(1.0) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment