source: trunk/misc/operations_helpers/munin/tahoe_storagespace

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 amount of disk space each node's
4# StorageServer is consuming on behalf of other nodes. This is where the
5# shares are kept. If there are N nodes present in the mesh, the total space
6# consumed by the entire mesh will be about N times the space reported by
7# this plugin.
8
9# Copy this plugin into /etc/munun/plugins/tahoe_storagespace and then put
10# the following in your /etc/munin/plugin-conf.d/foo file to let it know
11# where to find the basedirectory for each node:
12#
13#  [tahoe_storagespace]
14#  env.basedir_NODE1 /path/to/node1
15#  env.basedir_NODE2 /path/to/node2
16#  env.basedir_NODE3 /path/to/node3
17#
18# Allmydata-tahoe must be installed on the system where this plugin is used,
19# since it imports a utility module from allmydata.utils .
20
21
22import os, sys
23import commands
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
32seriesname = "storage"
33
34configinfo = \
35"""graph_title Allmydata Tahoe Shareholder Space
36graph_vlabel bytes
37graph_category tahoe
38graph_info This graph shows the space consumed by this node's StorageServer
39"""
40
41for nodename, basedir in nodedirs:
42    configinfo += "%s.label %s\n" % (nodename, nodename)
43    configinfo += "%s.draw LINE2\n" % (nodename,)
44
45
46if len(sys.argv) > 1:
47    if sys.argv[1] == "config":
48        print(configinfo.rstrip())
49        sys.exit(0)
50
51for nodename, basedir in nodedirs:
52    cmd = "du --bytes --summarize %s" % os.path.join(basedir, "storage")
53    rc,out = commands.getstatusoutput(cmd)
54    if rc != 0:
55        sys.exit(rc)
56    bytes, extra = out.split()
57    usage = int(bytes)
58    print("%s.value %d" % (nodename, usage))
59
Note: See TracBrowser for help on using the repository browser.