cgroups

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUndefinedController error = errors.New("undefined controller type")
	ErrDoesNotExist        error = errors.New("cgroup does not exist")
)

Functions

func GetSystemCPUUsage

func GetSystemCPUUsage() (uint64, error)

GetSystemCPUUsage returns the system usage for all the cgroups

func IsCgroup2UnifiedMode

func IsCgroup2UnifiedMode() (bool, error)

IsCgroup2UnifiedMode returns whether we are running in cgroup 2 cgroup2 mode.

func UserOwnsCurrentSystemdCgroup

func UserOwnsCurrentSystemdCgroup() (bool, error)

UserOwnsCurrentSystemdCgroup checks whether the current EUID owns the current cgroup.

Types

type CPUAcct

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

CPUAcct cpuacct control group controller

func NewCPUAcct

func NewCPUAcct(path string) (*CPUAcct, error)

NewCPUAcct create new CPUAcct type

func (*CPUAcct) Stats

func (ca *CPUAcct) Stats() (uint64, error)

Stats get cpuacct stats

type CgroupControl

type CgroupControl interface {
	Stats() (uint64, error)
}

CgroupControl represents a cgroup controller

func CgroupControlFactory

func CgroupControlFactory(ct ControlType, path string) (CgroupControl, error)

CgroupControlFactory generates CgroupControl type based on specified type

type ControlType

type ControlType int

ControlType supported cgroup controller types

const (
	CPUAcctT ControlType = iota
	MemoryT
)

func (ControlType) String

func (ct ControlType) String() string

type Memory

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

Memory memory control group controller

func NewMemory

func NewMemory(path string) (*Memory, error)

NewMemory create new memory cgroup control type

func (*Memory) Stats

func (m *Memory) Stats() (uint64, error)

Stats get memory stats

Jump to

Keyboard shortcuts

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