]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - misc/munin/tahoe_estimate_files
249565e4dba2329809f38454fb530d90f5009ee0
[tahoe-lafs/tahoe-lafs.git] / misc / munin / tahoe_estimate_files
1 #!/usr/bin/env python
2
3 import sys, os.path
4
5 if len(sys.argv) > 1 and sys.argv[1] == "config":
6     print """\
7 graph_title Tahoe File Estimate
8 graph_vlabel files
9 graph_category tahoe
10 graph_info This graph shows the estimated number of files and directories present in the grid
11 files.label files
12 files.draw LINE2"""
13     sys.exit(0)
14
15 # Edit this to point at some subset of storage directories.
16 node_dirs = [os.path.expanduser("~amduser/prodnet/storage1"),
17              os.path.expanduser("~amduser/prodnet/storage2"),
18              os.path.expanduser("~amduser/prodnet/storage3"),
19              os.path.expanduser("~amduser/prodnet/storage4"),
20              ]
21
22 sections = ["aa", "ab", "ac", "ad", "ae", "af", "ag", "ah", "ai", "aj"]
23 # and edit this to reflect your default encoding's "total_shares" value, and
24 # the total number of servers.
25 N = 10
26 num_servers = 20
27
28 index_strings = set()
29 for base in node_dirs:
30     for section in sections:
31         sampledir = os.path.join(base, "storage", "shares", section)
32         indices = os.listdir(sampledir)
33         index_strings.update(indices)
34 unique_strings = len(index_strings)
35
36 # the chance that any given file appears on any given server
37 chance = 1.0 * N / num_servers
38
39 # the chance that the file does *not* appear on the servers that we're
40 # examining
41 no_chance = (1-chance) ** len(node_dirs)
42
43 # if a file has a 25% chance of not appearing in our sample, then we need to
44 # raise our estimate by (1.25/1)
45 correction = 1+no_chance
46 #print "correction", correction
47
48 files = unique_strings * (32*32/len(sections)) * correction
49 print "files.value %d" % int(files)