cgroups

package
v3.4.7 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: Apache-2.0 Imports: 18 Imported by: 10

Documentation

Index

Constants

View Source
const (

	// CPU is the cpu controller
	CPU = "cpu"
	// CPUAcct is the cpuacct controller
	CPUAcct = "cpuacct"
	// CPUset is the cpuset controller
	CPUset = "cpuset"
	// Memory is the memory controller
	Memory = "memory"
	// Pids is the pids controller
	Pids = "pids"
	// Blkio is the blkio controller
	Blkio = "blkio"
)

Variables

View Source
var (
	// ErrCgroupDeleted means the cgroup was deleted
	ErrCgroupDeleted = errors.New("cgroup deleted")
	// ErrCgroupV1Rootless means the cgroup v1 were attempted to be used in rootless environment
	ErrCgroupV1Rootless = errors.New("no support for CGroups V1 in rootless environments")
	ErrStatCgroup       = errors.New("no cgroup available for gathering user statistics")
)

Functions

func GetAvailableControllers added in v3.2.0

func GetAvailableControllers(exclude map[string]controllerHandler, cgroup2 bool) ([]string, error)

GetAvailableControllers get string:bool map of all the available controllers

func GetSystemCPUUsage

func GetSystemCPUUsage() (uint64, error)

GetSystemCPUUsage returns the system usage for all the cgroups

func GetUserConnection

func GetUserConnection(uid int) (*systemdDbus.Conn, error)

GetUserConnection returns a user connection to D-BUS

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 BlkIOEntry

type BlkIOEntry struct {
	Op    string
	Major uint64
	Minor uint64
	Value uint64
}

BlkIOEntry describes an entry in the blkio stats

type BlkioMetrics

type BlkioMetrics struct {
	IoServiceBytesRecursive []BlkIOEntry
}

BlkioMetrics keeps usage stats for the blkio cgroup controller

type CPUMetrics

type CPUMetrics struct {
	Usage CPUUsage
}

CPUMetrics keeps stats for the CPU usage

type CPUUsage

type CPUUsage struct {
	Kernel uint64
	Total  uint64
	PerCPU []uint64
}

CPUUsage keeps stats for the CPU usage (unit: nanoseconds)

type CgroupControl

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

CgroupControl controls a cgroup hierarchy

func Load

func Load(path string) (*CgroupControl, error)

Load loads an existing cgroup control

func New

func New(path string, resources *spec.LinuxResources) (*CgroupControl, error)

New creates a new cgroup control

func NewSystemd

func NewSystemd(path string) (*CgroupControl, error)

NewSystemd creates a new cgroup control

func (*CgroupControl) AddPid

func (c *CgroupControl) AddPid(pid int) error

AddPid moves the specified pid to the cgroup

func (*CgroupControl) CreateSystemdUnit

func (c *CgroupControl) CreateSystemdUnit(path string) error

CreateSystemdUnit creates the systemd cgroup

func (*CgroupControl) CreateSystemdUserUnit

func (c *CgroupControl) CreateSystemdUserUnit(path string, uid int) error

CreateSystemdUserUnit creates the systemd cgroup for the specified user

func (*CgroupControl) Delete

func (c *CgroupControl) Delete() error

Delete cleans a cgroup

func (*CgroupControl) DeleteByPath

func (c *CgroupControl) DeleteByPath(path string) error

DeleteByPath deletes the specified cgroup path

func (*CgroupControl) DeleteByPathConn

func (c *CgroupControl) DeleteByPathConn(path string, conn *systemdDbus.Conn) error

DeleteByPathConn deletes the specified cgroup path using the specified dbus connection if needed.

func (*CgroupControl) Stat

func (c *CgroupControl) Stat() (*Metrics, error)

Stat returns usage statistics for the cgroup

func (*CgroupControl) Update

func (c *CgroupControl) Update(resources *spec.LinuxResources) error

Update updates the cgroups

type MemoryMetrics

type MemoryMetrics struct {
	Usage MemoryUsage
}

MemoryMetrics keeps usage stats for the memory cgroup controller

type MemoryUsage

type MemoryUsage struct {
	Usage uint64
	Limit uint64
}

MemoryUsage keeps stats for the memory usage

type Metrics

type Metrics struct {
	CPU    CPUMetrics
	Blkio  BlkioMetrics
	Memory MemoryMetrics
	Pids   PidsMetrics
}

Metrics keeps usage stats for the cgroup controllers

type PidsMetrics

type PidsMetrics struct {
	Current uint64
}

PidsMetrics keeps usage stats for the pids cgroup controller

Jump to

Keyboard shortcuts

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