MCPcopy Create free account
hub / github.com/prometheus/procfs / parseBtreeWriteStats

Function parseBtreeWriteStats

bcachefs/get.go:369–408  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

367}
368
369func parseBtreeWriteStats(path string) (map[string]BtreeWriteStats, error) {
370 file, err := openIfExists(path)
371 if err != nil {
372 return nil, err
373 }
374 if file == nil {
375 return map[string]BtreeWriteStats{}, nil
376 }
377 defer file.Close()
378
379 stats := make(map[string]BtreeWriteStats)
380 scanner := bufio.NewScanner(file)
381 scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024)
382 lineNum := 0
383 for scanner.Scan() {
384 lineNum++
385 line := scanner.Text()
386 if lineNum == 1 {
387 continue
388 }
389 fields := strings.Fields(line)
390 if len(fields) < 3 {
391 continue
392 }
393 writeType := strings.TrimSuffix(fields[0], ":")
394 count, err := strconv.ParseUint(fields[1], 10, 64)
395 if err != nil {
396 return nil, err
397 }
398 size, err := parseHumanReadableBytes(fields[2])
399 if err != nil {
400 return nil, err
401 }
402 stats[writeType] = BtreeWriteStats{Count: count, SizeBytes: size}
403 }
404 if err := scanner.Err(); err != nil {
405 return nil, err
406 }
407 return stats, nil
408}
409
410func parseDevices(fsPath string) (map[string]*DeviceStats, error) {
411 entries, err := os.ReadDir(fsPath)

Callers 1

readFilesystemStatsMethod · 0.85

Calls 3

openIfExistsFunction · 0.85
parseHumanReadableBytesFunction · 0.85
ErrMethod · 0.80

Tested by

no test coverage detected