MCPcopy
hub / github.com/google/cadvisor / GetMachineMemoryCapacity

Function GetMachineMemoryCapacity

lib/machine/machine.go:175–186  ·  view source on GitHub ↗

GetMachineMemoryCapacity returns the machine's total memory from /proc/meminfo. Returns the total memory capacity as an uint64 (number of bytes).

()

Source from the content-addressed store, hash-verified

173// GetMachineMemoryCapacity returns the machine's total memory from /proc/meminfo.
174// Returns the total memory capacity as an uint64 (number of bytes).
175func GetMachineMemoryCapacity() (uint64, error) {
176 out, err := os.ReadFile("/proc/meminfo")
177 if err != nil {
178 return 0, err
179 }
180
181 memoryCapacity, err := parseCapacity(out, memoryCapacityRegexp)
182 if err != nil {
183 return 0, err
184 }
185 return memoryCapacity, err
186}
187
188// GetMachineMemoryByType returns information about memory capacity and number of DIMMs.
189// Information is retrieved from sysfs edac per-DIMM API (/sys/devices/system/edac/mc/)

Callers 2

GetSpecMethod · 0.92
InfoFunction · 0.85

Calls 2

parseCapacityFunction · 0.85
ReadFileMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…