Skip to content

Instantly share code, notes, and snippets.

@fh
Created December 16, 2013 09:03
Show Gist options
  • Save fh/7984214 to your computer and use it in GitHub Desktop.
Save fh/7984214 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
require 'haproxy'
haproxy = HAProxy.read_stats '/tmp/haproxy.sock'
statsd = UDPSocket.new
haproxy.stats.each do |hi|
if ['BACKEND', 'FRONTEND'].include?(hi[:svname])
%w(scur smax ereq econ rate hrsp_2xx hrsp_3xx hrsp_4xx hrsp_5xx).each do |statname|
stat = "haproxy.#{hi[:svname]}.#{hi[:pxname]}.#{statname}:#{hi[statname.to_sym]}|g"
statsd.send(stat,0,'127.0.0.1',8125)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment