source: trunk/misc/operations_helpers/munin/tahoe_files

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