Documentation ¶
Overview ¶
Package cgroup provides an interface to read and write configuration to cgroup.
Index ¶
- func IsOnlyV2() bool
- type Cgroup
- func (c *Cgroup) CPUQuota() (float64, error)
- func (c *Cgroup) CPUUsage() (uint64, error)
- func (c *Cgroup) Install(res *specs.LinuxResources) error
- func (c *Cgroup) Join() (func(), error)
- func (c *Cgroup) MakePath(controllerName string) string
- func (c *Cgroup) MemoryLimit() (uint64, error)
- func (c *Cgroup) NumCPU() (int, error)
- func (c *Cgroup) Uninstall() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cgroup ¶
type Cgroup struct { Name string `json:"name"` Parents map[string]string `json:"parents"` Own map[string]bool `json:"own"` }
Cgroup represents a group inside all controllers. For example:
Name='/foo/bar' maps to /sys/fs/cgroup/<controller>/foo/bar on all controllers.
If Name is relative, it uses the parent cgroup path to determine the location. For example:
Name='foo/bar' and Parent[ctrl]="/user.slice", then it will map to /sys/fs/cgroup/<ctrl>/user.slice/foo/bar
func NewFromPid ¶
NewFromPid loads cgroup for the given process.
func NewFromSpec ¶
NewFromSpec creates a new Cgroup instance if the spec includes a cgroup path. Returns nil otherwise. Cgroup paths are loaded based on the current process.
func (*Cgroup) Install ¶
func (c *Cgroup) Install(res *specs.LinuxResources) error
Install creates and configures cgroups according to 'res'. If cgroup path already exists, it means that the caller has already provided a pre-configured cgroups, and 'res' is ignored.
func (*Cgroup) Join ¶
Join adds the current process to the all controllers. Returns function that restores cgroup to the original state.
func (*Cgroup) MemoryLimit ¶
MemoryLimit returns the memory limit.