source: trunk/misc/operations_helpers/munin/tahoe_files @ 40963cd

Last change on this file since 40963cd was 55f8408, checked in by heartsucker <heartsucker@…>, at 2019-03-22T10:41:16Z

use print function over print statement in ./misc/ directory

  • Property mode set to 100644
File size: 1.8 KB
Line 
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
21from __future__ import print_function
22
23import os, sys
24
25nodedirs = []
26for k,v in os.environ.items():
27    if k.startswith("basedir_"):
28        nodename = k[len("basedir_"):]
29        nodedirs.append( (nodename, v) )
30nodedirs.sort()
31
32configinfo = \
33"""graph_title Allmydata Tahoe Filecount
34graph_vlabel files
35graph_category tahoe
36graph_info This graph shows the number of files hosted by this node's StorageServer
37"""
38
39for nodename, basedir in nodedirs:
40    configinfo += "%s.label %s\n" % (nodename, nodename)
41    configinfo += "%s.draw LINE2\n" % (nodename,)
42
43
44if len(sys.argv) > 1:
45    if sys.argv[1] == "config":
46        print(configinfo.rstrip())
47        sys.exit(0)
48
49for nodename, basedir in nodedirs:
50    shares = 0
51    root = os.path.join(basedir, "storage", "shares")
52
53    for dirpath, dirnames, filenames in os.walk(root, topdown=True):
54        if dirpath == root and "incoming" in dirnames:
55            dirnames.remove("incoming")
56        shares += len(filenames)
57    print("%s.value %d" % (nodename, shares))
58
Note: See TracBrowser for help on using the repository browser.