/
mongodb_size_
executable file
·45 lines (40 loc) · 1.14 KB
/
mongodb_size_
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
45
#!/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()