tahoe-lafs/misc/munin/tahoe-dirnodes.py

39 lines
1.2 KiB
Python
Raw Normal View History

2007-07-05 20:38:15 +00:00
#! /usr/bin/python
# This is a munin plugin to track the number of directory nodes that a vdrive
# server is maintaining on behalf of other nodes. If a mesh has only one
# vdrive server (or if clients are only bothering to use a single one), then
# this will be equal to the number of dirnodes in use in the entire mesh.
# Copy this plugin into /etc/munun/plugins/tahoe-dirnodes and then put
# the following in your /etc/munin/plugin-conf.d/foo file to let it know
# where to find the basedirectory for the vdrive server.
#
2007-07-05 21:38:31 +00:00
# [tahoe-dirnodes]
2007-07-05 20:38:15 +00:00
# env.basedir /path/to/vdrivenode
import os, sys
nodedir = os.environ["basedir"]
configinfo = \
"""graph_title Allmydata Tahoe Dirnode Count
2007-07-05 21:38:31 +00:00
graph_vlabel dirnodes
2007-07-05 20:38:15 +00:00
graph_category tahoe
graph_info This graph shows the number of directory nodes hosted by this vdrive server
dirnodes.label dirnodes
dirnodes.draw LINE2
"""
2007-07-05 20:38:15 +00:00
if len(sys.argv) > 1:
if sys.argv[1] == "config":
print configinfo.rstrip()
2007-07-05 20:38:15 +00:00
sys.exit(0)
dirnodes = len(os.listdir(os.path.join(nodedir, "vdrive")))
if os.path.exists(os.path.join(nodedir, "vdrive", "root")):
dirnodes -= 1 # the 'root' pointer doesn't count
print "dirnodes.value %d" % dirnodes