1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
### Author: Vikas Gorur (http://github.com/vikasgorur)
class dstat_plugin(dstat):
"""
Waiting calls on mounted FUSE filesystems
Displays the number of waiting calls on all mounted FUSE filesystems.
"""
def __init__(self):
self.name = 'fuse'
self.type = 'd'
self.fusectl_path = "/sys/fs/fuse/connections/"
self.dirs = []
def check(self):
info(1, "Module %s is still experimental." % self.filename)
if not os.path.exists(self.fusectl_path):
raise Exception('%s not mounted' % self.fusectl_path)
if len(os.listdir(self.fusectl_path)) == 0:
raise Exception('No fuse filesystems mounted')
def vars(self):
self.dirs = os.listdir(self.fusectl_path)
atleast_one_ok = False
for d in self.dirs:
if os.access(self.fusectl_path + d + "/waiting", os.R_OK):
atleast_one_ok = True
if not atleast_one_ok:
raise Exception('User is not root or no fuse filesystems mounted')
return self.dirs
def extract(self):
for d in self.dirs:
path = self.fusectl_path + d + "/waiting"
if os.path.exists(path):
line = dopen(path).readline()
self.val[d] = int(line)
else:
self.val[d] = 0
# vim:ts=4:sw=4:et
|