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

Method parseLine

proc_smaps.go:115–138  ·  view source on GitHub ↗
(line string)

Source from the content-addressed store, hash-verified

113}
114
115func (s *ProcSMapsRollup) parseLine(line string) error {
116 kv := strings.SplitN(line, ":", 2)
117 if len(kv) != 2 {
118 return errors.New("invalid net/dev line, missing colon")
119 }
120
121 k := kv[0]
122 if k == "VmFlags" {
123 return nil
124 }
125
126 v := strings.TrimSpace(kv[1])
127 v = strings.TrimSuffix(v, " kB")
128
129 vKBytes, err := strconv.ParseUint(v, 10, 64)
130 if err != nil {
131 return err
132 }
133 vBytes := vKBytes * 1024
134
135 s.addValue(k, vBytes)
136
137 return nil
138}
139
140func (s *ProcSMapsRollup) addValue(k string, vUintBytes uint64) {
141 switch k {

Callers 2

ProcSMapsRollupMethod · 0.95
procSMapsRollupManualMethod · 0.95

Calls 1

addValueMethod · 0.95

Tested by

no test coverage detected