Sha256: 138dad23c46d49b33e862d1942151764359dcad29e8858e7802a08685ff29025

Contents?: true

Size: 617 Bytes

Versions: 5

Compression:

Stored size: 617 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

5 entries across 5 versions & 1 rubygems

Version Path
mongodb-graphite-agent-0.1.4 lib/mongodb/graphite/agent/graphite_writer.rb
mongodb-graphite-agent-0.1.3 lib/mongodb/graphite/agent/graphite_writer.rb
mongodb-graphite-agent-0.1.2 lib/mongodb/graphite/agent/graphite_writer.rb
mongodb-graphite-agent-0.0.8 lib/mongodb/graphite/agent/graphite_writer.rb
mongodb-graphite-agent-0.0.6 lib/mongodb/graphite/agent/graphite_writer.rb