Projet

Général

Profil

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

root / plugins / riak / riak_node @ a7139bca

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

1
#!/usr/bin/env python
2

    
3
# This is monitoring plugin for riak Developer's website: http://wiki.basho.com/Riak.html
4
# sample config in /etc/munin/plugin-conf.d/riak
5
#
6
# [riak_*]
7
# env.RIAK_URL http://127.0.0.1:8091/stats
8
# any questions to fygrave at o0o dot nu
9
#
10
# This plugin monitors put/get rate at each node.
11
#
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 = ["node_gets_total", "node_puts_total"]
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 puts and gets"
39
    print "graph_args --base 1000 -l 0"
40
    print "graph_vlabel puts/gets"
41
    print "graph_category other"
42

    
43
    for name in names:
44
        print name + ".label " + name
45
        print name + ".min 0"
46
        print name + ".type COUNTER"
47
        print name + ".max 500000"
48
        print name + "draw LINE1"
49

    
50

    
51

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

    
58