]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - misc/munin/tahoe_files
quickstart.html: link to snapshots page, sorted with most recent first.
[tahoe-lafs/tahoe-lafs.git] / misc / munin / tahoe_files
1 #!/usr/bin/env python
2
3 # This is a munin plugin to track the number of files that each node's
4 # StorageServer is holding on behalf of other nodes. Each file that has been
5 # uploaded to the mesh (and has shares present on this node) will be counted
6 # here. When there are <= 100 nodes in the mesh, this count will equal the
7 # total number of files that are active in the entire mesh. When there are
8 # 200 nodes present in the mesh, it will represent about half of the total
9 # number.
10
11 # Copy this plugin into /etc/munun/plugins/tahoe-files and then put
12 # the following in your /etc/munin/plugin-conf.d/foo file to let it know
13 # where to find the basedirectory for each node:
14 #
15 #  [tahoe-files]
16 #  env.basedir_NODE1 /path/to/node1
17 #  env.basedir_NODE2 /path/to/node2
18 #  env.basedir_NODE3 /path/to/node3
19 #
20
21 import os, sys
22
23 nodedirs = []
24 for k,v in os.environ.items():
25     if k.startswith("basedir_"):
26         nodename = k[len("basedir_"):]
27         nodedirs.append( (nodename, v) )
28 nodedirs.sort()
29
30 configinfo = \
31 """graph_title Allmydata Tahoe Filecount
32 graph_vlabel files
33 graph_category tahoe
34 graph_info This graph shows the number of files hosted by this node's StorageServer
35 """
36
37 for nodename, basedir in nodedirs:
38     configinfo += "%s.label %s\n" % (nodename, nodename)
39     configinfo += "%s.draw LINE2\n" % (nodename,)
40
41
42 if len(sys.argv) > 1:
43     if sys.argv[1] == "config":
44         print configinfo.rstrip()
45         sys.exit(0)
46
47 for nodename, basedir in nodedirs:
48     files = len(os.listdir(os.path.join(basedir, "storage", "shares")))
49     if os.path.exists(os.path.join(basedir, "storage", "shares", "incoming")):
50         files -= 1 # the 'incoming' directory doesn't count
51     print "%s.value %d" % (nodename, files)
52