Exemplo n.º 1
0
Arquivo: disk.py Projeto: s4z/plumd
 def proc_mounts(self):
     fs_types = self.config.get('fs_types')
     ret = []
     mounts = get_file_list("/proc/mounts")
     filter_chars = self.filter_chars
     mnt_re = self.mnt_re
     tlate_args = self.tlate_args
     for entry in mounts:
         dev, path, fs, opts, d1, d2 = entry.split()
         if mnt_re.match(path) or fs not in fs_types:
             continue
         dev = re.sub("^/dev/", "", dev)
         dev = dev.translate(*tlate_args)
         ret.append((dev, path))
     return ret
Exemplo n.º 2
0
Arquivo: swap.py Projeto: s4z/plumd
    def check(self):
        """Return swap file usage metrics from proc file swap.

        :rtype: plumd.Result
        """
        result = plumd.Result("swap")
        dat = get_file_list(self.proc_file)
        # header: file, type, size, used, priority
        if len(dat) > 1:
            # remove header line
            dat.popleft()
        for entry in dat:
            #sfname, stype, ssize, sused, sprio = ("", None, 0, 0, 0)
            sfname, stype, ssize, sused, sprio = entry.split()
            sname = os.path.basename(sfname)
            mstr = "{0}.used".format(sname)
            result.add(plumd.Float(mstr, sused))
            mstr = "{0}.size".format(sname)
            result.add(plumd.Float(mstr, ssize))
            sfree = float(ssize) - float(sused)
            mstr = "{0}.free".format(sname)
            result.add(plumd.Float(mstr, sfree))
        return [result]