3 # This is a munin plugin which pulls total-used data from the server in
4 # misc/spacetime/diskwatcher.tac, and a total-deep-size number from custom
5 # PHP database-querying scripts on a different server. It produces a graph of
6 # how much garbage/overhead is present in the grid: the ratio of total-used
7 # over (total-deep-size*N/k), expressed as a percentage. No overhead would be
8 # 0, using twice as much space as we'd prefer would be 100. This is the
9 # percentage which could be saved if we made GC work perfectly and reduced
10 # other forms of overhead to zero. This script assumes 3-of-10.
12 # A second graph is produced with how much of the total-deep-size number
13 # would be saved if we removed data from inactive accounts. This is also on a
16 # A separate number (without a graph) is produced with the "effective
17 # expansion factor". If there were no overhead, with 3-of-10, this would be
20 # Overhead is caused by the following problems (in order of size):
21 # uncollected garbage: files that are no longer referenced but not yet deleted
22 # inactive accounts: files that are referenced by cancelled accounts
23 # share storage overhead: bucket directories
24 # filesystem overhead: 4kB minimum block sizes
25 # share overhead: hashes, pubkeys, lease information
27 # This plugin should be configured with env_diskwatcher_url= pointing at the
28 # diskwatcher.tac webport, and env_deepsize_url= pointing at the PHP script.
30 import os, sys, urllib, simplejson
32 if len(sys.argv) > 1 and sys.argv[1] == "config":
34 graph_title Tahoe Overhead Calculator
35 graph_vlabel Percentage
37 graph_info This graph shows the estimated amount of storage overhead (ratio of actual disk usage to ideal disk usage). The 'overhead' number is how much space we could save if we implemented GC, and the 'inactive' number is how much additional space we could save if we could delete data for cancelled accounts.
38 overhead.label disk usage overhead
40 inactive.label inactive account usage
42 effective_expansion.label Effective Expansion Factor
43 effective_expansion.graph no"""
46 diskwatcher_url = os.environ["diskwatcher_url"]
47 total = simplejson.load(urllib.urlopen(diskwatcher_url))["used"]
48 deepsize_url = os.environ["deepsize_url"]
49 deepsize = simplejson.load(urllib.urlopen(deepsize_url))
51 expansion = float(N) / k
53 ideal = expansion * deepsize["all"]
54 overhead = (total - ideal) / ideal
56 # until all the storage-servers come online, this number will be nonsense
57 print "overhead.value %f" % (100.0 * overhead)
60 effective_expansion = total / deepsize["all"]
61 print "effective_expansion.value %f" % effective_expansion
63 # this value remains valid, though
64 inactive_savings = (deepsize["all"] - deepsize["active"]) / deepsize["active"]
65 print "inactive.value %f" % (100.0 * inactive_savings)