Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 27 lines (22 sloc) 0.796 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
class MongoStatsPlugin < Scout::Plugin
  OPTIONS=<<-EOS
path_to_db_yml:
label: Path to database.yml
rails_env:
label: Rails Environment
default: production
EOS

  needs 'mongo', 'yaml'

  def build_report
    config = YAML::load_file(option('path_to_db_yml'))[option('rails_env')]
    connection = Mongo::Connection.new(config['host'], config['port'])
    db = connection.db(config['database'])
    db.authenticate(config['username'], config['password']) unless config['username'].nil?

    stats = db.stats

    report(:objects => stats['objects'])
    report(:data_size => stats['dataSize'])
    report(:storage_size => stats['storageSize'])
    report(:indexes => stats['indexes'])
    report(:index_size => stats['indexSize'])
  end
end
Something went wrong with that request. Please try again.