MCPcopy Create free account
hub / github.com/containerd/cgroups / percpuUsage

Method percpuUsage

cgroup1/cpuacct.go:72–86  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

70}
71
72func (c *cpuacctController) percpuUsage(path string) ([]uint64, error) {
73 var usage []uint64
74 data, err := os.ReadFile(filepath.Join(c.Path(path), "cpuacct.usage_percpu"))
75 if err != nil {
76 return nil, err
77 }
78 for _, v := range strings.Fields(string(data)) {
79 u, err := strconv.ParseUint(v, 10, 64)
80 if err != nil {
81 return nil, err
82 }
83 usage = append(usage, u)
84 }
85 return usage, nil
86}
87
88func (c *cpuacctController) getUsage(path string) (user uint64, kernel uint64, err error) {
89 statPath := filepath.Join(c.Path(path), "cpuacct.stat")

Callers 1

StatMethod · 0.95

Calls 1

PathMethod · 0.95

Tested by

no test coverage detected