Skip to content

Instantly share code, notes, and snippets.

@asmuth
Created November 10, 2014 14:59
Show Gist options
  • Save asmuth/68d99cd765440bbf2b1b to your computer and use it in GitHub Desktop.
Save asmuth/68d99cd765440bbf2b1b to your computer and use it in GitHub Desktop.
statsd fork/bridge (forward statsd data to multiple hosts)
#!/usr/bin/env ruby
require "socket"
udp = UDPSocket.new
udp.bind('0.0.0.0', 8125)
targets = [
["localhost", 8125],
["other.host.net", 8125]
]
loop do
begin
data, addr = udp.recvfrom(65535)
puts data.inspect
targets.each do |target|
udp.send data, 0, target[0], target[1]
end
rescue Exception => e
puts e.inspect
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment