root / plugins / mongodb / mongo_conn @ 9f85e0ae
Historique | Voir | Annoter | Télécharger (759 octets)
| 1 |
#!/usr/bin/python |
|---|---|
| 2 |
|
| 3 |
## GENERATED FILE - DO NOT EDIT |
| 4 |
|
| 5 |
import urllib2 |
| 6 |
import sys |
| 7 |
|
| 8 |
try: |
| 9 |
import json |
| 10 |
except ImportError: |
| 11 |
import simplejson as json |
| 12 |
|
| 13 |
|
| 14 |
def getServerStatus(): |
| 15 |
raw = urllib2.urlopen( "http://127.0.0.1:28017/_status" ).read() |
| 16 |
return json.loads( raw )["serverStatus"] |
| 17 |
|
| 18 |
name = "connections" |
| 19 |
|
| 20 |
|
| 21 |
def doData(): |
| 22 |
print name + ".value " + str( getServerStatus()["connections"]["current"] ) |
| 23 |
|
| 24 |
def doConfig(): |
| 25 |
|
| 26 |
print "graph_title MongoDB current connections" |
| 27 |
print "graph_args --base 1000 -l 0" |
| 28 |
print "graph_vlabel connections" |
| 29 |
print "graph_category MongoDB" |
| 30 |
|
| 31 |
print name + ".label " + name |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
if __name__ == "__main__": |
| 39 |
if len(sys.argv) > 1 and sys.argv[1] == "config": |
| 40 |
doConfig() |
| 41 |
else: |
| 42 |
doData() |
| 43 |
|
| 44 |
|
