MCPcopy Create free account
hub / github.com/containerd/nerdctl / SetCgroupStatsFields

Function SetCgroupStatsFields

pkg/statsutil/stats_linux.go:41–62  ·  view source on GitHub ↗
(previousStats *ContainerStats, data *v1.Metrics, links []netlink.Link, systemInfo SystemInfo)

Source from the content-addressed store, hash-verified

39}
40
41func SetCgroupStatsFields(previousStats *ContainerStats, data *v1.Metrics, links []netlink.Link, systemInfo SystemInfo) (StatsEntry, error) {
42 cpuPercent := calculateCgroupCPUPercent(previousStats, data, systemInfo)
43 blkRead, blkWrite := calculateCgroupBlockIO(data)
44 mem := calculateCgroupMemUsage(data)
45 memLimit := getCgroupMemLimit(float64(data.Memory.Usage.Limit))
46 memPercent := calculateMemPercent(memLimit, mem)
47 pidsStatsCurrent := data.Pids.Current
48 netRx, netTx := calculateCgroupNetwork(links)
49
50 return StatsEntry{
51 CPUPercentage: cpuPercent,
52 Memory: mem,
53 MemoryPercentage: memPercent,
54 MemoryLimit: memLimit,
55 NetworkRx: netRx,
56 NetworkTx: netTx,
57 BlockRead: float64(blkRead),
58 BlockWrite: float64(blkWrite),
59 PidsCurrent: pidsStatsCurrent,
60 }, nil
61
62}
63
64func SetCgroup2StatsFields(previousStats *ContainerStats, metrics *v2.Metrics, links []netlink.Link) (StatsEntry, error) {
65 cpuPercent := calculateCgroup2CPUPercent(previousStats, metrics)

Callers 1

Calls 6

calculateCgroupBlockIOFunction · 0.85
calculateCgroupMemUsageFunction · 0.85
getCgroupMemLimitFunction · 0.85
calculateMemPercentFunction · 0.85
calculateCgroupNetworkFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…