source: trunk/misc/operations_helpers/munin/tahoe_overhead

Last change on this file was b856238, checked in by Alexandre Detiste <alexandre.detiste@…>, at 2024-02-15T15:53:34Z

remove old Python2 future statements

  • Property mode set to 100644
File size: 2.9 KB
Line 
1#!/usr/bin/env python
2
3# This is a munin plugin which pulls total-used data from the server in
4# misc/operations_helpers/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
31import os, sys, urllib, json
32
33if len(sys.argv) > 1 and sys.argv[1] == "config":
34    print("""\
35graph_title Tahoe Overhead Calculator
36graph_vlabel Percentage
37graph_category tahoe
38graph_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.
39overhead.label disk usage overhead
40overhead.draw LINE2
41inactive.label inactive account usage
42inactive.draw LINE1
43effective_expansion.label Effective Expansion Factor
44effective_expansion.graph no""")
45    sys.exit(0)
46
47diskwatcher_url = os.environ["diskwatcher_url"]
48total = json.load(urllib.urlopen(diskwatcher_url))["used"]
49deepsize_url = os.environ["deepsize_url"]
50deepsize = json.load(urllib.urlopen(deepsize_url))
51k = 3; N = 10
52expansion = float(N) / k
53
54ideal = expansion * deepsize["all"]
55overhead = (total - ideal) / ideal
56if overhead > 0:
57    # until all the storage-servers come online, this number will be nonsense
58    print("overhead.value %f" % (100.0 * overhead))
59
60    # same for this one
61    effective_expansion = total / deepsize["all"]
62    print("effective_expansion.value %f" % effective_expansion)
63
64# this value remains valid, though
65inactive_savings = (deepsize["all"] - deepsize["active"]) / deepsize["active"]
66print("inactive.value %f" % (100.0 * inactive_savings))
Note: See TracBrowser for help on using the repository browser.