MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / getMemInfo

Method getMemInfo

metric/meminfo_linux.go:15–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13)
14
15func (c *meminfoCollector) getMemInfo() (map[string]float64, error) {
16 file, err := os.Open(procFilePath("meminfo"))
17 if err != nil {
18 return nil, err
19 }
20 defer file.Close()
21
22 info, err := parseMemInfo(file)
23 if _, ok := info["MemAvailable_bytes"]; !ok {
24 if err == nil {
25 free, ok := info["MemFree_bytes"]
26 if ok {
27 buf, ok := info["Buffers_bytes"]
28 if ok {
29 cache, ok := info["Cached_bytes"]
30 if ok {
31 info["MemAvailable_bytes"] = free + buf + cache
32 }
33 }
34 }
35 }
36 }
37 return info, err
38}
39
40func parseMemInfo(r io.Reader) (map[string]float64, error) {
41 var (

Callers 1

UpdateMethod · 0.95

Calls 4

procFilePathFunction · 0.85
parseMemInfoFunction · 0.85
CloseMethod · 0.65
OpenMethod · 0.45

Tested by

no test coverage detected