updated memory calculation and logo
This commit is contained in:
@@ -4,6 +4,7 @@ package system
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"syscall"
|
||||
@@ -29,6 +30,16 @@ func GetInfo(hddPath string) SystemInfo {
|
||||
return info
|
||||
}
|
||||
|
||||
// GetTotalMemoryMB reads total system memory from /proc/meminfo.
|
||||
func GetTotalMemoryMB() (int, error) {
|
||||
info := SystemInfo{}
|
||||
readMemInfo(&info)
|
||||
if info.TotalMemMB == 0 {
|
||||
return 0, fmt.Errorf("could not read MemTotal from /proc/meminfo")
|
||||
}
|
||||
return int(info.TotalMemMB), nil
|
||||
}
|
||||
|
||||
func readMemInfo(info *SystemInfo) {
|
||||
f, err := os.Open("/proc/meminfo")
|
||||
if err != nil {
|
||||
|
||||
@@ -2,7 +2,14 @@
|
||||
|
||||
package system
|
||||
|
||||
import "fmt"
|
||||
|
||||
// GetInfo returns empty system info on non-Linux platforms.
|
||||
func GetInfo(_ string) SystemInfo {
|
||||
return SystemInfo{}
|
||||
}
|
||||
|
||||
// GetTotalMemoryMB is not available on non-Linux platforms.
|
||||
func GetTotalMemoryMB() (int, error) {
|
||||
return 0, fmt.Errorf("/proc/meminfo not available on this platform")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user