Sha256: 1b5e9d1c119a74d1dc3af1b9668e97657dd3b77a06c8c9013e196cc79960f1c7

Contents?: true

Size: 596 Bytes

Versions: 3

Compression:

Stored size: 596 Bytes

Contents

module Mongodb
  module Graphite
    module Agent
      class GraphiteWriter
        def initialize(opts)
          @graphite = ::Graphite.new({:host => opts[:host], :port => opts[:port]})
          @opts = opts
        end

        def write(metric_hash)
          @metric_hash_with_hostname = Hash[metric_hash.map { |k,v| ["#{@opts[:metrics_prefix]}.#{k}", v]}]
          if @opts[:verbose]
            puts "Sending data to graphite..."
            ap @metric_hash_with_hostname
          end
          @graphite.send_metrics @metric_hash_with_hostname
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongodb-graphite-agent-0.1.1 lib/mongodb/graphite/agent/graphite_writer.rb
mongodb-graphite-agent-0.1.0 lib/mongodb/graphite/agent/graphite_writer.rb
mongodb-graphite-agent-0.0.9 lib/mongodb/graphite/agent/graphite_writer.rb