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 GetContainerRelativeCgroupPath(podUID, containerId string) (string, error)
- func GetKubernetesAbsCgroupPath(subsys, suffix string) string
- func GetKubernetesAnyExistAbsCgroupPath(subsys, suffix string) (string, error)
- func GetKubernetesAnyExistRelativeCgroupPath(suffix string) (string, error)
- func GetKubernetesCgroupRootPathWithSubSys(subsys string) []string
- func GetPodAbsCgroupPath(subsys, podUID string) (string, error)
- func InitKubernetesCGroupPath(cgroupType CgroupType, additionalK8SCGroupPath []string)
- func InstrumentedWriteFileIfChange(dir, file, data string) (err error, applied bool, oldData string)
- func IsCPUIdleSupported() bool
- func IsContainerCgroupExist(podUID, containerID string) (bool, error)
- func ParseCgroupNumaValue(cgroupPath, cgroupFile string) (map[string]map[int]uint64, error)
- func ReadTasksFile(file string) ([]string, error)
- type CPUData
- type CPUMetrics
- type CPUSetData
- type CPUSetStats
- type CPUStats
- type CgroupMetrics
- type CgroupType
- type IOCostCtrlMode
- type IOCostModel
- type IOCostModelData
- type IOCostQoSData
- type MemoryData
- type MemoryMetrics
- type MemoryNumaMetrics
- 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" CgroupSubsysIO = "io" // 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" )
const ( IOCostCtrlModeAuto IOCostCtrlMode = "auto" IOCostCtrlModeUser IOCostCtrlMode = "user" IOCostModelLinear IOCostModel = "linear" )
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 absolute cgroup path for container level
func GetContainerRelativeCgroupPath ¶ added in v0.3.0
GetContainerRelativeCgroupPath returns relative cgroup path for container level
func GetKubernetesAbsCgroupPath ¶
GetKubernetesAbsCgroupPath returns absolute cgroup path for kubernetes with the given suffix without considering whether the path exists or not.
func GetKubernetesAnyExistAbsCgroupPath ¶
GetKubernetesAnyExistAbsCgroupPath returns any absolute cgroup path that exists for kubernetes
func GetKubernetesAnyExistRelativeCgroupPath ¶ added in v0.3.0
GetKubernetesAnyExistRelativeCgroupPath returns any relative 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 absolute 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 InstrumentedWriteFileIfChange ¶ added in v0.5.4
func InstrumentedWriteFileIfChange(dir, file, data string) (err error, applied bool, oldData string)
InstrumentedWriteFileIfChange wraps WriteFileIfChange with audit 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 ParseCgroupNumaValue ¶ added in v0.4.1
ParseCgroupNumaValue parse cgroup numa stat files like memory.numa_stat, the format is like "anon N0=1686843392 N1=1069957120 N2=316747776 N3=163962880"
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 IOCostCtrlMode ¶ added in v0.4.0
type IOCostCtrlMode string
type IOCostModel ¶ added in v0.4.0
type IOCostModel string
type IOCostModelData ¶ added in v0.4.0
type IOCostModelData struct { CtrlMode IOCostCtrlMode `json:"ctrl_mode"` //"auto" or "user" Model IOCostModel `json:"model"` // The cost model in use - "linear" ReadBPS uint64 `json:"read_bps"` // read bytes per second ReadSeqIOPS uint64 `json:"read_seq_iops"` // sequential read IOPS ReadRandIOPS uint64 `json:"read_rand_iops"` // random read IOPS WriteBPS uint64 `json:"write_bps"` // wirte bytes per second WriteSeqIOPS uint64 `json:"write_seq_iops"` // sequential write IOPS WriteRandIOPS uint64 `json:"write_rand_iops"` // random write IOPS }
IOCostModelData is the io.cost.model data supported in cgroupv2
func (*IOCostModelData) String ¶ added in v0.4.0
func (iocmd *IOCostModelData) String() string
type IOCostQoSData ¶ added in v0.4.0
type IOCostQoSData struct { Enable uint32 `json:"enable"` // Weight-based control enable CtrlMode IOCostCtrlMode `json:"ctrl_mode"` //"auto" or "user" ReadLatencyPercent float32 `json:"read_latency_percent"` // read latency percentile [0, 100] ReadLatencyUS uint32 `json:"read_latency_us"` // read latency threshold, unit microsecond WriteLatencyPercent float32 `json:"write_latency_percent"` // write latency percentile [0, 100] WriteLatencyUS uint32 `json:"write_latency_us"` // write latency threshold, unit microsecond VrateMin float32 `json:"vrate_min"` // vrate minimum scaling percentage [1, 10000] VrateMax float32 `json:"vrate_max"` // vrate maximum scaling percentage [1, 10000] }
IOCostQoSData is the io.cost.qos data supported in cgroupv2
func (*IOCostQoSData) String ¶ added in v0.4.0
func (iocqd *IOCostQoSData) String() string
type MemoryData ¶
type MemoryData struct { LimitInBytes int64 TCPMemLimitInBytes int64 // SoftLimitInBytes for memory.low // Best effort memory protection, cgroup memory that will not be reclaimed in soft_limit_reclaim phase of kswapd. SoftLimitInBytes int64 // MinInBytes for memory.min // cgroup memory that can never be reclaimed by kswapd. MinInBytes int64 WmarkRatio int32 // SwapMaxInBytes < 0 means disable cgroup-level swap SwapMaxInBytes int64 }
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 MemoryNumaMetrics ¶ added in v0.4.1
MemoryNumaMetrics get per-numa level 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