]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
munin tahoe_files plugin: fix incorrect file count
authorfrancois <francois@ctrlaltdel.ch>
Thu, 28 Apr 2011 05:53:12 +0000 (22:53 -0700)
committerfrancois <francois@ctrlaltdel.ch>
Thu, 28 Apr 2011 05:53:12 +0000 (22:53 -0700)
fixes #1391

misc/operations_helpers/munin/tahoe_files

index e68b59da68d4e1989ccd5878d19a8d040b6deed2..b6359094680d242f0f006aaa4688e74242eb0f19 100644 (file)
@@ -45,8 +45,12 @@ if len(sys.argv) > 1:
         sys.exit(0)
 
 for nodename, basedir in nodedirs:
-    files = len(os.listdir(os.path.join(basedir, "storage", "shares")))
-    if os.path.exists(os.path.join(basedir, "storage", "shares", "incoming")):
-        files -= 1 # the 'incoming' directory doesn't count
-    print "%s.value %d" % (nodename, files)
+    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)
+    print "%s.value %d" % (nodename, shares)