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

Function ParseStats

xfs/parse.go:27–196  ·  view source on GitHub ↗

ParseStats parses a Stats from an input io.Reader, using the format found in /proc/fs/xfs/stat.

(r io.Reader)

Source from the content-addressed store, hash-verified

25// ParseStats parses a Stats from an input io.Reader, using the format
26// found in /proc/fs/xfs/stat.
27func ParseStats(r io.Reader) (*Stats, error) {
28 const (
29 // Fields parsed into stats structures.
30 fieldExtentAlloc = "extent_alloc"
31 fieldAbt = "abt"
32 fieldBlkMap = "blk_map"
33 fieldBmbt = "bmbt"
34 fieldDir = "dir"
35 fieldTrans = "trans"
36 fieldIg = "ig"
37 fieldLog = "log"
38 fieldPushAil = "push_ail"
39 fieldXstrat = "xstrat"
40 fieldRw = "rw"
41 fieldAttr = "attr"
42 fieldIcluster = "icluster"
43 fieldVnodes = "vnodes"
44 fieldBuf = "buf"
45 fieldXpc = "xpc"
46 fieldAbtb2 = "abtb2"
47 fieldAbtc2 = "abtc2"
48 fieldBmbt2 = "bmbt2"
49 fieldIbt2 = "ibt2"
50 fieldFibt2 = "fibt2"
51 fieldRmapbt = "rmapbt"
52 fieldRefcntbt = "refcntbt"
53 fieldRmapbtMem = "rmapbt_mem"
54 fieldRcbagbt = "rcbagbt"
55 fieldRtrmapbt = "rtrmapbt"
56 fieldRtrmapbtMem = "rtrmapbt_mem"
57 fieldRtrefcntbt = "rtrefcntbt"
58 fieldQm = "qm"
59 fieldDebug = "debug"
60 fieldZoned = "zoned"
61 fieldMetaFile = "metafile"
62 fieldDeferRelog = "defer_relog"
63 )
64
65 var xfss Stats
66
67 s := bufio.NewScanner(r)
68 for s.Scan() {
69 // Expect at least a string label and a single integer value, ex:
70 // - abt 0
71 // - rw 1 2
72 // - gc xpc 123 (two-word label)
73 ss := strings.Fields(string(s.Bytes()))
74 if len(ss) < 2 {
75 continue
76 }
77 label := ss[0]
78
79 // Special case: "gc xpc" is a two-word label in the kernel output.
80 if label == "gc" && len(ss) >= 3 && ss[1] == "xpc" {
81 us, err := util.ParseUint64s(ss[2:])
82 if err != nil {
83 return nil, err
84 }

Callers 4

TestParseStatsLinux614Function · 0.92
TestParseStatsLinux70Function · 0.92
ProcStatMethod · 0.85
SysStatsMethod · 0.85

Calls 15

ParseUint64sFunction · 0.92
ParseUint32sFunction · 0.92
gcXpcStatsFunction · 0.85
extendedPrecisionStatsFunction · 0.85
deferRelogStatsFunction · 0.85
extentAllocationStatsFunction · 0.85
btreeStatsFunction · 0.85
blockMappingStatsFunction · 0.85
directoryOperationStatsFunction · 0.85
transactionStatsFunction · 0.85
inodeOperationStatsFunction · 0.85
logOperationStatsFunction · 0.85

Tested by 2

TestParseStatsLinux614Function · 0.74
TestParseStatsLinux70Function · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…