Documentation
¶
Overview ¶
Package cgroup parses /proc cgroup membership data without cgroup filesystem access.
Index ¶
- func CGroupIDFromEntries(cgroups []ControlGroup) containerutils.CGroupID
- func ContainerContextFromProcCgroupData(data []byte) (containerutils.ContainerID, containerutils.CGroupID)
- func FindContainerIDFromEntries(cgroups []ControlGroup) containerutils.ContainerID
- func ParseCgroupLine(line string) (id, ctrl, path string, err error)
- type ControlGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CGroupIDFromEntries ¶
func CGroupIDFromEntries(cgroups []ControlGroup) containerutils.CGroupID
CGroupIDFromEntries picks a cgroup path string suitable as CGroupID from parsed /proc cgroup lines.
func ContainerContextFromProcCgroupData ¶
func ContainerContextFromProcCgroupData(data []byte) (containerutils.ContainerID, containerutils.CGroupID)
ContainerContextFromProcCgroupData returns container ID and cgroup path id from a single parse of the proc cgroup file.
func FindContainerIDFromEntries ¶
func FindContainerIDFromEntries(cgroups []ControlGroup) containerutils.ContainerID
FindContainerIDFromEntries extracts a container ID from parsed /proc cgroup lines.
func ParseCgroupLine ¶
ParseCgroupLine parses a single line from /proc/[pid]/cgroup.
Types ¶
type ControlGroup ¶
type ControlGroup struct {
// ID unique hierarchy ID
ID int
// Controllers are the list of cgroup controllers bound to the hierarchy
Controllers []string
// Path is the pathname of the control group to which the process
// belongs. It is relative to the mountpoint of the hierarchy.
Path string
}
ControlGroup describes the cgroup membership of a process (paths from /proc).
func MakeControlGroup ¶
func MakeControlGroup(id, ctrl, path string) (ControlGroup, error)
MakeControlGroup builds a ControlGroup from fields returned by ParseCgroupLine.
func ParseProcCgroupDataLenient ¶
func ParseProcCgroupDataLenient(data []byte) []ControlGroup
ParseProcCgroupDataLenient parses /proc/[pid]/cgroup: trims lines, skips empty lines, and skips lines that cannot be parsed or have a non-integer hierarchy id.
func ParseProcCgroupDataStrict ¶
func ParseProcCgroupDataStrict(data []byte) ([]ControlGroup, error)
ParseProcCgroupDataStrict parses the full /proc/[pid]/cgroup file; any non-empty invalid line is an error.
func (ControlGroup) GetContainerContext ¶
func (cg ControlGroup) GetContainerContext() containerutils.ContainerID
GetContainerContext returns the container ID derived from the cgroup path.