Documentation ¶
Index ¶
- Constants
- Variables
- func CgroupFsMagicStr(magic uint64) string
- func CgroupNameFromCStr(cstr []byte) string
- func DetectCgroupFSMagic() (uint64, error)
- func DetectDeploymentMode() (uint32, error)
- func DiscoverSubSysIds() error
- func GetCgroupFSMagic() uint64
- func GetCgroupFSPath() string
- func GetCgroupIdFromPath(cgroupPath string) (uint64, error)
- func GetCgrpControllerName() string
- func GetCgrpHierarchyID() uint32
- func GetCgrpSubsystemIdx() uint32
- func GetDeploymentMode() uint32
- func HostCgroupRoot() (string, error)
- type CgroupController
- type CgroupModeCode
- type DeploymentCode
- type FileHandle
Constants ¶
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 ¶
var ( /* Cgroup controllers that we are interested in * are usually the ones that are setup by systemd * or other init programs. */ CgroupControllers = []CgroupController{ {Name: "memory"}, {Name: "pids"}, {Name: "cpuset"}, } )
Functions ¶
func CgroupFsMagicStr ¶
DetectCgroupFSMagic() runs by default DetectCgroupMode() CgroupFsMagicStr() Returns "Cgroupv2" or "Cgroupv1" based on passed magic.
func CgroupNameFromCStr ¶ added in v0.8.4
CgroupNameFromCstr() Returns a Golang string from the passed C language format string.
func DetectCgroupFSMagic ¶
DetectCgroupFSMagic() runs by default DetectCgroupMode() Return the Cgroupfs v1 or v2 that will be used by bpf programs
func DetectDeploymentMode ¶
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 GetCgroupFSPath ¶ added in v0.8.4
func GetCgroupFSPath() string
func GetCgroupIdFromPath ¶ added in v0.8.4
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
func HostCgroupRoot ¶ added in v0.9.0
HostCgroupRoot tries to retrieve the host cgroup root
For cgroupv1, we return the directory of the contoller currently used.
NB(kkourt): for now we are checking /sys/fs/cgroup under host /proc's init. For systems where the cgroup is mounted in a non-standard location, we could also check host's /proc/mounts.
Types ¶
type CgroupController ¶ added in v0.8.4
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
type FileHandle ¶ added in v0.8.4
type FileHandle struct {
Id uint64
}