]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
storage: include disk-free information in the stats-gatherer output
authorBrian Warner <warner@lothar.com>
Wed, 6 Aug 2008 21:06:02 +0000 (14:06 -0700)
committerBrian Warner <warner@lothar.com>
Wed, 6 Aug 2008 21:06:02 +0000 (14:06 -0700)
src/allmydata/storage.py

index fda061ded39881935b0900c5060e49d417636eb6..72cbdaddb9882bf9353032a545dbb8512bbda9be 100644 (file)
@@ -865,6 +865,23 @@ class StorageServer(service.MultiService, Referenceable):
         for category,ld in self.get_latencies().items():
             for name,v in ld.items():
                 stats['storage_server.latencies.%s.%s' % (category, name)] = v
+        try:
+            s = os.statvfs(self.storedir)
+            disk_total = s.f_bsize * s.f_blocks
+            disk_used = s.f_bsize * (s.f_blocks - s.f_bfree)
+            # spacetime predictors should look at the slope of disk_used.
+            disk_avail = s.f_bsize * s.f_bavail # available to non-root users
+            # TODO: include our local policy here: if we stop accepting
+            # shares when the available space drops below 1GB, then include
+            # that fact in disk_avail.
+            #
+            # spacetime predictors should use disk_avail / (d(disk_used)/dt)
+            stats["storage_server.disk_total"] = disk_total
+            stats["storage_server.disk_used"] = disk_used
+            stats["storage_server.disk_avail"] = disk_avail
+        except AttributeError:
+            # os.statvfs is only available on unix
+            pass
         return stats
 
     def allocated_size(self):