Permalink
Browse files

mem info and fixes

  • Loading branch information...
1 parent a950cc8 commit f9ccc4df08c2517a67fc95b6b2912c62fe23617c @erh committed Mar 24, 2010
Showing with 46 additions and 1 deletion.
  1. +45 −0 mongo_mem
  2. +1 −1 mongo_ops
View
@@ -0,0 +1,45 @@
+#!/usr/bin/python
+
+import urllib2
+import sys
+
+try:
+ import json
+except ImportError:
+ import simplejson as json
+
+def ok(s):
+ return s == "resident" or s == "virtual" or s == "mapped"
+
+
+def getParsed():
+ raw = urllib2.urlopen( "http://127.0.0.1:28017/_status" ).read()
+ return json.loads( raw )
+
+def data():
+ parsed = getParsed()
+ for k,v in parsed["serverStatus"]["mem"].iteritems():
+ if ok(k):
+ print( str(k) + ".value " + str(v) )
+
+def config():
+
+ print "graph_title MongoDB memory usage"
+ print "graph_args --base 1000"
+ print "graph_vlabel mb ${graph_period}"
+ print "graph_category MongoDB"
+
+ for k in getParsed()["serverStatus"]["mem"]:
+ if ok( k ):
+ print k + ".label " + k
+ print k + ".type GAUGE"
+ print k + ".draw AREA"
+
+
+if __name__ == "__main__":
+ if len(sys.argv) > 1 and sys.argv[1] == "config":
+ config()
+ else:
+ data()
+
+
View
@@ -29,7 +29,7 @@ def config():
for k in getParsed()["serverStatus"]["opcounters"]:
print k + ".label " + k
print k + ".min 0"
- print k + ".type DERIVE"
+ print k + ".type COUNTER"
print k + ".max 500000"
print k + ".draw AREA"

0 comments on commit f9ccc4d

Please sign in to comment.