cgroup

package
v2.39.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CgroupBasePath = "/sys/fs/cgroup/"

	V1CpuacctStatFile        = "cpuacct/cpuacct.stat"
	V1CpuStatFile            = "cpu/cpu.stat"
	V1CpuSharesFile          = "cpu/cpu.shares"
	V1CpuPeriodFile          = "cpu/cpu.cfs_period_us"
	V1CpuQuotaFile           = "cpu/cpu.cfs_quota_us"
	V1CpusetCpusFile         = "cpuset/cpuset.cpus"
	V1MemStatFile            = "memory/memory.stat"
	V1MemTotalFile           = "memory/memory.limit_in_bytes"
	V1MemUsageFile           = "memory/memory.usage_in_bytes"
	V1OutOfMemoryControlFile = "memory/memory.oom_control"
	V1SwapTotalFile          = "memory/memory.memsw.limit_in_bytes"
	V1SwapUsageFile          = "memory/memory.memsw.usage_in_bytes"

	V1UserKey                = "user"
	V1SystemKey              = "system"
	V1CachedKey              = "cache"
	V1SharedKey              = "total_shmem"
	V1ThrottlingTimeKey      = "throttled_time"
	V1ThrottlingThrottledKey = "nr_throttled"
	V1ThrottlingPeriodsKey   = "nr_periods"
	V1OutOfMemoryKey         = "under_oom"
	V1OutOfMemoryKillKey     = "oom_kill"

	V2CpuStatFile    = "cpu.stat"
	V2CpuWeightFile  = "cpu.weight"
	V2CpuMaxFile     = "cpu.max"
	V2CpusetCpusFile = "cpuset.cpus"
	V2MemStatFile    = "memory.stat"
	V2MemTotalFile   = "memory.max"
	V2MemUsageFile   = "memory.current"
	V2MemEventsFile  = "memory.events"
	V2SwapTotalFile  = "memory.swap.max"
	V2SwapUsageFile  = "memory.swap.current"

	V2UserKey                = "user_usec"
	V2SystemKey              = "system_usec"
	V2CachedKey              = "file"
	V2SharedKey              = "shmem"
	V2ThrottlingTimeKey      = "throttled_usec"
	V2ThrottlingThrottledKey = "nr_throttled"
	V2ThrottlingPeriodsKey   = "nr_periods"
	V2OutOfMemoryKey         = "oom"
	V2OutOfMemoryKillKey     = "oom_kill"
	V2DefaultMaxValue        = "max"
)

Variables

View Source
var (
	CpuStatsPath     = "/proc/stat"
	GetNumberOfCores = runtime.NumCPU
)

Functions

func GetMemTotal

func GetMemTotal(filePath string) (uint64, error)

If no memory limit is set for docker container, then memTotal is set to zero and total is set to the host's swap memory total

func GetMemoryLimitInBytes

func GetMemoryLimitInBytes(filePath string) (uint64, error)

func GetTotal

func GetTotal(filePath string) (uint64, error)

func GetV1DefaultMaxValue

func GetV1DefaultMaxValue() string

func IsCgroupV2

func IsCgroupV2(basePath string) bool

func ReadIntegerValueCgroupFile

func ReadIntegerValueCgroupFile(filename string) (uint64, error)

func ReadLines

func ReadLines(filename string) ([]string, error)

func ReadLinesOffsetN

func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error)

func ReadSingleValueCgroupFile

func ReadSingleValueCgroupFile(filename string) (string, error)

Types

type CgroupCPU

type CgroupCPU struct {
	// contains filtered or unexported fields
}

func NewCgroupCPUSource

func NewCgroupCPUSource(basePath string) *CgroupCPU

func (*CgroupCPU) Percentages

func (cgroupCPU *CgroupCPU) Percentages() (DockerCpuPercentages, error)

type CgroupMem

type CgroupMem struct {
	// contains filtered or unexported fields
}

func NewCgroupMemSource

func NewCgroupMemSource(basePath string) *CgroupMem

func (*CgroupMem) VirtualMemoryStat

func (cgroupMem *CgroupMem) VirtualMemoryStat() (*mem.VirtualMemoryStat, error)

func (*CgroupMem) VirtualMemoryStatWithContext added in v2.28.0

func (cgroupMem *CgroupMem) VirtualMemoryStatWithContext(ctx context.Context) (*mem.VirtualMemoryStat, error)

type CgroupSource

type CgroupSource interface {
	Stats() float64
}

type CgroupSwap

type CgroupSwap struct {
	// contains filtered or unexported fields
}

func NewCgroupSwapSource

func NewCgroupSwapSource(basePath string) *CgroupSwap

func (*CgroupSwap) SwapMemoryStat

func (cgroupSwap *CgroupSwap) SwapMemoryStat() (*mem.SwapMemoryStat, error)

type DockerCpuPercentages

type DockerCpuPercentages struct {
	User   float64
	System float64
}

type DockerCpuTimes

type DockerCpuTimes struct {
	// contains filtered or unexported fields
}

type MemoryStat

type MemoryStat struct {
	// contains filtered or unexported fields
}

func GetMemoryStat

func GetMemoryStat(statFile string, cachedKey string, sharedKey string) (MemoryStat, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL