mongodb-graphite-agent 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,12 +13,10 @@ module Mongodb
|
|
13
13
|
collection_count_hash = {}
|
14
14
|
@mongo_client.database_names.each { |db_name|
|
15
15
|
@mongo_client[db_name].collection_names.each { |collection_name|
|
16
|
-
|
17
|
-
|
18
16
|
collection_count_hash["collection_sizes.#{db_name}.#{collection_name}"] = @mongo_client[db_name][collection_name].stats()["count"]
|
19
17
|
} unless db_name == 'local'
|
20
18
|
}
|
21
|
-
|
19
|
+
collection_count_hash["total_documents"] = collection_count_hash.values.inject { |sum,x| sum+x }
|
22
20
|
return collection_count_hash
|
23
21
|
end
|
24
22
|
|
@@ -4,7 +4,9 @@ require 'mongo'
|
|
4
4
|
|
5
5
|
describe 'Collection size calculator' do
|
6
6
|
it 'should calculate the number of documents in all db collections' do
|
7
|
-
|
7
|
+
connection = Mongo::MongoClient.new()
|
8
|
+
connection["test"]["lol"].save({ asd: 1})
|
9
|
+
collection_size_calculator = Mongodb::Graphite::Agent::CollectionSizeCalculator.new(connection)
|
8
10
|
collection_size_calculator.calculate.should have_at_least(1).items
|
9
11
|
end
|
10
12
|
end
|