2008-11-05 01:03:06 +00:00
|
|
|
#!/usr/bin/env python
|
2007-07-05 20:38:15 +00:00
|
|
|
|
|
|
|
# This is a munin plugin to track the number of files that each node's
|
|
|
|
# StorageServer is holding on behalf of other nodes. Each file that has been
|
|
|
|
# uploaded to the mesh (and has shares present on this node) will be counted
|
|
|
|
# here. When there are <= 100 nodes in the mesh, this count will equal the
|
|
|
|
# total number of files that are active in the entire mesh. When there are
|
|
|
|
# 200 nodes present in the mesh, it will represent about half of the total
|
|
|
|
# number.
|
|
|
|
|
|
|
|
# Copy this plugin into /etc/munun/plugins/tahoe-files and then put
|
|
|
|
# the following in your /etc/munin/plugin-conf.d/foo file to let it know
|
|
|
|
# where to find the basedirectory for each node:
|
|
|
|
#
|
2007-07-05 21:38:31 +00:00
|
|
|
# [tahoe-files]
|
2007-07-05 20:38:15 +00:00
|
|
|
# env.basedir_NODE1 /path/to/node1
|
|
|
|
# env.basedir_NODE2 /path/to/node2
|
|
|
|
# env.basedir_NODE3 /path/to/node3
|
|
|
|
#
|
|
|
|
|
2019-03-22 10:40:58 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2007-07-05 20:38:15 +00:00
|
|
|
import os, sys
|
|
|
|
|
|
|
|
nodedirs = []
|
|
|
|
for k,v in os.environ.items():
|
|
|
|
if k.startswith("basedir_"):
|
|
|
|
nodename = k[len("basedir_"):]
|
|
|
|
nodedirs.append( (nodename, v) )
|
|
|
|
nodedirs.sort()
|
|
|
|
|
|
|
|
configinfo = \
|
|
|
|
"""graph_title Allmydata Tahoe Filecount
|
2007-07-05 21:38:31 +00:00
|
|
|
graph_vlabel files
|
2007-07-05 20:38:15 +00:00
|
|
|
graph_category tahoe
|
2007-10-18 19:49:22 +00:00
|
|
|
graph_info This graph shows the number of files hosted by this node's StorageServer
|
|
|
|
"""
|
2007-10-18 19:39:26 +00:00
|
|
|
|
2007-07-05 20:38:15 +00:00
|
|
|
for nodename, basedir in nodedirs:
|
|
|
|
configinfo += "%s.label %s\n" % (nodename, nodename)
|
|
|
|
configinfo += "%s.draw LINE2\n" % (nodename,)
|
|
|
|
|
|
|
|
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
if sys.argv[1] == "config":
|
2019-03-22 10:40:58 +00:00
|
|
|
print(configinfo.rstrip())
|
2007-07-05 20:38:15 +00:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
for nodename, basedir in nodedirs:
|
2011-04-28 05:53:12 +00:00
|
|
|
shares = 0
|
|
|
|
root = os.path.join(basedir, "storage", "shares")
|
|
|
|
|
|
|
|
for dirpath, dirnames, filenames in os.walk(root, topdown=True):
|
|
|
|
if dirpath == root and "incoming" in dirnames:
|
|
|
|
dirnames.remove("incoming")
|
|
|
|
shares += len(filenames)
|
2019-03-22 10:40:58 +00:00
|
|
|
print("%s.value %d" % (nodename, shares))
|
2007-07-05 20:38:15 +00:00
|
|
|
|