Documentation
¶
Overview ¶
Package cgroup reads CPU and memory resource limits from Linux control groups (cgroup v2).
References:
- cgroups(7): https://man7.org/linux/man-pages/man7/cgroups.7.html
- cgroup v2 (cpu.max, memory.max): https://docs.kernel.org/admin-guide/cgroup-v2.html
- /proc/self/cgroup: https://man7.org/linux/man-pages/man7/cgroups.7.html (see "/proc files")
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNoLimit indicates that no cgroup limit is set. ErrNoLimit = errors.New("no cgroup limit set") // ErrV1Detected indicates that cgroup v1 controllers were found. Only v2 is // supported. ErrV1Detected = errors.New("cgroup v1 detected; only v2 is supported") )
Errors.
Functions ¶
This section is empty.
Types ¶
type Cgroup ¶
type Cgroup struct {
// contains filtered or unexported fields
}
Cgroup provides access to cgroup v2 resource limits. Create one with New or NewFromRoot.
func NewFromRoot ¶
NewFromRoot is like New but resolves all filesystem paths relative to root instead of "/". This is useful for testing with a mock filesystem.
func (Cgroup) CPUQuota ¶
CPUQuota returns the CPU quota as a fractional number of CPUs (e.g. 0.5 means half a core). Returns ErrNoLimit if no CPU limit is configured.
func (Cgroup) MemoryLimit ¶
MemoryLimit returns the cgroup memory limit in bytes. Returns ErrNoLimit if no memory limit is configured.
Click to show internal directories.
Click to hide internal directories.