(path string)
| 486 | } |
| 487 | |
| 488 | func parseDeviceIODone(path string) (map[string]map[string]uint64, error) { |
| 489 | file, err := openIfExists(path) |
| 490 | if err != nil { |
| 491 | return nil, err |
| 492 | } |
| 493 | if file == nil { |
| 494 | return map[string]map[string]uint64{}, nil |
| 495 | } |
| 496 | defer file.Close() |
| 497 | |
| 498 | stats := make(map[string]map[string]uint64) |
| 499 | scanner := bufio.NewScanner(file) |
| 500 | var currentOp string |
| 501 | |
| 502 | for scanner.Scan() { |
| 503 | line := strings.TrimSpace(scanner.Text()) |
| 504 | if line == "" { |
| 505 | continue |
| 506 | } |
| 507 | if line == "read:" || line == "write:" { |
| 508 | currentOp = strings.TrimSuffix(line, ":") |
| 509 | if _, ok := stats[currentOp]; !ok { |
| 510 | stats[currentOp] = make(map[string]uint64) |
| 511 | } |
| 512 | continue |
| 513 | } |
| 514 | if currentOp == "" { |
| 515 | continue |
| 516 | } |
| 517 | parts := strings.SplitN(line, ":", 2) |
| 518 | if len(parts) != 2 { |
| 519 | continue |
| 520 | } |
| 521 | dataType := strings.TrimSpace(parts[0]) |
| 522 | valueStr := strings.TrimSpace(parts[1]) |
| 523 | value, err := strconv.ParseUint(valueStr, 10, 64) |
| 524 | if err != nil { |
| 525 | return nil, err |
| 526 | } |
| 527 | stats[currentOp][dataType] = value |
| 528 | } |
| 529 | |
| 530 | if err := scanner.Err(); err != nil { |
| 531 | return nil, err |
| 532 | } |
| 533 | return stats, nil |
| 534 | } |
| 535 | |
| 536 | func parseDeviceIOErrors(path string) (map[string]uint64, error) { |
| 537 | file, err := openIfExists(path) |
no test coverage detected