cgroup

package
v0.0.0-...-17244d7 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Blkio     = "blkio"
	Cpu       = "cpu"
	Cpuacct   = "cpuacct"
	Cpuset    = "cpuset"
	Devices   = "devices"
	Freezer   = "freezer"
	Memory    = "memory"
	NetCLS    = "net_cls"
	NetPrio   = "net_prio"
	PerfEvent = "perf_event"
	Pids      = "pids"
)
View Source
const (
	DeleteFlagIgnoreMigration = 1 << iota
	DeleteFlagRecursive
	DeleteFlagEmptyOnly
)

Variables

View Source
var ErrCgroupNotMounted = errors.New("cgroup is not mounted")
View Source
var ErrInvalid = errors.New("invalid operation")
View Source
var ErrNonEmpty = errors.New("group is not empty")
View Source
var ErrSubSysNotMounted = errors.New("cgroup one of the needed subsystems is not mounted")

Functions

func GetProcessControllerPath

func GetProcessControllerPath(pid int, controller string) (string, error)

func GetProcs

func GetProcs(name, controller string) ([]int, error)

func GetSubSysMountPoint

func GetSubSysMountPoint(controller string) string

func GetSubSysMountPoints

func GetSubSysMountPoints(controller string) []string

func GetTasks

func GetTasks(name, controller string) ([]int, error)

func Init

func Init() error

Types

type Cgroup

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

func NewCgroup

func NewCgroup(name string) *Cgroup

func (*Cgroup) AddController

func (cg *Cgroup) AddController(name string) *Controller

func (*Cgroup) AllExist

func (cg *Cgroup) AllExist() bool

func (*Cgroup) AttachCurrentProcess

func (cg *Cgroup) AttachCurrentProcess() error

func (*Cgroup) AttachCurrentTask

func (cg *Cgroup) AttachCurrentTask() error

func (*Cgroup) AttachProcess

func (cg *Cgroup) AttachProcess(pid int) error

func (*Cgroup) AttachTask

func (cg *Cgroup) AttachTask(tid int) error

func (*Cgroup) Create

func (cg *Cgroup) Create(ignoreOwnership bool) (err error)

Create physically create a control group in kernel.

func (*Cgroup) Delete

func (cg *Cgroup) Delete(flags DeleteFlags) (err error)

func (*Cgroup) GetChildren

func (cg *Cgroup) GetChildren(controller string) ([]string, error)

func (*Cgroup) GetController

func (cg *Cgroup) GetController(name string) *Controller

func (*Cgroup) GetProcs

func (cg *Cgroup) GetProcs(controller string) ([]int, error)

func (*Cgroup) GetTasks

func (cg *Cgroup) GetTasks(controller string) ([]int, error)

func (*Cgroup) GetUidGid

func (cg *Cgroup) GetUidGid() (int, int, int, int)

func (*Cgroup) Name

func (cg *Cgroup) Name() string

func (*Cgroup) NewChildGroup

func (cg *Cgroup) NewChildGroup(name string) *Cgroup

func (*Cgroup) NewChildrenGroups

func (cg *Cgroup) NewChildrenGroups(controller string) ([]*Cgroup, error)

func (*Cgroup) SetPermissions

func (cg *Cgroup) SetPermissions(controlDirPerm, controlFilePerm, tasksFilePerm os.FileMode)

func (*Cgroup) SetUidGid

func (cg *Cgroup) SetUidGid(tasksUid, tasksGid, controlUid, controlGid int)

type Controller

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

func (*Controller) Cgroup

func (c *Controller) Cgroup() *Cgroup

func (*Controller) Exists

func (c *Controller) Exists() bool

func (*Controller) GetStats

func (c *Controller) GetStats(fields []string, args ...*uint64) (int, error)

func (*Controller) GetStatsAll

func (c *Controller) GetStatsAll() (map[string]uint64, error)

func (*Controller) GetValueBool

func (c *Controller) GetValueBool(name string) (bool, error)

func (*Controller) GetValueInt64

func (c *Controller) GetValueInt64(name string) (int64, error)

func (*Controller) GetValueString

func (c *Controller) GetValueString(name string) (string, error)

func (*Controller) GetValueUint64

func (c *Controller) GetValueUint64(name string) (uint64, error)

func (*Controller) Name

func (c *Controller) Name() string

func (*Controller) SetValueBool

func (c *Controller) SetValueBool(name string, value bool) error

func (*Controller) SetValueInt64

func (c *Controller) SetValueInt64(name string, value int64) error

func (*Controller) SetValueString

func (c *Controller) SetValueString(name, value string) error

func (*Controller) SetValueUint64

func (c *Controller) SetValueUint64(name string, value uint64) error

type ControllerInfo

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

func GetAllControllers

func GetAllControllers() ([]*ControllerInfo, error)

GetAllControllers list all controllers, including those which are not mounted.

func (*ControllerInfo) Enabled

func (cd *ControllerInfo) Enabled() bool

func (*ControllerInfo) Hierarchy

func (cd *ControllerInfo) Hierarchy() int

Hierarchy is the identification of the controller. Controllers with the same hierarchy ID are mounted together as one hierarchy. Controllers with ID 0 are not currently mounted anywhere.

func (*ControllerInfo) Name

func (cd *ControllerInfo) Name() string

func (*ControllerInfo) NumCgroups

func (cd *ControllerInfo) NumCgroups() int

type DeleteFlags

type DeleteFlags uint

type MountEntry

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

type MountTableItem

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

func GetControllers

func GetControllers() []*MountTableItem

GetControllers list mounted controllers.

func (*MountTableItem) MountPoints

func (item *MountTableItem) MountPoints() []string

func (*MountTableItem) Name

func (item *MountTableItem) Name() string

Jump to

Keyboard shortcuts

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