Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / mongodb / mongo_lock @ 68d23cce

Historique | Voir | Annoter | Télécharger (1,12 ko)

1 237bf058 Eliot Horowitz
#!/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 = "locked"
19
20
def doData():
21 271a38f0 Dimitri Savineau
    status = getServerStatus()
22
    if status["version"] >= "2.2.0":
23 68d23cce Takuya Matsuyama
        if status["globalLock"]["lockTime"]["$numberLong"]:
24
            ratio = float(status["globalLock"]["lockTime"]["$numberLong"]) / float(status["globalLock"]["totalTime"]["$numberLong"])
25
        else:
26
            ratio = float(status["globalLock"]["lockTime"]) / status["globalLock"]["totalTime"]
27 271a38f0 Dimitri Savineau
    else:
28
        ratio = status["globalLock"]["ratio"]
29
    print name + ".value " + str( 100 * ratio )
30 237bf058 Eliot Horowitz
31
def doConfig():
32
33
    print "graph_title MongoDB write lock percentage"
34
    print "graph_args --base 1000 -l 0 "
35
    print "graph_vlabel percentage"
36
    print "graph_category MongoDB"
37
38
    print name + ".label " + name
39
40
41
42
43
44
45
if __name__ == "__main__":
46
    if len(sys.argv) > 1 and sys.argv[1] == "config":
47
        doConfig()
48
    else:
49
        doData()
50