Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b28d5f2bfe
Fetching contributors…

Cannot retrieve contributors at this time

executable file 44 lines (40 sloc) 1.176 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from munin.mongodb import MuninMongoDBPlugin

class MongoDBMemoryPlugin(MuninMongoDBPlugin):
    args = "-l 0 --base 1024"
    vlabel = "bytes"
    title = "MongoDB memory usage"
    info = "Memory usage"
    fields = (
        ('virtual', dict(
            label = "virtual",
            info = "Bytes of virtual memory",
            type = "GAUGE",
            min = "0",
        )),
        ('resident', dict(
            label = "resident",
            info = "Bytes of resident memory",
            type = "GAUGE",
            min = "0",
        )),
        ('mapped', dict(
            label = "mapped",
            info = "Bytes of mapped memory",
            type = "GAUGE",
            min = "0",
        )),
    )

    def execute(self):
        status = self.connection.admin.command('serverStatus')
        values = {}
        for k in ("virtual", "resident", "mapped"):
            try:
                value = int(status["mem"][k]) * 1024 * 1024
            except KeyError:
                value = "U"
            values[k] = value
        return values

if __name__ == "__main__":
    MongoDBMemoryPlugin().run()
Something went wrong with that request. Please try again.