File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44import sys
55
66class MuninMongoDBPlugin (object ):
7- dbname_in_args = True
7+ dbname_in_args = False
88 category = "MongoDB"
99
1010 def __init__ (self ):
1111 super (MuninMongoDBPlugin , self ).__init__ ()
1212
1313 self .dbname = ((sys .argv [0 ].rsplit ('_' , 1 )[- 1 ] if self .dbname_in_args else None )
14- or os .environ [ 'MONGODB_DATABASE' ] )
14+ or os .environ . get ( 'MONGODB_DATABASE' ) or None )
1515 host = os .environ .get ('MONGODB_SERVER' ) or 'localhost'
1616 if ':' in host :
1717 host , port = host .split (':' )
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ # -*- coding: utf-8 -*-
3+
4+ from munin .mongodb import MuninMongoDBPlugin
5+
6+ class MongoDBMemoryPlugin (MuninMongoDBPlugin ):
7+ args = "-l 0 --base 1024"
8+ vlabel = "bytes"
9+ tital = "MongoDB memory usage"
10+ info = "Memory usage"
11+ field_types = (
12+ ('virtual' , dict (
13+ label = "virtual" ,
14+ info = "Bytes of virtual memory" ,
15+ type = "GAUGE" ,
16+ min = "0" ,
17+ )),
18+ ('resident' , dict (
19+ label = "resident" ,
20+ info = "Bytes of resident memory" ,
21+ type = "GAUGE" ,
22+ min = "0" ,
23+ )),
24+ ('mapped' , dict (
25+ label = "mapped" ,
26+ info = "Bytes of mapped memory" ,
27+ type = "GAUGE" ,
28+ min = "0" ,
29+ )),
30+ )
31+
32+ def run (self ):
33+ status = self .connection .admin .command ('serverStatus' )
34+ print "virtual.value" , status ["mem" ]["virtual" ]
35+ print "resident.value" , status ["mem" ]["resident.value" ]
36+ print "mapped.value" , status ["mem" ]["mapped" ]
37+
38+ if __name__ == "__main__" :
39+ MongoDBMemoryPlugin ().run ()
You can’t perform that action at this time.
0 commit comments