]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - misc/munin/tahoe_server_operations_
quickstart.html: link to snapshots page, sorted with most recent first.
[tahoe-lafs/tahoe-lafs.git] / misc / munin / tahoe_server_operations_
1 #!/usr/bin/env python
2
3 # graph operations-per-second from a set of storage servers.
4
5 # the OPERATION value should come from the following list:
6 #   allocate:   allocate_buckets, first step to upload an immutable file
7 #    write: write data to an immutable share
8 #    close: finish writing to an immutable share
9 #    cancel: abandon a partial immutable share
10 #   get: get_buckets, first step to download an immutable file
11 #    read: read data from an immutable share
12 #   writev: slot_testv_and_readv_and_writev, modify/create a directory
13 #   readv: read a directory (or mutable file)
14
15 # To use this, create a symlink from
16 # /etc/munin/plugins/tahoe_server_operations_OPERATION to this script. For
17 # example:
18
19 # ln -s /usr/share/doc/allmydata-tahoe/munin/tahoe_server_operations_ \
20 #  /etc/munin/plugins/tahoe_server_operations_allocate
21
22 # Also, you will need to put a list of node statistics URLs in the plugin's
23 # environment, by adding a stanza like the following to a file in
24 # /etc/munin/plugin-conf.d/, such as /etc/munin/plugin-conf.d/tahoe_operations:
25 #
26 # [tahoe_server_operations*]
27 # env.url_storage1 http://localhost:9011/statistics?t=json
28 # env.url_storage2 http://localhost:9012/statistics?t=json
29 # env.url_storage3 http://localhost:9013/statistics?t=json
30 # env.url_storage4 http://localhost:9014/statistics?t=json
31
32 # of course, these URLs must match the webports you have configured into the
33 # storage nodes.
34
35 import os, sys
36 import urllib
37 import simplejson
38
39 node_urls = []
40 for k,v in os.environ.items():
41     if k.startswith("url_"):
42         nodename = k[len("url_"):]
43         node_urls.append( (nodename, v) )
44 node_urls.sort()
45
46 my_name = os.path.basename(sys.argv[0])
47 PREFIX = "tahoe_server_operations_"
48 assert my_name.startswith(PREFIX)
49 operation = my_name[len(PREFIX):]
50
51 configinfo = \
52 """graph_title Tahoe Server '%(operation)s' Operations
53 graph_vlabel ops per second
54 graph_category tahoe
55 graph_info This graph shows how many '%(operation)s' operations take place on the storage server
56 """ % {'operation': operation}
57
58 for nodename, url in node_urls:
59     configinfo += "%s.label %s\n" % (nodename, nodename)
60     configinfo += "%s.type DERIVE\n" % (nodename,)
61     configinfo += "%s.min 0\n" % (nodename,)
62     configinfo += "%s.draw LINE2\n" % (nodename,)
63
64
65 if len(sys.argv) > 1:
66     if sys.argv[1] == "config":
67         print configinfo.rstrip()
68         sys.exit(0)
69
70 for nodename, url in node_urls:
71     data = simplejson.loads(urllib.urlopen(url).read())
72     key = "storage_server.%s" % operation
73     value = data["counters"][key]
74     print "%s.value %s" % (nodename, value)
75