forked from samuel/python-munin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmongodb_memory
More file actions
executable file
·44 lines (40 loc) · 1.15 KB
/
Copy pathmongodb_memory
File metadata and controls
executable file
·44 lines (40 loc) · 1.15 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()