Cgroups - File /proc/cgroups
This parser reads the content of /proc/cgroups
.
This file shows the control groups information of system.
Sample /proc/cgroups
file:
#subsys_name hierarchy num_cgroups enabled
cpuset 10 48 1
cpu 2 232 1
cpuacct 2 232 1
memory 5 232 1
devices 6 232 1
freezer 3 48 1
net_cls 4 48 1
blkio 9 232 1
perf_event 8 48 1
hugetlb 11 48 1
pids 7 232 1
net_prio 4 48 1
Examples
>>> i_cgroups.get_num_cgroups("memory")
232
>>> i_cgroups.is_subsys_enabled("memory")
True
>>> i_cgroups.data[0].get('hierarchy')
'10'
>>> i_cgroups.subsystems["memory"]["enabled"]
'1'
- class insights.parsers.cgroups.Cgroups(context)[source]
Bases:
Parser
Class
Cgroups
parses the content of the/proc/cgroups
.- data
A list of the subsystem cgroup information
- Type:
list
- subsystems
A dict of all subsystems, key is subsystem name and value is dict with keys: hierarchy, num_cgroups, enabled
- Type:
dict
- get_num_cgroups(i_subsys_name)[source]
Get value of cgroup number for specified subsystem, raise exception if keyword not found.
Example
>>> i_cgroups.get_num_cgroups("memory") 232 >>> i_cgroups.get_num_cgroups('hugetlb') 48
- Parameters:
i_subsys_name (str) -- specified subsystem name.
- Returns:
Int value of the specified subsystem cgroups
- Return type:
value (int)
- Raises:
KeyError -- Exception is raised if given subsystem name is wrong
- is_subsys_enabled(i_subsys_name)[source]
Get enable or not of cgroup of specified subsystem, raise exception if keyword not found.
Example
>>> i_cgroups.is_subsys_enabled("memory") True >>> i_cgroups.is_subsys_enabled('hugetlb') True
- Parameters:
i_subsys_name (str) -- specified subsystem name.
- Returns:
Return True if the cgroup of specified subsystem is enabled, else return False
- Return type:
value (boolean)
- Raises:
KeyError -- Exception is raised if given subsystem name is wrong