From: Brian Warner Date: Wed, 6 Aug 2008 21:06:02 +0000 (-0700) Subject: storage: include disk-free information in the stats-gatherer output X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/rgr-080307.php?a=commitdiff_plain;h=0d5c8468e940f0661aee972daf8b99503d8175c8;p=tahoe-lafs%2Ftahoe-lafs.git storage: include disk-free information in the stats-gatherer output --- diff --git a/src/allmydata/storage.py b/src/allmydata/storage.py index fda061de..72cbdadd 100644 --- a/src/allmydata/storage.py +++ b/src/allmydata/storage.py @@ -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):