Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed a CentOS compatibility issue. #6

Open
wants to merge 7 commits into from
This page is out of date. Refresh to see the latest.
View
14 build.bash
@@ -7,13 +7,21 @@ do
x=${x%.py}
out=mongo_$x
-
- echo "#!/usr/bin/env python" > $out
+
+ if type "python26" &>/dev/null; then
+ echo "#!/usr/bin/env python26" > $out
+ else
+ if type "python2.6" &>/dev/null; then
+ echo "#!/usr/bin/env python2.6" > $out
+ else
+ echo "#!/usr/bin/env python" > $out
+ fi
+ fi
+
echo "" >> $out
echo "## GENERATED FILE - DO NOT EDIT" >> $out
cat src/header.py >> $out
cat src/body_$x.py >> $out
cat src/footer.py >> $out
chmod 755 $out
-
done
View
26 mongo_btree
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
## GENERATED FILE - DO NOT EDIT
@@ -11,13 +11,23 @@ try:
except ImportError:
import simplejson as json
-
def getServerStatus():
host = os.environ.get("host", "127.0.0.1")
port = 28017
raw = urllib2.urlopen( "http://%s:%d/_status" % (host, port) ).read()
return json.loads( raw )["serverStatus"]
+def doAutoConf():
+ host = os.environ.get("host", "127.0.0.1")
+ port = 28017
+ try:
+ raw = urllib2.urlopen( "http://%s:%d/_status" % (host, port) ).read()
+ print "yes"
+ return True
+ except urllib2.URLError:
+ print "no"
+ return False
+
def get():
return getServerStatus()["indexCounters"]["btree"]
@@ -26,7 +36,6 @@ def doData():
print( str(k) + ".value " + str(int(v)) )
def doConfig():
-
print "graph_title MongoDB btree stats"
print "graph_args --base 1000 -l 0"
print "graph_vlabel mb ${graph_period}"
@@ -39,15 +48,10 @@ def doConfig():
print k + ".max 500000"
print k + ".draw LINE1"
-
-
-
-
-
if __name__ == "__main__":
- if len(sys.argv) > 1 and sys.argv[1] == "config":
+ if len(sys.argv) > 1 and sys.argv[1] == "autoconf":
+ doAutoConf()
+ elif len(sys.argv) > 1 and sys.argv[1] == "config":
doConfig()
else:
doData()
-
-
View
27 mongo_conn
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
## GENERATED FILE - DO NOT EDIT
@@ -11,21 +11,29 @@ try:
except ImportError:
import simplejson as json
-
def getServerStatus():
host = os.environ.get("host", "127.0.0.1")
port = 28017
raw = urllib2.urlopen( "http://%s:%d/_status" % (host, port) ).read()
return json.loads( raw )["serverStatus"]
-name = "connections"
+def doAutoConf():
+ host = os.environ.get("host", "127.0.0.1")
+ port = 28017
+ try:
+ raw = urllib2.urlopen( "http://%s:%d/_status" % (host, port) ).read()
+ print "yes"
+ return True
+ except urllib2.URLError:
+ print "no"
+ return False
+name = "connections"
def doData():
print name + ".value " + str( getServerStatus()["connections"]["current"] )
def doConfig():
-
print "graph_title MongoDB current connections"
print "graph_args --base 1000 -l 0"
print "graph_vlabel connections"
@@ -33,15 +41,10 @@ def doConfig():
print name + ".label " + name
-
-
-
-
-
if __name__ == "__main__":
- if len(sys.argv) > 1 and sys.argv[1] == "config":
+ if len(sys.argv) > 1 and sys.argv[1] == "autoconf":
+ doAutoConf()
+ elif len(sys.argv) > 1 and sys.argv[1] == "config":
doConfig()
else:
doData()
-
-
View
26 mongo_lock
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
## GENERATED FILE - DO NOT EDIT
@@ -11,20 +11,29 @@ try:
except ImportError:
import simplejson as json
-
def getServerStatus():
host = os.environ.get("host", "127.0.0.1")
port = 28017
raw = urllib2.urlopen( "http://%s:%d/_status" % (host, port) ).read()
return json.loads( raw )["serverStatus"]
+def doAutoConf():
+ host = os.environ.get("host", "127.0.0.1")
+ port = 28017
+ try:
+ raw = urllib2.urlopen( "http://%s:%d/_status" % (host, port) ).read()
+ print "yes"
+ return True
+ except urllib2.URLError:
+ print "no"
+ return False
+
name = "locked"
def doData():
print name + ".value " + str( 100 * getServerStatus()["globalLock"]["ratio"] )
def doConfig():
-
print "graph_title MongoDB write lock percentage"
print "graph_args --base 1000 -l 0 "
print "graph_vlabel percentage"
@@ -32,15 +41,10 @@ def doConfig():
print name + ".label " + name
-
-
-
-
-
if __name__ == "__main__":
- if len(sys.argv) > 1 and sys.argv[1] == "config":
+ if len(sys.argv) > 1 and sys.argv[1] == "autoconf":
+ doAutoConf()
+ elif len(sys.argv) > 1 and sys.argv[1] == "config":
doConfig()
else:
doData()
-
-
View
27 mongo_mem
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
## GENERATED FILE - DO NOT EDIT
@@ -11,13 +11,23 @@ try:
except ImportError:
import simplejson as json
-
def getServerStatus():
host = os.environ.get("host", "127.0.0.1")
port = 28017
raw = urllib2.urlopen( "http://%s:%d/_status" % (host, port) ).read()
return json.loads( raw )["serverStatus"]
+def doAutoConf():
+ host = os.environ.get("host", "127.0.0.1")
+ port = 28017
+ try:
+ raw = urllib2.urlopen( "http://%s:%d/_status" % (host, port) ).read()
+ print "yes"
+ return True
+ except urllib2.URLError:
+ print "no"
+ return False
+
def ok(s):
return s == "resident" or s == "virtual" or s == "mapped"
@@ -27,7 +37,6 @@ def doData():
print( str(k) + ".value " + str(v * 1024 * 1024) )
def doConfig():
-
print "graph_title MongoDB memory usage"
print "graph_args --base 1024 -l 0 --vertical-label Bytes"
print "graph_category MongoDB"
@@ -37,16 +46,10 @@ def doConfig():
print k + ".label " + k
print k + ".draw LINE1"
-
-
-
-
-
-
if __name__ == "__main__":
- if len(sys.argv) > 1 and sys.argv[1] == "config":
+ if len(sys.argv) > 1 and sys.argv[1] == "autoconf":
+ doAutoConf()
+ elif len(sys.argv) > 1 and sys.argv[1] == "config":
doConfig()
else:
doData()
-
-
View
20 mongo_ops
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
## GENERATED FILE - DO NOT EDIT
@@ -11,13 +11,22 @@ try:
except ImportError:
import simplejson as json
-
def getServerStatus():
host = os.environ.get("host", "127.0.0.1")
port = 28017
raw = urllib2.urlopen( "http://%s:%d/_status" % (host, port) ).read()
return json.loads( raw )["serverStatus"]
+def doAutoConf():
+ host = os.environ.get("host", "127.0.0.1")
+ port = 28017
+ try:
+ raw = urllib2.urlopen( "http://%s:%d/_status" % (host, port) ).read()
+ print "yes"
+ return True
+ except urllib2.URLError:
+ print "no"
+ return False
def doData():
ss = getServerStatus()
@@ -25,7 +34,6 @@ def doData():
print( str(k) + ".value " + str(v) )
def doConfig():
-
print "graph_title MongoDB ops"
print "graph_args --base 1000 -l 0"
print "graph_vlabel ops / ${graph_period}"
@@ -40,9 +48,9 @@ def doConfig():
print k + ".draw LINE1"
if __name__ == "__main__":
- if len(sys.argv) > 1 and sys.argv[1] == "config":
+ if len(sys.argv) > 1 and sys.argv[1] == "autoconf":
+ doAutoConf()
+ elif len(sys.argv) > 1 and sys.argv[1] == "config":
doConfig()
else:
doData()
-
-
View
6 src/body_btree.py
@@ -7,7 +7,6 @@ def doData():
print( str(k) + ".value " + str(int(v)) )
def doConfig():
-
print "graph_title MongoDB btree stats"
print "graph_args --base 1000 -l 0"
print "graph_vlabel mb ${graph_period}"
@@ -19,8 +18,3 @@ def doConfig():
print k + ".type COUNTER"
print k + ".max 500000"
print k + ".draw LINE1"
-
-
-
-
-
View
7 src/body_conn.py
@@ -1,20 +1,13 @@
name = "connections"
-
def doData():
print name + ".value " + str( getServerStatus()["connections"]["current"] )
def doConfig():
-
print "graph_title MongoDB current connections"
print "graph_args --base 1000 -l 0"
print "graph_vlabel connections"
print "graph_category MongoDB"
print name + ".label " + name
-
-
-
-
-
View
6 src/body_lock.py
@@ -5,15 +5,9 @@ def doData():
print name + ".value " + str( 100 * getServerStatus()["globalLock"]["ratio"] )
def doConfig():
-
print "graph_title MongoDB write lock percentage"
print "graph_args --base 1000 -l 0 "
print "graph_vlabel percentage"
print "graph_category MongoDB"
print name + ".label " + name
-
-
-
-
-
View
7 src/body_mem.py
@@ -8,7 +8,6 @@ def doData():
print( str(k) + ".value " + str(v * 1024 * 1024) )
def doConfig():
-
print "graph_title MongoDB memory usage"
print "graph_args --base 1024 -l 0 --vertical-label Bytes"
print "graph_category MongoDB"
@@ -17,9 +16,3 @@ def doConfig():
if ok( k ):
print k + ".label " + k
print k + ".draw LINE1"
-
-
-
-
-
-
View
2  src/body_ops.py
@@ -1,12 +1,10 @@
-
def doData():
ss = getServerStatus()
for k,v in ss["opcounters"].iteritems():
print( str(k) + ".value " + str(v) )
def doConfig():
-
print "graph_title MongoDB ops"
print "graph_args --base 1000 -l 0"
print "graph_vlabel ops / ${graph_period}"
View
6 src/footer.py
@@ -1,8 +1,8 @@
if __name__ == "__main__":
- if len(sys.argv) > 1 and sys.argv[1] == "config":
+ if len(sys.argv) > 1 and sys.argv[1] == "autoconf":
+ doAutoConf()
+ elif len(sys.argv) > 1 and sys.argv[1] == "config":
doConfig()
else:
doData()
-
-
View
15 src/header.py
@@ -1,4 +1,7 @@
+#%# family=auto
+#%# capabilities=autoconf
+
import urllib2
import sys
import os
@@ -8,9 +11,19 @@
except ImportError:
import simplejson as json
-
def getServerStatus():
host = os.environ.get("host", "127.0.0.1")
port = 28017
raw = urllib2.urlopen( "http://%s:%d/_status" % (host, port) ).read()
return json.loads( raw )["serverStatus"]
+
+def doAutoConf():
+ host = os.environ.get("host", "127.0.0.1")
+ port = 28017
+ try:
+ raw = urllib2.urlopen( "http://%s:%d/_status" % (host, port) ).read()
+ print "yes"
+ return True
+ except urllib2.URLError as detail:
+ print "no (", detail, ")"
+ return False
Something went wrong with that request. Please try again.