Documentation ¶
Index ¶
- Constants
- func CheckCgroup2UnifiedMode() bool
- func GetAbsCgroupPath(subsys, suffix string) string
- func GetCgroupParamInt(cgroupPath, cgroupFile string) (int64, error)
- func GetCgroupRootPath(subsys string) string
- func GetContainerAbsCgroupPath(subsys, podUID, containerId string) (string, error)
- func GetKubernetesAbsCgroupPath(subsys, suffix string) string
- func GetKubernetesAnyExistAbsCgroupPath(subsys, suffix string) (string, error)
- func GetKubernetesCgroupRootPathWithSubSys(subsys string) []string
- func GetPodAbsCgroupPath(subsys, podUID string) (string, error)
- func InitKubernetesCGroupPath(cgroupType CgroupType, additionalK8SCGroupPath []string)
- func IsCPUIdleSupported() bool
- func IsContainerCgroupExist(podUID, containerID string) (bool, error)
- func ReadTasksFile(file string) ([]string, error)
- func WriteFileIfChange(dir, file, data string) (error, bool, string)
- type CPUData
- type CPUMetrics
- type CPUSetData
- type CPUSetStats
- type CPUStats
- type CgroupMetrics
- type CgroupType
- type MemoryData
- type MemoryMetrics
- type MemoryStats
- type NetClsData
- type PidMetrics
Constants ¶
const ( // CgroupFSMountPoint default cgroup mount point CgroupFSMountPoint = "/sys/fs/cgroup" // DefaultSelectedSubsys cgroupv1 default select subsys DefaultSelectedSubsys = "cpu" // CgroupTasksFileV1 thread id file for cgroupv1 CgroupTasksFileV1 = "tasks" // CgroupTasksFileV2 thread id file for cgroupv2 CgroupTasksFileV2 = "cgroup.threads" CgroupSubsysCPUSet = "cpuset" CgroupSubsysMemory = "memory" CgroupSubsysCPU = "cpu" // CgroupSubsysNetCls is the net_cls sub-system CgroupSubsysNetCls = "net_cls" PodCgroupPathPrefix = "pod" CgroupFsRootPath = "/kubepods" CgroupFsRootPathBestEffort = "/kubepods/besteffort" CgroupFsRootPathBurstable = "/kubepods/burstable" SystemdRootPath = "/kubepods.slice" SystemdRootPathBestEffort = "/kubepods.slice/kubepods-besteffort.slice" SystemdRootPathBurstable = "/kubepods.slice/kubepods-burstable.slice" )
const ( CgroupTypeCgroupfs = "cgroupfs" CgroupTypeSystemd = "systemd" )
Variables ¶
This section is empty.
Functions ¶
func CheckCgroup2UnifiedMode ¶ added in v0.2.0
func CheckCgroup2UnifiedMode() bool
CheckCgroup2UnifiedMode return whether it is in cgroupv2 env
func GetAbsCgroupPath ¶
GetAbsCgroupPath get absolute cgroup path for relative cgroup path
func GetCgroupParamInt ¶
func GetCgroupRootPath ¶
GetCgroupRootPath get cgroupfs root path compatible with v1 and v2
func GetContainerAbsCgroupPath ¶
GetContainerAbsCgroupPath returns cgroup path for container level
func GetKubernetesAbsCgroupPath ¶
GetKubernetesAbsCgroupPath returns cgroup path for kubernetes with the given suffix without considering whether the path exists or not.
func GetKubernetesAnyExistAbsCgroupPath ¶
GetKubernetesAnyExistAbsCgroupPath returns any cgroup path that exists for kubernetes
func GetKubernetesCgroupRootPathWithSubSys ¶
GetKubernetesCgroupRootPathWithSubSys returns all Cgroup paths to run container for kubernetes, and the returned values are merged with subsys.
func GetPodAbsCgroupPath ¶
GetPodAbsCgroupPath returns cgroup path for pod level
func InitKubernetesCGroupPath ¶
func InitKubernetesCGroupPath(cgroupType CgroupType, additionalK8SCGroupPath []string)
InitKubernetesCGroupPath can only be called once to init dynamic cgroup path configurations. additionalCGroupPath is set because we may have legacy cgroup path settings, so it will be used as an adaptive logic.
func IsCPUIdleSupported ¶ added in v0.2.0
func IsCPUIdleSupported() bool
IsCPUIdleSupported checks if cpu idle supported by checking if the cpu.idle interface file exists
func IsContainerCgroupExist ¶ added in v0.2.0
func ReadTasksFile ¶
Types ¶
type CPUMetrics ¶
CPUMetrics get cpu cgroup metrics
type CPUSetData ¶
CPUSetData set cgroup cpuset data
type CPUSetStats ¶
CPUSetStats get cgroup cpuset data
type CgroupMetrics ¶
type CgroupMetrics struct { CPU *CPUMetrics Memory *MemoryMetrics Pid *PidMetrics }
CgroupMetrics cgroup metrics
type CgroupType ¶
type CgroupType string
CgroupType defines the cgroup type that kubernetes version uses, and CgroupTypeCgroupfs will used as the default one.
type MemoryData ¶
MemoryData set cgroup memory data
type MemoryMetrics ¶
type MemoryMetrics struct { RSS uint64 Cache uint64 Dirty uint64 WriteBack uint64 UsageUsage uint64 KernelUsage uint64 // memory.memsw.usage_in_bytes Reports the total size in // bytes of the memory and swap space used by tasks in the cgroup. MemSWUsage uint64 }
MemoryMetrics get memory cgroup metrics
type MemoryStats ¶
MemoryStats get cgroup memory data
type NetClsData ¶
type NetClsData struct { // ClassID is the class id of the container. ClassID uint32 // CgroupID is used for cgroup v2. CgroupID uint64 // Attributes are some optional attributes. Attributes map[string]string }
NetClsData is the net class data.
type PidMetrics ¶
PidMetrics get pid cgroup metrics