Sha256: 7113df13da7abd3b1f54466a74916ba35b48ce38b6c6911f152a26df961c865f

Contents?: true

Size: 702 Bytes

Versions: 1

Compression:

Stored size: 702 Bytes

Contents

require 'awesome_print'

module Mongodb
  module Graphite
    module Agent
      class CollectionSizeCalculator

        def initialize(mongo_client)
          @mongo_client = mongo_client
        end

        def calculate
          collection_count_hash = {}
          @mongo_client.database_names.each { |db_name|
            @mongo_client[db_name].collection_names.each { |collection_name|


              collection_count_hash["collection_sizes.#{db_name}.#{collection_name}"] = @mongo_client[db_name][collection_name].stats()["count"]
            } unless db_name == 'local'
          }

          return collection_count_hash
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongodb-graphite-agent-0.1.3 lib/mongodb/graphite/agent/collection_size_calculator.rb