cgroups

package
v0.42.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package cgroups provides utilities to access Linux control group (CGroups) parameters (total memory, for example) for a given process. The original implementation is taken from https://github.com/uber-go/automaxprocs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CGroup

type CGroup struct {
	// contains filtered or unexported fields
}

CGroup represents the data structure for a Linux control group.

func NewCGroup

func NewCGroup(path string) *CGroup

NewCGroup returns a new *CGroup from a given path.

func (*CGroup) ParamPath

func (cg *CGroup) ParamPath(param string) string

ParamPath returns the path of the given cgroup param under itself.

func (*CGroup) Path

func (cg *CGroup) Path() string

Path returns the path of the CGroup*.

type CGroupSubsys

type CGroupSubsys struct {
	ID         int
	Subsystems []string
	Name       string
}

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

type CGroups map[string]*CGroup

CGroups is a map that associates each CGroup with its subsystem name.

func NewCGroups

func NewCGroups(procPathMountInfo, procPathCGroup string) (CGroups, error)

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

func NewCGroupsForCurrentProcess() (CGroups, error)

NewCGroupsForCurrentProcess returns a new *CGroups instance for the current process.

func (CGroups) MemoryQuota

func (cg CGroups) MemoryQuota() (int64, bool, error)

MemoryQuota returns the total memory a It is a result of `memory.limit_in_bytes`. If the value of `memory.limit_in_bytes` was not set (-1) or (9223372036854771712), the method 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL