tahoe-lafs/misc/munin/tahoe_server_operations_
2008-07-14 13:18:47 -07:00

75 lines
2.5 KiB
Python

#!/usr/bin/python
# graph operations-per-second from a set of storage servers.
# the OPERATION value should come from the following list:
# allocate: allocate_buckets, first step to upload an immutable file
# write: write data to an immutable share
# close: finish writing to an immutable share
# cancel: abandon a partial immutable share
# get: get_buckets, first step to download an immutable file
# read: read data from an immutable share
# writev: slot_testv_and_readv_and_writev, modify/create a directory
# readv: read a directory (or mutable file)
# To use this, create a symlink from
# /etc/munin/plugins/tahoe_server_operations_OPERATION to this script. For
# example:
# ln -s /usr/share/doc/allmydata-tahoe/munin/tahoe_server_operations_ \
# /etc/munin/plugins/tahoe_server_operations_allocate
# Also, you will need to put a list of node statistics URLs in the plugin's
# environment, by adding a stanza like the following to a file in
# /etc/munin/plugin-conf.d/, such as /etc/munin/plugin-conf.d/tahoe_operations:
#
# [tahoe_server_operations*]
# env.url_storage1 http://localhost:9011/statistics?t=json
# env.url_storage2 http://localhost:9012/statistics?t=json
# env.url_storage3 http://localhost:9013/statistics?t=json
# env.url_storage4 http://localhost:9014/statistics?t=json
# of course, these URLs must match the webports you have configured into the
# storage nodes.
import os, sys
import urllib
import simplejson
node_urls = []
for k,v in os.environ.items():
if k.startswith("url_"):
nodename = k[len("url_"):]
node_urls.append( (nodename, v) )
node_urls.sort()
configinfo = \
"""graph_title Tahoe Server Operations
graph_vlabel ops per second
graph_category tahoe
graph_info This graph shows server-side storage operation rates
"""
for nodename, url in node_urls:
configinfo += "%s.label %s\n" % (nodename, nodename)
configinfo += "%s.type DERIVE\n" % (nodename,)
configinfo += "%s.min 0\n" % (nodename,)
configinfo += "%s.draw LINE2\n" % (nodename,)
if len(sys.argv) > 1:
if sys.argv[1] == "config":
print configinfo.rstrip()
sys.exit(0)
for nodename, url in node_urls:
data = simplejson.loads(urllib.urlopen(url).read())
my_name = os.path.basename(sys.argv[0])
PREFIX = "tahoe_server_operations_"
assert my_name.startswith(PREFIX)
operation = my_name[len(PREFIX):]
key = "storage_server.%s" % operation
value = data["counters"][key]
print "%s.value %s" % (nodename, value)