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

Function getKVStatsFileContentUint64

cgroup2/utils.go:297–319  ·  view source on GitHub ↗

getKVStatsFileContentUint64 gets uint64 parsed content of key-value cgroup stat file

(filePath string, propertyName string)

Source from the content-addressed store, hash-verified

295
296// getKVStatsFileContentUint64 gets uint64 parsed content of key-value cgroup stat file
297func getKVStatsFileContentUint64(filePath string, propertyName string) uint64 {
298 f, err := os.Open(filePath)
299 if err != nil {
300 return 0
301 }
302 defer f.Close()
303
304 s := bufio.NewScanner(f)
305 for s.Scan() {
306 name, value, err := parseKV(s.Text())
307 if name == propertyName {
308 if err != nil {
309 log.L.WithError(err).Errorf("unable to parse %q as a uint from Cgroup file %q", propertyName, filePath)
310 return 0
311 }
312 return value
313 }
314 }
315 if err = s.Err(); err != nil {
316 log.L.WithError(err).Errorf("error reading Cgroup file %q for property %q", filePath, propertyName)
317 }
318 return 0
319}
320
321func readIoStats(path string) []*stats.IOEntry {
322 // more details on the io.stat file format: https://www.kernel.org/doc/Documentation/cgroup-v2.txt

Callers 2

readHugeTlbStatsFunction · 0.85

Calls 1

parseKVFunction · 0.70

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…