Projet

Général

Profil

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

root / plugins / other / riak_memory @ 994980d2

Historique | Voir | Annoter | Télécharger (924 octets)

1
#!/usr/bin/python
2

    
3

    
4
import urllib2
5
import sys
6

    
7
try:
8
    import json
9
except ImportError:
10
    import simplejson as json
11

    
12

    
13
names = ["memory_total","memory_processes","memory_processes_used","memory_system","memory_atom","memory_atom_used","memory_binary","memory_code","memory_ets"]
14

    
15
def getServerStatus():
16
    raw = urllib2.urlopen( "http://127.0.0.1:8091/stats" ).read()
17
    return json.loads( raw )
18

    
19

    
20

    
21
def doData():
22
    for name in names:
23
        print name + ".value " + str( getServerStatus()[name] )
24

    
25
def doConfig():
26

    
27
    print "graph_title Riak memory"
28
    print "graph_args --base 1000 -l 0"
29
    print "graph_vlabel memory"
30
    print "graph_category Riak"
31

    
32
    for name in names:
33
        print name + ".label " + name
34
        print name + ".type GAUGE"
35
        print name + "draw LINE1"
36

    
37

    
38

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

    
45