package cgroups
import "go.uber.org/automaxprocs/internal/cgroups"
Package cgroups provides utilities to access Linux control group (CGroups) parameters (CPU quota, for example) for a given process.
Index ¶
- Variables
- type CGroup
- func NewCGroup(path string) *CGroup
- func (cg *CGroup) ParamPath(param string) string
- func (cg *CGroup) Path() string
- type CGroupSubsys
- type CGroups
- func NewCGroups(procPathMountInfo, procPathCGroup string) (CGroups, error)
- func NewCGroupsForCurrentProcess() (CGroups, error)
- func (cg CGroups) CPUQuota() (float64, bool, error)
- type CGroups2
- func NewCGroups2ForCurrentProcess() (*CGroups2, error)
- func (cg *CGroups2) CPUQuota() (float64, bool, error)
- type MountPoint
Variables ¶
ErrNotV2 indicates that the system is not using cgroups2.
Types ¶
type CGroup ¶
type CGroup struct {
// contains filtered or unexported fields
}
CGroup represents the data structure for a Linux control group.
func NewCGroup ¶
NewCGroup returns a new *CGroup from a given path.
func (*CGroup) ParamPath ¶
ParamPath returns the path of the given cgroup param under itself.
func (*CGroup) Path ¶
Path returns the path of the CGroup*.
type CGroupSubsys ¶
CGroupSubsys represents the data structure for entities in `/proc/$PID/cgroup`. See also proc(5) for more information.
func NewCGroupSubsysFromLine ¶
func NewCGroupSubsysFromLine(line string) (*CGroupSubsys, error)
NewCGroupSubsysFromLine returns a new *CGroupSubsys by parsing a string in the format of `/proc/$PID/cgroup`
type CGroups ¶
CGroups is a map that associates each CGroup with its subsystem name.
func NewCGroups ¶
NewCGroups returns a new *CGroups from given `mountinfo` and `cgroup` files under for some process under `/proc` file system (see also proc(5) for more information).
func NewCGroupsForCurrentProcess ¶
NewCGroupsForCurrentProcess returns a new *CGroups instance for the current process.
func (CGroups) CPUQuota ¶
CPUQuota returns the CPU quota applied with the CPU cgroup controller. It is a result of `cpu.cfs_quota_us / cpu.cfs_period_us`. If the value of `cpu.cfs_quota_us` was not set (-1), the method returns `(-1, nil)`.
type CGroups2 ¶
type CGroups2 struct {
// contains filtered or unexported fields
}
CGroups2 provides access to cgroups data for systems using cgroups2.
func NewCGroups2ForCurrentProcess ¶
NewCGroups2ForCurrentProcess builds a CGroups2 for the current process.
This returns ErrNotV2 if the system is not using cgroups2.
func (*CGroups2) CPUQuota ¶
CPUQuota returns the CPU quota applied with the CPU cgroup2 controller. It is a result of reading cpu quota and period from cpu.max file. It will return `cpu.max / cpu.period`. If cpu.max is set to max, it returns (-1, false, nil)
type MountPoint ¶
type MountPoint struct { MountID int ParentID int DeviceID string Root string MountPoint string Options []string OptionalFields []string FSType string MountSource string SuperOptions []string }
MountPoint is the data structure for the mount points in `/proc/$PID/mountinfo`. See also proc(5) for more information.
func NewMountPointFromLine ¶
func NewMountPointFromLine(line string) (*MountPoint, error)
NewMountPointFromLine parses a line read from `/proc/$PID/mountinfo` and returns a new *MountPoint.
func (*MountPoint) Translate ¶
func (mp *MountPoint) Translate(absPath string) (string, error)
Translate converts an absolute path inside the *MountPoint's file system to the host file system path in the mount namespace the *MountPoint belongs to.
Source Files ¶
cgroup.go cgroups.go cgroups2.go doc.go errors.go mountpoint.go subsys.go
- Version
- v1.6.0 (latest)
- Published
- Sep 23, 2024
- Platform
- linux/amd64
- Imports
- 9 packages
- Last checked
- 5 hours ago –
Tools for package owners.