This Munin plugin monitors document sizes of all collections within a MongoDB database
Switch branches/tags
Nothing to show
Pull request Compare This branch is even with lobster1234:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



This project contains the munin plugin that monitors the number of documents in various collections within a database. The database name is configured in the munin-plugin.conf file.


  • Ruby 1.8+

  • mongo gem


I have tested these steps on Centos5 and Ubuntu 10.10

Follow these steps on the same server you're running your mongo instance on.

NOTE: If running master/slave I'd recommend doing this on just one of the slave nodes. Do not set up this plugin on all the nodes in a replica-set/replica-pair or master/slave config, as they all will report pretty much the same data.

  • Verify if you have mongo gem installed

mpandit@mpandit-ubuntu:~$ gem list | grep mongo mongo (1.1.2, 1.1)

  • If missing, then install with

gem install mongo

  • Grab the plugin

git clone git://

  • Make sure mongo_collections.rb is +x for owner, group and others

    chmod +x mongo_collections.rb

cp mongo_collections.rb /usr/share/munin/plugins/ ln -s /usr/share/munin/plugins/mongo_collections.rb /etc/munin/plugins/mongo_collections.rb

  • Now to add the database name to the plugin configuration, do this:

    sudo vi /etc/munin/plugin-conf.d/munin-node
  • Paste this to the bottom of the file

[mongo*] env.dbname replace_with_your_database_name

  • Save, and exit

  • Restart the munin node

sudo /etc/init.d/munin-node restart

  • Make sure the munin server is listening from this node and you should be good to go!


  • You can test this by simply running the plugin on command line (replace mydb with your database name)

    export dbname=mydb 
    cd /etc/munin/plugins
    ./mongo_collections config
  • You should see something like this, in this case mydb contains only 1 collection called twitter.

    twitter.label twitter
    twitter.min 0
    twitter.max 3000000
    twitter.draw LINE1
    twitter.type GAUGE Number of documents in twitter
    graph_title MongoDB Collections in mydb
    graph_args --base 1000
    graph_vlabel documents
    graph_category MongoDB


  • Support discovery of databases on the node and pick up the collections in every db

  • Support datbase/collection names whitelisting where only the whitelisted dbs/collections will be scanned

  • Support user/password auth

  • Remove dependency on running on the same node as the mongo instance.


@lobster1234 on Twitter pandit(dot)manish(at)gmail(dot)com