Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 64 lines (45 sloc) 1.479 kB
612e65b @samuelclay Adding HTTP Basic/Digest Auth for secure mongodb.
samuelclay authored
1 #!/usr/bin/env python
017ecad @erh mongo_btree
authored
2
3 ## GENERATED FILE - DO NOT EDIT
4
5 import urllib2
6 import sys
c9a9fb7 @alaz Possible to specify host in Munin config
alaz authored
7 import os
017ecad @erh mongo_btree
authored
8
9 try:
10 import json
11 except ImportError:
12 import simplejson as json
13
14
15 def getServerStatus():
c9a9fb7 @alaz Possible to specify host in Munin config
alaz authored
16 host = os.environ.get("host", "127.0.0.1")
17 port = 28017
612e65b @samuelclay Adding HTTP Basic/Digest Auth for secure mongodb.
samuelclay authored
18 url = "http://%s:%d/_status" % (host, port)
19 req = urllib2.Request(url)
20 user = os.environ.get("user")
21 password = os.environ.get("password")
22 if user and password:
23 passwdmngr = urllib2.HTTPPasswordMgrWithDefaultRealm()
24 passwdmngr.add_password(None, 'http://%s:%d' % (host, port), user, password)
25 authhandler = urllib2.HTTPDigestAuthHandler(passwdmngr)
26 opener = urllib2.build_opener(authhandler)
27 urllib2.install_opener(opener)
28 raw = urllib2.urlopen(req).read()
017ecad @erh mongo_btree
authored
29 return json.loads( raw )["serverStatus"]
30
31 def get():
32 return getServerStatus()["indexCounters"]["btree"]
33
34 def doData():
35 for k,v in get().iteritems():
bfe0d65 @erh some fixes
authored
36 print( str(k) + ".value " + str(int(v)) )
017ecad @erh mongo_btree
authored
37
38 def doConfig():
39
bfe0d65 @erh some fixes
authored
40 print "graph_title MongoDB btree stats"
0459580 @erh make everything 0 based CASE 1
authored
41 print "graph_args --base 1000 -l 0"
017ecad @erh mongo_btree
authored
42 print "graph_vlabel mb ${graph_period}"
43 print "graph_category MongoDB"
44
45 for k in get():
46 print k + ".label " + k
47 print k + ".min 0"
48 print k + ".type COUNTER"
49 print k + ".max 500000"
bfe0d65 @erh some fixes
authored
50 print k + ".draw LINE1"
017ecad @erh mongo_btree
authored
51
52
53
54
55
56
57 if __name__ == "__main__":
58 if len(sys.argv) > 1 and sys.argv[1] == "config":
59 doConfig()
60 else:
61 doData()
62
63
Something went wrong with that request. Please try again.