Documentation
¶
Index ¶
- Constants
- 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 IsCgroup2UnifiedMode() bool
- 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" 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 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 IsCgroup2UnifiedMode ¶
func IsCgroup2UnifiedMode() bool
IsCgroup2UnifiedMode return whether it is in cgroupv2 env
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 uint32 // for cgroupv2 CgroupID uint64 // cgroup path cid SvcID uint64 }
NetClsData set cgroup net data
type PidMetrics ¶
PidMetrics get pid cgroup metrics