Files
rpi5-health/internal/system_check/ram.go
T
2026-10-05 14:17:03 +02:00

33 lines
666 B
Go

package system_check
import (
"fmt"
"runtime"
)
type MemoryInformation struct {
/*
* The total amount of memory the system has available
*/
SystemMemory uint64
/*
* How much memory is currently unused
*/
AvailableMemory uint64
}
func (memInfo MemoryInformation) GetUsedMemory() uint64 {
return memInfo.SystemMemory - memInfo.AvailableMemory
}
func GetRamInformation() (MemoryInformation, error) {
switch runtime.GOOS {
case "windows":
return getWinRamInfo(getWindowsTools().ProcGlobalMemoryStatusEx), nil
case "linux":
return getLinuxRamInfo()
default:
return MemoryInformation{}, fmt.Errorf("Unsupported OS: \"%s\"", runtime.GOOS)
}
}