Skip to content

Instantly share code, notes, and snippets.

@roidrage
Created January 1, 2010 16:08
Show Gist options
  • Select an option

  • Save roidrage/267149 to your computer and use it in GitHub Desktop.

Select an option

Save roidrage/267149 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'socket'
host = ARGV[0] || 'localhost'
port = ARGV[1] || '6379'
trap(:INT) {
exit
}
puts "Connecting to #{host}:#{port}"
begin
sock = TCPSocket.new(host, port)
sock.setsockopt Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1
sock.write("monitor\r\n")
while line = sock.gets
puts line
end
rescue Errno::ECONNREFUSED
puts "Connection refused"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment