Skip to content

Instantly share code, notes, and snippets.

@outoftime
Created January 13, 2009 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save outoftime/46665 to your computer and use it in GitHub Desktop.
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
#!/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