cgroups

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Generic unset value that means undefined or not set
	CGROUP_UNSET_VALUE = 0

	// Max cgroup subsystems count that is used from BPF side
	// to define a max index for the default controllers on tasks.
	// For further documentation check BPF part.
	CGROUP_SUBSYS_COUNT = 15

	// The default hierarchy for cgroupv2
	CGROUP_DEFAULT_HIERARCHY = 0
)

Variables

This section is empty.

Functions

func CgroupFsMagicStr

func CgroupFsMagicStr(magic uint64) string

DetectCgroupFSMagic() runs by default DetectCgroupMode() CgroupFsMagicStr() Returns "Cgroupv2" or "Cgroupv1" based on passed magic.

func DetectCgroupFSMagic

func DetectCgroupFSMagic() (uint64, error)

DetectCgroupFSMagic() runs by default DetectCgroupMode() Return the Cgroupfs v1 or v2 that will be used by bpf programs

func DetectDeploymentMode

func DetectDeploymentMode() (uint32, error)

func DiscoverSubSysIds

func DiscoverSubSysIds() error

DiscoverSubSysIds() Discover Cgroup SubSys IDs and indexes. of the corresponding controllers that we are interested in. We need this dynamic behavior since these controllers are compile config.

func GetCgroupFSMagic

func GetCgroupFSMagic() uint64

func GetCgrpControllerName

func GetCgrpControllerName() string

GetCgrpControllerName() returns the name of the controller that is being used as fallback from the css to get cgroup information and track processes.

func GetCgrpHierarchyID

func GetCgrpHierarchyID() uint32

GetCgrpHierarchyID() returns the ID of the Cgroup hierarchy that is used to track processes. This is used for Cgroupv1 as for Cgroupv2 we run in the default hierarchy.

func GetCgrpSubsystemIdx

func GetCgrpSubsystemIdx() uint32

GetCgrpSubsystemIdx() returns the Index of the subsys or hierarchy to be used to track processes.

func GetDeploymentMode

func GetDeploymentMode() uint32

Types

type CgroupModeCode

type CgroupModeCode int
const (
	/* Cgroup Mode:
	 * https://systemd.io/CGROUP_DELEGATION/
	 * But this should work also for non-systemd environments: where
	 * only legacy or unified are available by default.
	 */
	CGROUP_UNDEF   CgroupModeCode = iota
	CGROUP_LEGACY  CgroupModeCode = 1
	CGROUP_HYBRID  CgroupModeCode = 2
	CGROUP_UNIFIED CgroupModeCode = 3
)

func DetectCgroupMode

func DetectCgroupMode() (CgroupModeCode, error)

DetectCgroupMode() Returns the current Cgroup mode that is applied to the system This applies to systemd and non-systemd machines, possible values:

  • CGROUP_UNDEF: undefined
  • CGROUP_LEGACY: Cgroupv1 legacy controllers
  • CGROUP_HYBRID: Cgroupv1 and Cgroupv2 set up by systemd
  • CGROUP_UNIFIED: Pure Cgroupv2 hierarchy

Reference: https://systemd.io/CGROUP_DELEGATION/

func GetCgroupMode

func GetCgroupMode() CgroupModeCode

func (CgroupModeCode) String

func (code CgroupModeCode) String() string

type DeploymentCode

type DeploymentCode int
const (
	// Deployment modes
	DEPLOY_UNKNOWN    DeploymentCode = iota
	DEPLOY_K8S        DeploymentCode = 1  // K8s deployment
	DEPLOY_CONTAINER  DeploymentCode = 2  // Container docker, podman, etc
	DEPLOY_SD_SERVICE DeploymentCode = 10 // Systemd service
	DEPLOY_SD_USER    DeploymentCode = 11 // Systemd user session
)

func (DeploymentCode) String

func (op DeploymentCode) String() string

Jump to

Keyboard shortcuts

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