Documentation ¶
Index ¶
- Constants
- Variables
- func EnterPid(cgroupPaths map[string]string, pid int) error
- func FindCgroupMountpoint(cgroupPath, subsystem string) (string, error)
- func FindCgroupMountpointAndRoot(cgroupPath, subsystem string) (string, string, error)
- func FindCgroupMountpointDir() (string, error)
- func GetAllPids(path string) ([]int, error)
- func GetAllSubsystems() ([]string, error)
- func GetClosestMountpointAncestor(dir, mountinfo string) string
- func GetHugePageSize() ([]string, error)
- func GetInitCgroup(subsystem string) (string, error)
- func GetInitCgroupPath(subsystem string) (string, error)
- func GetOwnCgroup(subsystem string) (string, error)
- func GetOwnCgroupPath(subsystem string) (string, error)
- func GetPids(path string) ([]int, error)
- func IsCgroup2UnifiedMode() bool
- func IsNotFound(err error) bool
- func NewNotFoundError(sub string) error
- func ParseCgroupFile(path string) (map[string]string, error)
- func PathExists(path string) bool
- func RemovePaths(paths map[string]string) (err error)
- func WriteCgroupProc(dir string, pid int) error
- type BlkioStatEntry
- type BlkioStats
- type CpuStats
- type CpuUsage
- type HugetlbStats
- type Manager
- type MemoryData
- type MemoryStats
- type Mount
- type NotFoundError
- type PidsStats
- type Stats
- type ThrottlingData
Constants ¶
const ( CgroupNamePrefix = "name=" CgroupProcesses = "cgroup.procs" )
Variables ¶
var HugePageSizeUnitList = []string{"B", "KB", "MB", "GB", "TB", "PB"}
HugePageSizeUnitList is a list of the units used by the linux kernel when naming the HugePage control files. https://www.kernel.org/doc/Documentation/cgroup-v1/hugetlb.txt TODO Since the kernel only use KB, MB and GB; TB and PB should be removed, depends on https://github.com/docker/go-units/commit/a09cd47f892041a4fac473133d181f5aea6fa393
Functions ¶
func FindCgroupMountpointAndRoot ¶ added in v0.0.4
func FindCgroupMountpointDir ¶
func GetAllPids ¶ added in v0.0.7
GetAllPids returns all pids, that were added to cgroup at path and to all its subcgroups.
func GetAllSubsystems ¶
GetAllSubsystems returns all the cgroup subsystems supported by the kernel
func GetHugePageSize ¶
func GetInitCgroup ¶
func GetInitCgroupPath ¶
func GetOwnCgroup ¶
GetOwnCgroup returns the relative path to the cgroup docker is running in.
func GetOwnCgroupPath ¶
func IsCgroup2UnifiedMode ¶
func IsCgroup2UnifiedMode() bool
IsCgroup2UnifiedMode returns whether we are running in cgroup v2 unified mode.
func IsNotFound ¶
func NewNotFoundError ¶
func ParseCgroupFile ¶
ParseCgroupFile parses the given cgroup file, typically from /proc/<pid>/cgroup, into a map of subgroups to cgroup names.
func PathExists ¶
func RemovePaths ¶
RemovePaths iterates over the provided paths removing them. We trying to remove all paths five times with increasing delay between tries. If after all there are not removed cgroups - appropriate error will be returned.
func WriteCgroupProc ¶
WriteCgroupProc writes the specified pid into the cgroup's cgroup.procs file
Types ¶
type BlkioStatEntry ¶
type BlkioStats ¶
type BlkioStats struct { // number of bytes tranferred to and from the block device IoServiceBytesRecursive []BlkioStatEntry `json:"io_service_bytes_recursive,omitempty"` IoServicedRecursive []BlkioStatEntry `json:"io_serviced_recursive,omitempty"` IoQueuedRecursive []BlkioStatEntry `json:"io_queue_recursive,omitempty"` IoServiceTimeRecursive []BlkioStatEntry `json:"io_service_time_recursive,omitempty"` IoWaitTimeRecursive []BlkioStatEntry `json:"io_wait_time_recursive,omitempty"` IoMergedRecursive []BlkioStatEntry `json:"io_merged_recursive,omitempty"` IoTimeRecursive []BlkioStatEntry `json:"io_time_recursive,omitempty"` SectorsRecursive []BlkioStatEntry `json:"sectors_recursive,omitempty"` }
type CpuStats ¶
type CpuStats struct { CpuUsage CpuUsage `json:"cpu_usage,omitempty"` ThrottlingData ThrottlingData `json:"throttling_data,omitempty"` }
type CpuUsage ¶
type CpuUsage struct { // Total CPU time consumed. // Units: nanoseconds. TotalUsage uint64 `json:"total_usage,omitempty"` // Total CPU time consumed per core. // Units: nanoseconds. PercpuUsage []uint64 `json:"percpu_usage,omitempty"` // Time spent by tasks of the cgroup in kernel mode. // Units: nanoseconds. UsageInKernelmode uint64 `json:"usage_in_kernelmode"` // Time spent by tasks of the cgroup in user mode. // Units: nanoseconds. UsageInUsermode uint64 `json:"usage_in_usermode"` }
CpuUsage denotes the usage of a CPU. All CPU stats are aggregate since container inception.
type HugetlbStats ¶
type Manager ¶
type Manager interface { // Applies cgroup configuration to the process with the specified pid Apply(pid int) error // Returns the PIDs inside the cgroup set GetPids() ([]int, error) // Returns the PIDs inside the cgroup set & all sub-cgroups GetAllPids() ([]int, error) // Returns statistics for the cgroup set GetStats() (*Stats, error) // Toggles the freezer cgroup according with specified state Freeze(state configs.FreezerState) error // Destroys the cgroup set Destroy() error // Returns cgroup paths to save in a state file and to be able to // restore the object later. GetPaths() map[string]string // GetUnifiedPath returns the unified path when running in unified mode. // The value corresponds to the all values of GetPaths() map. // // GetUnifiedPath returns error when running in hybrid mode as well as // in legacy mode. GetUnifiedPath() (string, error) // Sets the cgroup as configured. Set(container *configs.Config) error // Gets the cgroup as configured. GetCgroups() (*configs.Cgroup, error) }
type MemoryData ¶
type MemoryStats ¶
type MemoryStats struct { // memory used for cache Cache uint64 `json:"cache,omitempty"` // usage of memory Usage MemoryData `json:"usage,omitempty"` // usage of memory + swap SwapUsage MemoryData `json:"swap_usage,omitempty"` // usage of kernel memory KernelUsage MemoryData `json:"kernel_usage,omitempty"` // usage of kernel TCP memory KernelTCPUsage MemoryData `json:"kernel_tcp_usage,omitempty"` // if true, memory usage is accounted for throughout a hierarchy of cgroups. UseHierarchy bool `json:"use_hierarchy"` Stats map[string]uint64 `json:"stats,omitempty"` }
type Mount ¶
func GetCgroupMounts ¶
GetCgroupMounts returns the mounts for the cgroup subsystems. all indicates whether to return just the first instance or all the mounts.
type NotFoundError ¶
type NotFoundError struct {
Subsystem string
}
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type Stats ¶
type Stats struct { CpuStats CpuStats `json:"cpu_stats,omitempty"` MemoryStats MemoryStats `json:"memory_stats,omitempty"` PidsStats PidsStats `json:"pids_stats,omitempty"` BlkioStats BlkioStats `json:"blkio_stats,omitempty"` // the map is in the format "size of hugepage: stats of the hugepage" HugetlbStats map[string]HugetlbStats `json:"hugetlb_stats,omitempty"` }
type ThrottlingData ¶
type ThrottlingData struct { // Number of periods with throttling active Periods uint64 `json:"periods,omitempty"` // Number of periods when the container hit its throttling limit. ThrottledPeriods uint64 `json:"throttled_periods,omitempty"` // Aggregate time the container was throttled for in nanoseconds. ThrottledTime uint64 `json:"throttled_time,omitempty"` }
Directories ¶
Path | Synopsis |
---|---|
devicefilter
Package devicefilter containes eBPF device filter program The implementation is based on https://github.com/containers/crun/blob/0.10.2/src/libcrun/ebpf.c Although ebpf.c is originally licensed under LGPL-3.0-or-later, the author (Giuseppe Scrivano) agreed to relicense the file in Apache License 2.0: https://github.com/opencontainers/runc/issues/2144#issuecomment-543116397
|
Package devicefilter containes eBPF device filter program The implementation is based on https://github.com/containers/crun/blob/0.10.2/src/libcrun/ebpf.c Although ebpf.c is originally licensed under LGPL-3.0-or-later, the author (Giuseppe Scrivano) agreed to relicense the file in Apache License 2.0: https://github.com/opencontainers/runc/issues/2144#issuecomment-543116397 |