(RE-7014) Add support for statsd

They way we were using graphite was incorrect for the type of data we were sending it.  statsd is the appropriate mechanism for our needs.
statsd and graphite are mutually exclusive and configuring statsd will take precendence over Graphite.  Example of configuration in vmpooler.yaml.example
This commit is contained in:
Rick Sherman 2016-05-10 12:47:01 -05:00
parent 5aaab7c5c2
commit 8d75865a5c
8 changed files with 143 additions and 7 deletions

View file

@ -7,6 +7,7 @@ module Vmpooler
require 'rbvmomi'
require 'redis'
require 'sinatra/base'
require "statsd-ruby"
require 'time'
require 'timeout'
require 'yaml'
@ -52,6 +53,13 @@ module Vmpooler
parsed_config[:graphite]['prefix'] ||= 'vmpooler'
end
# statsd is an addition and my not be present in YAML configuration
if parsed_config[:statsd]
if parsed_config[:statsd]['server']
parsed_config[:statsd]['prefix'] ||= 'vmpooler'
end
end
if parsed_config[:tagfilter]
parsed_config[:tagfilter].keys.each do |tag|
parsed_config[:tagfilter][tag] = Regexp.new(parsed_config[:tagfilter][tag])
@ -79,6 +87,14 @@ module Vmpooler
end
end
def self.new_statsd(server, port)
if server.nil? or server.empty? or server.length == 0
nil
else
Statsd.new server, port
end
end
def self.pools(conf)
conf[:pools]
end