NewsBlur/config/munin/mongodb_size_newsblur

45 lines
1.1 KiB
Python
Executable file

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from munin.mongodb import MuninMongoDBPlugin
class MongoDBSizePlugin(MuninMongoDBPlugin):
args = "-l 0 --base 1024"
vlabel = "bytes"
info = "Size of database"
dbname_in_args = True
fields = (
('storagesize', dict(
label = "Storage size (bytes)",
info = "Storage size",
type = "GAUGE",
draw = "AREA",
)),
('datasize', dict(
label = "Data size (bytes)",
info = "Data size",
type = "GAUGE",
draw = "AREA",
)),
('indexsize', dict(
label = "Index size (bytes)",
info = "Index size",
type = "GAUGE",
draw = "AREA",
)),
)
@property
def title(self):
return "MongoDB size of database %s" % self.dbname
def execute(self):
stats = self.db.command("dbstats")
return dict(
storagesize = stats["storageSize"],
datasize = stats["dataSize"],
indexsize = stats["indexSize"],
)
if __name__ == "__main__":
MongoDBSizePlugin().run()