"Fossies" - the Fresh Open Source Software Archive

Member "dstat-0.7.4/plugins/dstat_fuse.py" (17 Jan 2019, 1369 Bytes) of package /linux/privat/dstat-0.7.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "dstat_fuse.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 0.7.3_vs_0.7.4.

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