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

Function parseNFSOperationStats

mountstats.go:542–592  ·  view source on GitHub ↗

parseNFSOperationStats parses a slice of NFSOperationStats by scanning additional information about per-operation statistics until an empty line is reached.

(s *bufio.Scanner)

Source from the content-addressed store, hash-verified

540// additional information about per-operation statistics until an empty
541// line is reached.
542func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) {
543 const (
544 // Minimum number of expected fields in each per-operation statistics set
545 minFields = 9
546 )
547
548 var ops []NFSOperationStats
549
550 for s.Scan() {
551 ss := strings.Fields(string(s.Bytes()))
552 if len(ss) == 0 {
553 // Must break when reading a blank line after per-operation stats to
554 // enable top-level function to parse the next device entry
555 break
556 }
557
558 if len(ss) < minFields {
559 return nil, fmt.Errorf("%w: invalid NFS per-operations stats: %v", ErrFileParse, ss)
560 }
561
562 // Skip string operation name for integers
563 ns := make([]uint64, 0, minFields-1)
564 for _, st := range ss[1:] {
565 n, err := strconv.ParseUint(st, 10, 64)
566 if err != nil {
567 return nil, err
568 }
569
570 ns = append(ns, n)
571 }
572 opStats := NFSOperationStats{
573 Operation: strings.TrimSuffix(ss[0], ":"),
574 Requests: ns[0],
575 Transmissions: ns[1],
576 MajorTimeouts: ns[2],
577 BytesSent: ns[3],
578 BytesReceived: ns[4],
579 CumulativeQueueMilliseconds: ns[5],
580 CumulativeTotalResponseMilliseconds: ns[6],
581 CumulativeTotalRequestMilliseconds: ns[7],
582 }
583
584 if len(ns) > 8 {
585 opStats.Errors = ns[8]
586 }
587
588 ops = append(ops, opStats)
589 }
590
591 return ops, s.Err()
592}
593
594// parseNFSTransportStats parses a NFSTransportStats line using an input set of
595// integer fields matched to a specific stats version.

Callers 1

parseMountStatsNFSFunction · 0.85

Calls 1

ErrMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…