(path string)
| 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 |
| 323 | var usage []*stats.IOEntry |
| 324 | fpath := filepath.Join(path, "io.stat") |
| 325 | currentData, err := os.ReadFile(fpath) |
| 326 | if err != nil { |
| 327 | return usage |
| 328 | } |
| 329 | entries := strings.Split(string(currentData), "\n") |
| 330 | |
| 331 | for _, entry := range entries { |
| 332 | parts := strings.Split(entry, " ") |
| 333 | if len(parts) < 2 { |
| 334 | continue |
| 335 | } |
| 336 | majmin := strings.Split(parts[0], ":") |
| 337 | if len(majmin) != 2 { |
| 338 | continue |
| 339 | } |
| 340 | major, err := strconv.ParseUint(majmin[0], 10, 0) |
| 341 | if err != nil { |
| 342 | return usage |
| 343 | } |
| 344 | minor, err := strconv.ParseUint(majmin[1], 10, 0) |
| 345 | if err != nil { |
| 346 | return usage |
| 347 | } |
| 348 | parts = parts[1:] |
| 349 | ioEntry := stats.IOEntry{ |
| 350 | Major: major, |
| 351 | Minor: minor, |
| 352 | } |
| 353 | for _, s := range parts { |
| 354 | keyPairValue := strings.Split(s, "=") |
| 355 | if len(keyPairValue) != 2 { |
| 356 | continue |
| 357 | } |
| 358 | v, err := strconv.ParseUint(keyPairValue[1], 10, 0) |
| 359 | if err != nil { |
| 360 | continue |
| 361 | } |
| 362 | switch keyPairValue[0] { |
| 363 | case "rbytes": |
| 364 | ioEntry.Rbytes = v |
| 365 | case "wbytes": |
| 366 | ioEntry.Wbytes = v |
| 367 | case "rios": |
| 368 | ioEntry.Rios = v |
| 369 | case "wios": |
| 370 | ioEntry.Wios = v |
| 371 | } |
| 372 | } |
| 373 | usage = append(usage, &ioEntry) |
| 374 | } |
| 375 | return usage |
| 376 | } |
| 377 | |
| 378 | func rdmaStats(filepath string) []*stats.RdmaEntry { |
no outgoing calls
no test coverage detected
searching dependent graphs…