cgroup

package
v0.22.3 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CgroupV1FsType          = "cgroup"
	CgroupV2FsType          = "cgroup2"
	CgroupDefaultController = "cpuset"
	CgroupControllersFile   = "/sys/fs/cgroup/cgroup.controllers"
)

Variables

This section is empty.

Functions

func CouldNotFindOrMountDefaultCgroup

func CouldNotFindOrMountDefaultCgroup(ver CgroupVersion) error

func CouldNotOpenFile

func CouldNotOpenFile(file string, err error) error

func ErrorParsingFile

func ErrorParsingFile(file string, err error) error

func GetCgroupControllerHierarchy

func GetCgroupControllerHierarchy(subsys string) (int, error)

Returns a cgroup controller hierarchy value

func GetCgroupPath

func GetCgroupPath(rootDir string, cgroupId uint64, subPath string) (string, time.Time, error)

GetCgroupPath iteratively searches the cgroup filesystem for the directory that matches the given cgroupId and optional subPath. If subPath is empty, all directories within the cgroup filesystem are searched.

Parameters: - rootDir: The root directory of the cgroup filesystem. - cgroupId: The cgroup ID to search for. - subPath: An optional subpath to narrow the search.

Returns: - The path of the found cgroup directory. - The creation time (ctime) of the found cgroup directory. - An error if the directory could not be found or an I/O error occurred.

Note: For cgroupfs, the inode number of a cgroupfs entry matches the cgroup ID. This function leverages this fact by checking if the lower 32 bits of the cgroup ID match the inode number of the entry to identify the desired cgroup directory.

func IsCgroupV2MountedAndDefault

func IsCgroupV2MountedAndDefault() (bool, error)

IsCgroupV2MountedAndDefault tests if cgroup2 is mounted and is the default cgroup version being used by the running environment. It does so by checking the existence of a "cgroup.controllers" file in default cgroupfs mountpoint.

func NoCgroupSupport

func NoCgroupSupport() error

Types

type Cgroup

type Cgroup interface {
	GetMountPoint() string

	GetVersion() CgroupVersion
	// contains filtered or unexported methods
}

func NewCgroup

func NewCgroup(ver CgroupVersion) (Cgroup, error)

type CgroupV1

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

func (*CgroupV1) GetMountPoint

func (c *CgroupV1) GetMountPoint() string

func (*CgroupV1) GetVersion

func (c *CgroupV1) GetVersion() CgroupVersion

type CgroupV2

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

func (*CgroupV2) GetMountPoint

func (c *CgroupV2) GetMountPoint() string

func (*CgroupV2) GetVersion

func (c *CgroupV2) GetVersion() CgroupVersion

type CgroupVersion

type CgroupVersion int
const (
	CgroupVersion1 CgroupVersion = iota
	CgroupVersion2
)

func GetCgroupDefaultVersion

func GetCgroupDefaultVersion() (CgroupVersion, error)

func (CgroupVersion) String

func (v CgroupVersion) String() string

type Cgroups

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

func NewCgroups

func NewCgroups() (*Cgroups, error)

func (*Cgroups) Destroy

func (cs *Cgroups) Destroy() error

func (*Cgroups) GetCgroup

func (cs *Cgroups) GetCgroup(ver CgroupVersion) Cgroup

func (*Cgroups) GetDefaultCgroup

func (cs *Cgroups) GetDefaultCgroup() Cgroup

func (*Cgroups) GetDefaultCgroupHierarchyID

func (cs *Cgroups) GetDefaultCgroupHierarchyID() int

type VersionNotSupported

type VersionNotSupported struct{}

func (*VersionNotSupported) Error

func (c *VersionNotSupported) Error() string

Jump to

Keyboard shortcuts

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