cgroup

package
v1.29.3 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	V1 = iota
	V2
)

Variables

View Source
var (
	ErrContainerIDNotFoundInCgroupPath = errors.New("container id not found in cgroup path")
	ErrCgroupNotFound                  = errors.New("cgroup not found")
)

Functions

func Init

func Init() error

Types

type CPUStat

type CPUStat struct {
	UsageSeconds         float64
	ThrottledTimeSeconds float64
	LimitCores           float64
}

type Cgroup

type Cgroup struct {
	Id               uint64
	Version          Version
	ContainerRuntime ContainerRuntimeID
	ContainerID      string
	Path             string
	// contains filtered or unexported fields
}

func NewFromProcessCgroupFile

func NewFromProcessCgroupFile(filePath string) (*Cgroup, error)

func (Cgroup) CpuStat

func (cg Cgroup) CpuStat() (*CPUStat, error)

func (*Cgroup) CreatedAt

func (cg *Cgroup) CreatedAt() time.Time

func (*Cgroup) IOStat

func (cg *Cgroup) IOStat() (map[string]IOStat, error)

func (*Cgroup) MemoryStat

func (cg *Cgroup) MemoryStat() (*MemoryStat, error)

type Client

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

func NewClient

func NewClient(log *logging.Logger, root string) (*Client, error)

func (*Client) CleanupCgroup added in v1.3.0

func (c *Client) CleanupCgroup(id ID)

func (*Client) DefaultCgroupVersion

func (c *Client) DefaultCgroupVersion() Version

func (*Client) GetCgroupForID

func (c *Client) GetCgroupForID(cgroupID ID) (*Cgroup, error)

func (*Client) GetCgroupsRootPath added in v1.22.0

func (c *Client) GetCgroupsRootPath() string

func (*Client) IsDefaultHierarchy added in v1.4.0

func (c *Client) IsDefaultHierarchy(hierarchyID uint32) bool

func (*Client) LoadCgroup added in v1.3.0

func (c *Client) LoadCgroup(id ID, path string)

type ContainerRuntimeID added in v1.3.0

type ContainerRuntimeID int

Represents the internal ID of a container runtime

const (
	UnknownRuntime ContainerRuntimeID = iota
	DockerRuntime
	ContainerdRuntime
	CrioRuntime
	PodmanRuntime
	GardenRuntime
)

func FromString added in v1.3.0

func FromString(str string) ContainerRuntimeID

func GetContainerIdFromCgroup added in v1.15.0

func GetContainerIdFromCgroup(cgroupPath string) (string, ContainerRuntimeID)

GetContainerIdFromCgroup extracts container id and its runtime from path. It returns the container id and the used runtime.

func (ContainerRuntimeID) String added in v1.3.0

func (runtime ContainerRuntimeID) String() string

type ID added in v1.3.0

type ID = uint64

type IOStat

type IOStat struct {
	ReadOps      uint64
	WriteOps     uint64
	ReadBytes    uint64
	WrittenBytes uint64
}

type MemoryStat

type MemoryStat struct {
	RSS   uint64
	Cache uint64
	Limit uint64
}

type Version

type Version uint8

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

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