Projet

Général

Profil

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

root / plugins / other / riak_memory @ b75bbfea

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

1
#!/usr/bin/python
2

    
3

    
4
# This is monitoring plugin for riak Developer's website: http://wiki.basho.com/Riak.html
5
# sample config in /etc/munin/plugin-conf.d/riak
6
#
7
# [riak_*]
8
# env.RIAK_URL http://127.0.0.1:8091/stats
9
# any questions to fygrave at o0o dot nu
10
#
11
# This plugin monitors memory allocation on each node.
12
#
13

    
14
import urllib2
15
import sys
16
import os
17

    
18
try:
19
    import json
20
except ImportError:
21
    import simplejson as json
22

    
23

    
24
names = ["memory_total","memory_processes","memory_processes_used","memory_system","memory_atom","memory_atom_used","memory_binary","memory_code","memory_ets"]
25

    
26
def getServerStatus():
27
    raw = urllib2.urlopen( os.environ.get('RIAK_URL', "http://127.0.0.1:8097/stats") ).read()
28
    return json.loads( raw )
29

    
30

    
31

    
32
def doData():
33
    for name in names:
34
        print name + ".value " + str( getServerStatus()[name] )
35

    
36
def doConfig():
37

    
38
    print "graph_title Riak memory"
39
    print "graph_args --base 1000 -l 0"
40
    print "graph_vlabel memory"
41
    print "graph_category Riak"
42

    
43
    for name in names:
44
        print name + ".label " + name
45
        print name + ".type GAUGE"
46
        print name + "draw LINE1"
47

    
48

    
49

    
50
if __name__ == "__main__":
51
    if len(sys.argv) > 1 and sys.argv[1] == "config":
52
        doConfig()
53
    else:
54
        doData()
55

    
56