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

Function SetCgroup2StatsFields

pkg/statsutil/stats_linux.go:64–85  ·  view source on GitHub ↗
(previousStats *ContainerStats, metrics *v2.Metrics, links []netlink.Link)

Source from the content-addressed store, hash-verified

62}
63
64func SetCgroup2StatsFields(previousStats *ContainerStats, metrics *v2.Metrics, links []netlink.Link) (StatsEntry, error) {
65 cpuPercent := calculateCgroup2CPUPercent(previousStats, metrics)
66 blkRead, blkWrite := calculateCgroup2IO(metrics)
67 mem := calculateCgroup2MemUsage(metrics)
68 memLimit := getCgroupMemLimit(float64(metrics.Memory.UsageLimit))
69 memPercent := calculateMemPercent(memLimit, mem)
70 pidsStatsCurrent := metrics.Pids.Current
71 netRx, netTx := calculateCgroupNetwork(links)
72
73 return StatsEntry{
74 CPUPercentage: cpuPercent,
75 Memory: mem,
76 MemoryPercentage: memPercent,
77 MemoryLimit: memLimit,
78 NetworkRx: netRx,
79 NetworkTx: netTx,
80 BlockRead: float64(blkRead),
81 BlockWrite: float64(blkWrite),
82 PidsCurrent: pidsStatsCurrent,
83 }, nil
84
85}
86
87func getCgroupMemLimit(memLimit float64) float64 {
88 if memLimit == float64(^uint64(0)) {

Callers 1

Calls 6

calculateCgroup2IOFunction · 0.85
calculateCgroup2MemUsageFunction · 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…