예제 #1
0
파일: linux.py 프로젝트: karthik101/wtf
    def run(self):
        p = procfs.Proc()
        n_cpu = multiprocessing.cpu_count()
        loadavg = p.loadavg()

        if any(avg > n_cpu for avg in loadavg['average'].values()):
            problem = "High load average (you have %d cores)" % n_cpu
        else:
            problem = False
        loadavg_avg = dict((str(k), v) for k, v in loadavg['average'].items())
        return dict(problem=problem, info="Load avg: %(1).2f (1m), %(5).2f (5m), %(15).2f (15m)" % loadavg_avg)
예제 #2
0
파일: linux.py 프로젝트: karthik101/wtf
    def _df(self):
        def _remove_nodev_and_empty(entry):
            if len(entry) < 2: return False
            if entry[0] == 'nodev': return False
            return True

        p = procfs.Proc()
        physfs = map(lambda entry: entry[1],
                     filter(_remove_nodev_and_empty,
                            map(lambda entry: entry.split('\t'), p.filesystems.split('\n'))))
        mounts = [mountpoint for mountpoint, mountinfo in p.mounts.items()
                  if mountinfo['type'] in physfs and mountpoint not in self._conf.get('ignored', [])]

        mount_df = filter(lambda (_, y): y,
                          [(mountpoint, self._statfs(mountpoint)) for mountpoint in mounts])
        return mount_df
예제 #3
0
def first(proc):
    """Return the first process"""
    return procfs.Proc().processes[0]
예제 #4
0
def proc():
    return procfs.Proc()