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

Function parseV21SlabEntry

slab.go:66–120  ·  view source on GitHub ↗

parseV21SlabEntry is used to parse a line from /proc/slabinfo version 2.1.

(line string)

Source from the content-addressed store, hash-verified

64
65// parseV21SlabEntry is used to parse a line from /proc/slabinfo version 2.1.
66func parseV21SlabEntry(line string) (*Slab, error) {
67 // First cleanup whitespace.
68 l := slabSpace.ReplaceAllString(line, " ")
69 s := strings.Split(l, " ")
70 if len(s) != 16 {
71 return nil, fmt.Errorf("%w: unable to parse: %q", ErrFileParse, line)
72 }
73 var err error
74 i := &Slab{Name: s[0]}
75 i.ObjActive, err = strconv.ParseInt(s[1], 10, 64)
76 if err != nil {
77 return nil, err
78 }
79 i.ObjNum, err = strconv.ParseInt(s[2], 10, 64)
80 if err != nil {
81 return nil, err
82 }
83 i.ObjSize, err = strconv.ParseInt(s[3], 10, 64)
84 if err != nil {
85 return nil, err
86 }
87 i.ObjPerSlab, err = strconv.ParseInt(s[4], 10, 64)
88 if err != nil {
89 return nil, err
90 }
91 i.PagesPerSlab, err = strconv.ParseInt(s[5], 10, 64)
92 if err != nil {
93 return nil, err
94 }
95 i.Limit, err = strconv.ParseInt(s[8], 10, 64)
96 if err != nil {
97 return nil, err
98 }
99 i.Batch, err = strconv.ParseInt(s[9], 10, 64)
100 if err != nil {
101 return nil, err
102 }
103 i.SharedFactor, err = strconv.ParseInt(s[10], 10, 64)
104 if err != nil {
105 return nil, err
106 }
107 i.SlabActive, err = strconv.ParseInt(s[13], 10, 64)
108 if err != nil {
109 return nil, err
110 }
111 i.SlabNum, err = strconv.ParseInt(s[14], 10, 64)
112 if err != nil {
113 return nil, err
114 }
115 i.SharedAvail, err = strconv.ParseInt(s[15], 10, 64)
116 if err != nil {
117 return nil, err
118 }
119 return i, nil
120}
121
122// parseSlabInfo21 is used to parse a slabinfo 2.1 file.
123func parseSlabInfo21(r *bytes.Reader) (SlabInfo, error) {

Callers 1

parseSlabInfo21Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected