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

Function parseErrors

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

Source from the content-addressed store, hash-verified

262}
263
264func parseErrors(path string) (map[string]ErrorStats, error) {
265 file, err := openIfExists(path)
266 if err != nil {
267 return nil, err
268 }
269 if file == nil {
270 return map[string]ErrorStats{}, nil
271 }
272 defer file.Close()
273
274 stats := make(map[string]ErrorStats)
275
276 scanner := bufio.NewScanner(file)
277 for scanner.Scan() {
278 line := scanner.Text()
279 fields := strings.Fields(line)
280 if len(fields) < 2 {
281 continue
282 }
283 count, err := strconv.ParseUint(fields[1], 10, 64)
284 if err != nil {
285 return nil, err
286 }
287 var ts uint64
288 if len(fields) >= 3 {
289 ts, err = strconv.ParseUint(fields[2], 10, 64)
290 if err != nil {
291 return nil, err
292 }
293 }
294 stats[fields[0]] = ErrorStats{Count: count, Timestamp: ts}
295 }
296 if err := scanner.Err(); err != nil {
297 return nil, err
298 }
299 return stats, nil
300}
301
302func parseCounters(countersPath string) (map[string]CounterStats, error) {
303 entries, err := os.ReadDir(countersPath)

Callers 1

readFilesystemStatsMethod · 0.85

Calls 2

openIfExistsFunction · 0.85
ErrMethod · 0.80

Tested by

no test coverage detected