Sha256: 6c4aad2f4809c3e08cba6c81faf1c9f3d2b1255c2115fb81e6549ffd858e8bea

Contents?: true

Size: 621 Bytes

Versions: 1

Compression:

Stored size: 621 Bytes

Contents

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

        def write(metric_hash)
          @metric_hash_with_hostname = Hash[metric_hash.map { |k,v| ["#{Socket.gethostname}.mongodb.#{k}", v]}]
          if @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

1 entries across 1 versions & 1 rubygems

Version Path
mongodb-graphite-agent-0.0.5 lib/mongodb/graphite/agent/graphite_writer.rb