lib/mongodb/graphite/agent.rb in mongodb-graphite-agent-0.1.2 vs lib/mongodb/graphite/agent.rb in mongodb-graphite-agent-0.1.3
- old
+ new
@@ -7,10 +7,11 @@
require 'awesome_print'
require 'time_difference'
require 'mongodb/graphite/agent/utils'
require 'mongodb/graphite/agent/op_counters_sample'
require 'mongodb/graphite/agent/mongo_cient_extensions'
+require 'mongodb/graphite/agent/collection_size_calculator'
module Mongodb
module Graphite
module Agent
class Runner
@@ -29,24 +30,27 @@
metric_hash = Utils.to_hash(server_status_result).select { |k|
k.match('^connection|^network\.|^cursors|^mem\.mapped|^indexCounters|^repl.oplog')
}
opcounters_per_second_metric_hash = calculate_opcounters_per_second server_status_result["opcounters"]
+ total_collections_hash = CollectionSizeCalculator.new(connection).calculate
if @opts[:verbose]
puts "Calculating metrics..."
ap metric_hash
ap opcounters_per_second_metric_hash
+ ap total_collections_hash
end
unless (@opts[:dry_run])
graphite_writer = GraphiteWriter.new({:host => @opts[:graphite_host],
:port => @opts[:graphite_port],
:verbose => @opts[:verbose],
:metrics_prefix => @opts[:graphite_metrics_prefix]})
graphite_writer.write(metric_hash)
graphite_writer.write(opcounters_per_second_metric_hash)
+ graphite_writer.write(total_collections_hash)
end
end
def calculate_opcounters_per_second(opcounters)
current_sample = OpCountersSample.new Hash[opcounters]
\ No newline at end of file