]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - misc/munin/tahoe_overhead
quickstart.html: link to snapshots page, sorted with most recent first.
[tahoe-lafs/tahoe-lafs.git] / misc / munin / tahoe_overhead
1 #!/usr/bin/env python
2
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.
11
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
14 # percentage scale.
15
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
18 # 3.33 .
19
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
26
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.
29
30 import os, sys, urllib, simplejson
31
32 if len(sys.argv) > 1 and sys.argv[1] == "config":
33     print """\
34 graph_title Tahoe Overhead Calculator
35 graph_vlabel Percentage
36 graph_category tahoe
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
39 overhead.draw LINE2
40 inactive.label inactive account usage
41 inactive.draw LINE1
42 effective_expansion.label Effective Expansion Factor
43 effective_expansion.graph no"""
44     sys.exit(0)
45
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))
50 k = 3; N = 10
51 expansion = float(N) / k
52
53 ideal = expansion * deepsize["all"]
54 overhead = (total - ideal) / ideal
55 if overhead > 0:
56     # until all the storage-servers come online, this number will be nonsense
57     print "overhead.value %f" % (100.0 * overhead)
58
59     # same for this one
60     effective_expansion = total / deepsize["all"]
61     print "effective_expansion.value %f" % effective_expansion
62
63 # this value remains valid, though
64 inactive_savings = (deepsize["all"] - deepsize["active"]) / deepsize["active"]
65 print "inactive.value %f" % (100.0 * inactive_savings)