Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

34 lines (31 sloc) 1.333 kb
# Munin plugin for Mongo Collection Document Sizes
require 'rubygems'
require 'mongo'
#get the database here
db ="localhost",27017).db(ENV['dbname']);
#check if the server is requesting a config or data
if ARGV.size != 0 && ARGV[0].eql?("config")
coll = db.collection(collection)
sanitized = collection.gsub('.','?') #Since Munin does not like periods here
puts sanitized+".label "+ collection
puts sanitized+".min 0"
puts sanitized+".max 3000000"
puts sanitized+".draw LINE1"
puts sanitized+".type GAUGE"
puts sanitized+".info Number of documents in " + collection
puts "graph_title MongoDB Collections in #{ENV['dbname']}"
puts "graph_args --base 1000"
puts "graph_vlabel documents"
puts "graph_category MongoDB"
else #output the data here
db.collection_names.each{ |collection|
coll = db.collection(collection)
puts collection.gsub('.','?')+'.value '+coll.count.to_s
#Add this to your /etc/munin/plugin-conf.d/munin-node
#env.dbname test #Replace test with your database name!
Jump to Line
Something went wrong with that request. Please try again.