Projet

Général

Profil

Révision 65a40bb6

ID65a40bb6f8ed6e55ab44a54a32a574e85cdabb73
Parent 1f23e26d
Enfant a200e01f

Ajouté par Eliot Horowitz il y a presque 14 ans

Initial version

Voir les différences:

plugins/other/mongo_mem
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
def ok(s):
19
    return s == "resident" or s == "virtual" or s == "mapped"
20

  
21
def doData():
22
    for k,v in getServerStatus()["mem"].iteritems():
23
        if ok(k):
24
            print( str(k) + ".value " + str(v * 1024 * 1024) )
25

  
26
def doConfig():
27

  
28
    print "graph_title MongoDB memory usage"
29
    print "graph_args --base 1024 -l 0 --vertical-label Bytes"
30
    print "graph_category MongoDB"
31

  
32
    for k in getServerStatus()["mem"]:
33
        if ok( k ):
34
            print k + ".label " + k
35
            print k + ".draw LINE1"
36

  
37

  
38

  
39

  
40

  
41

  
42

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

  
49

  

Formats disponibles : Unified diff