| Server IP : 199.250.200.62 / Your IP : 216.73.217.89 Web Server : Apache System : Linux vps37394.inmotionhosting.com 3.10.0-1160.119.1.vz7.224.4 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64 User : jasonp18 ( 1000) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /usr/local/ssl/share/dstat/ |
Upload File : |
### Author: Dag Wieers <dag$wieers,com>
### FIXME: This module needs infrastructure to provide a list of mountpoints
### FIXME: Would be nice to have a total by default (half implemented)
class dstat_plugin(dstat):
"""
Amount of used and free space per mountpoint.
"""
def __init__(self):
self.nick = ('used', 'free')
self.open('/etc/mtab')
self.cols = 2
def vars(self):
ret = []
for l in self.splitlines():
if len(l) < 6: continue
if l[2] in ('binfmt_misc', 'devpts', 'iso9660', 'none', 'proc', 'sysfs', 'usbfs'): continue
### FIXME: Excluding 'none' here may not be what people want (/dev/shm)
if l[0] in ('devpts', 'none', 'proc', 'sunrpc', 'usbfs'): continue
name = l[1]
res = os.statvfs(name)
if res[0] == 0: continue ### Skip zero block filesystems
ret.append(name)
return ret
def name(self):
return ['/' + os.path.basename(name) for name in self.vars]
def extract(self):
self.val['total'] = (0, 0)
for name in self.vars:
res = os.statvfs(name)
self.val[name] = ( (float(res.f_blocks) - float(res.f_bavail)) * long(res.f_frsize), float(res.f_bavail) * float(res.f_frsize) )
self.val['total'] = (self.val['total'][0] + self.val[name][0], self.val['total'][1] + self.val[name][1])
# vim:ts=4:sw=4:et