From 816b3fc12ed1eab106970db0cd493c14d0654005 Mon Sep 17 00:00:00 2001 From: Petr Oros Date: Wed, 27 Mar 2013 09:38:07 +0100 Subject: [PATCH] pidstats: Added support for parsing cgroups as a per thread attribute Signed-off-by: Petr Oros --- procfs/procfs.py | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/procfs/procfs.py b/procfs/procfs.py index c0ceec8..533a709 100755 --- a/procfs/procfs.py +++ b/procfs/procfs.py @@ -165,6 +165,8 @@ class process: self.load_cmdline() elif attr == "threads": self.load_threads() + elif attr == "cgroups": + self.load_cgroups() return getattr(self, attr) @@ -181,6 +183,16 @@ class process: # remove thread leader del self.threads[self.pid] + def load_cgroups(self): + f = file("/proc/%d/cgroup" % self.pid) + self.cgroups = "" + for line in reversed(f.readlines()): + if len(self.cgroups): + self.cgroups = self.cgroups + "," + line[:-1] + else: + self.cgroups = line[:-1] + f.close() + class pidstats: def __init__(self, basedir = "/proc"): -- 1.7.1