Projet

Général

Profil

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

root / plugins / riak / riak_memory @ a7139bca

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

1 a7139bca Lars Kruse
#!/usr/bin/env python
2 3bc264de Fyodor Yarochkin
3
4 0eedb04a Fyodor Yarochkin
# 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 b75bbfea Fyodor Yarochkin
# env.RIAK_URL http://127.0.0.1:8091/stats
9 0eedb04a Fyodor Yarochkin
# any questions to fygrave at o0o dot nu
10
#
11
# This plugin monitors memory allocation on each node.
12
#
13
14 3bc264de Fyodor Yarochkin
import urllib2
15
import sys
16 0eedb04a Fyodor Yarochkin
import os
17 3bc264de Fyodor Yarochkin
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 0eedb04a Fyodor Yarochkin
    raw = urllib2.urlopen( os.environ.get('RIAK_URL', "http://127.0.0.1:8097/stats") ).read()
28 3bc264de Fyodor Yarochkin
    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 63351ab5 dipohl
    print "graph_category other"
42 3bc264de Fyodor Yarochkin
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