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

Function getSystemCPUUsage

pkg/cmd/container/stats_linux.go:136–144  ·  view source on GitHub ↗

getSystemCPUUsage reads the system's CPU usage from /proc/stat and returns the total CPU usage in nanoseconds and the number of CPUs.

()

Source from the content-addressed store, hash-verified

134// getSystemCPUUsage reads the system's CPU usage from /proc/stat and returns
135// the total CPU usage in nanoseconds and the number of CPUs.
136func getSystemCPUUsage() (cpuUsage uint64, cpuNum uint32, _ error) {
137 f, err := os.Open("/proc/stat")
138 if err != nil {
139 return 0, 0, err
140 }
141 defer f.Close()
142
143 return readSystemCPUUsage(f)
144}
145
146// readSystemCPUUsage parses CPU usage information from a reader providing
147// /proc/stat format data. It returns the total CPU usage in nanoseconds

Callers 1

collectFunction · 0.70

Calls 2

readSystemCPUUsageFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…