mirror of
https://github.com/ARM-software/devlib.git
synced 2025-02-07 05:30:44 +00:00
cgroups: add couple of methods to return the tasks of a CGroup
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
This commit is contained in:
parent
42efd0a2e2
commit
d8ae3aba1a
@ -158,6 +158,23 @@ class Controller(object):
|
|||||||
tasks[int(tid)] = (tname, tcmdline)
|
tasks[int(tid)] = (tname, tcmdline)
|
||||||
return tasks
|
return tasks
|
||||||
|
|
||||||
|
def tasks_count(self, cgroup):
|
||||||
|
try:
|
||||||
|
cg = self._cgroups[cgroup]
|
||||||
|
except KeyError as e:
|
||||||
|
raise ValueError('Unkown group: {}'.format(e))
|
||||||
|
output = self.target.execute(
|
||||||
|
'{} wc -l {}/tasks'.format(
|
||||||
|
self.target.busybox, cg.directory),
|
||||||
|
as_root=True)
|
||||||
|
return int(output.split()[0])
|
||||||
|
|
||||||
|
def tasks_per_group(self):
|
||||||
|
tasks = {}
|
||||||
|
for cg in self.list_all():
|
||||||
|
tasks[cg] = self.tasks_count(cg)
|
||||||
|
return tasks
|
||||||
|
|
||||||
class CGroup(object):
|
class CGroup(object):
|
||||||
|
|
||||||
def __init__(self, controller, name, create=True):
|
def __init__(self, controller, name, create=True):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user