GetMachineMemoryCapacity returns the machine's total memory from /proc/meminfo. Returns the total memory capacity as an uint64 (number of bytes).
()
| 173 | // GetMachineMemoryCapacity returns the machine's total memory from /proc/meminfo. |
| 174 | // Returns the total memory capacity as an uint64 (number of bytes). |
| 175 | func 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/) |
no test coverage detected
searching dependent graphs…