MCPcopy
hub / github.com/prometheus/node_exporter / parseFileFDStats

Function parseFileFDStats

collector/filefd_linux.go:68–91  ·  view source on GitHub ↗
(filename string)

Source from the content-addressed store, hash-verified

66}
67
68func parseFileFDStats(filename string) (map[string]string, error) {
69 file, err := os.Open(filename)
70 if err != nil {
71 return nil, err
72 }
73 defer file.Close()
74
75 content, err := io.ReadAll(file)
76 if err != nil {
77 return nil, err
78 }
79 parts := bytes.Split(bytes.TrimSpace(content), []byte("\u0009"))
80 if len(parts) < 3 {
81 return nil, fmt.Errorf("unexpected number of file stats in %q", filename)
82 }
83
84 var fileFDStat = map[string]string{}
85 // The file-nr proc is only 1 line with 3 values.
86 fileFDStat["allocated"] = string(parts[0])
87 // The second value is skipped as it will always be zero in linux 2.6.
88 fileFDStat["maximum"] = string(parts[2])
89
90 return fileFDStat, nil
91}

Callers 2

UpdateMethod · 0.85
TestFileFDStatsFunction · 0.85

Calls 1

CloseMethod · 0.65

Tested by 1

TestFileFDStatsFunction · 0.68