dstat_fuse.py (dstat-0.7.3) | : | dstat_fuse.py (dstat-0.7.4) | ||
---|---|---|---|---|
skipping to change at line 20 | skipping to change at line 20 | |||
def __init__(self): | def __init__(self): | |||
self.name = 'fuse' | self.name = 'fuse' | |||
self.type = 'd' | self.type = 'd' | |||
self.fusectl_path = "/sys/fs/fuse/connections/" | self.fusectl_path = "/sys/fs/fuse/connections/" | |||
self.dirs = [] | self.dirs = [] | |||
def check(self): | def check(self): | |||
info(1, "Module %s is still experimental." % self.filename) | info(1, "Module %s is still experimental." % self.filename) | |||
if not os.path.exists(self.fusectl_path): | if not os.path.exists(self.fusectl_path): | |||
raise Exception, "%s not mounted" % self.fusectl_path | raise Exception('%s not mounted' % self.fusectl_path) | |||
if len(os.listdir(self.fusectl_path)) == 0: | if len(os.listdir(self.fusectl_path)) == 0: | |||
raise Exception, "No fuse filesystems mounted" | raise Exception('No fuse filesystems mounted') | |||
def vars(self): | def vars(self): | |||
self.dirs = os.listdir(self.fusectl_path) | self.dirs = os.listdir(self.fusectl_path) | |||
atleast_one_ok = False | atleast_one_ok = False | |||
for d in self.dirs: | for d in self.dirs: | |||
if os.access(self.fusectl_path + d + "/waiting", os.R_OK): | if os.access(self.fusectl_path + d + "/waiting", os.R_OK): | |||
atleast_one_ok = True | atleast_one_ok = True | |||
if not atleast_one_ok: | if not atleast_one_ok: | |||
raise Exception, "User is not root or no fuse filesystems mounted" | raise Exception('User is not root or no fuse filesystems mounted') | |||
return self.dirs | return self.dirs | |||
def extract(self): | def extract(self): | |||
for d in self.dirs: | for d in self.dirs: | |||
path = self.fusectl_path + d + "/waiting" | path = self.fusectl_path + d + "/waiting" | |||
if os.path.exists(path): | if os.path.exists(path): | |||
line = dopen(path).readline() | line = dopen(path).readline() | |||
self.val[d] = long(line) | self.val[d] = int(line) | |||
else: | else: | |||
self.val[d] = 0 | self.val[d] = 0 | |||
# vim:ts=4:sw=4:et | # vim:ts=4:sw=4:et | |||
End of changes. 4 change blocks. | ||||
4 lines changed or deleted | 4 lines changed or added |