Created
November 10, 2014 14:59
-
-
Save asmuth/68d99cd765440bbf2b1b to your computer and use it in GitHub Desktop.
statsd fork/bridge (forward statsd data to multiple hosts)
This file contains 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 "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