getKVStatsFileContentUint64 gets uint64 parsed content of key-value cgroup stat file
(filePath string, propertyName string)
| 295 | |
| 296 | // getKVStatsFileContentUint64 gets uint64 parsed content of key-value cgroup stat file |
| 297 | func 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 | |
| 321 | func readIoStats(path string) []*stats.IOEntry { |
| 322 | // more details on the io.stat file format: https://www.kernel.org/doc/Documentation/cgroup-v2.txt |
searching dependent graphs…