Projet

Général

Profil

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

root / plugins / mongodb / mongo_lock @ 9121b90e

Historique | Voir | Annoter | Télécharger (939 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 = "locked"
19

    
20
def doData():
21
    status = getServerStatus()
22
    if status["version"] >= "2.2.0":
23
        ratio = float(status["globalLock"]["lockTime"]) / status["globalLock"]["totalTime"]
24
    else:
25
        ratio = status["globalLock"]["ratio"]
26
    print name + ".value " + str( 100 * ratio )
27

    
28
def doConfig():
29

    
30
    print "graph_title MongoDB write lock percentage"
31
    print "graph_args --base 1000 -l 0 "
32
    print "graph_vlabel percentage"
33
    print "graph_category MongoDB"
34

    
35
    print name + ".label " + name
36

    
37

    
38

    
39

    
40

    
41

    
42
if __name__ == "__main__":
43
    if len(sys.argv) > 1 and sys.argv[1] == "config":
44
        doConfig()
45
    else:
46
        doData()
47

    
48