summaryrefslogtreecommitdiff
path: root/hw_linux.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-07 07:13:29 -0500
committerJeff Carr <[email protected]>2025-10-07 07:13:29 -0500
commitc5c6afea125875e635efb26da039d83d65e7d67f (patch)
tree8fad7393e2c1f545b7c64e98fb0a919e20e6841c /hw_linux.go
parent99f8eb08bdca46925e5a00d4dda4d9625694b86b (diff)
make this build on darwin
Diffstat (limited to 'hw_linux.go')
-rw-r--r--hw_linux.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/hw_linux.go b/hw_linux.go
new file mode 100644
index 0000000..d3cb116
--- /dev/null
+++ b/hw_linux.go
@@ -0,0 +1,32 @@
+package zoopb
+
+import (
+ "fmt"
+ "runtime"
+
+ "golang.org/x/sys/unix"
+)
+
+// simple memory and cpu count
+func (me *Machine) osGetMemory() {
+ // Get number of CPUs
+ numCPUs := runtime.NumCPU()
+
+ // Get total system memory
+ var sysInfo unix.Sysinfo_t
+ err := unix.Sysinfo(&sysInfo)
+ if err != nil {
+ fmt.Println("Error getting system info:", err)
+ return
+ }
+
+ // Convert memory from bytes to GB
+ m := float64(sysInfo.Totalram) * float64(sysInfo.Unit)
+ me.Memory = int64(m)
+ me.Cpus = int64(numCPUs)
+
+ // totalMemGB := float64(sysInfo.Totalram) * float64(sysInfo.Unit) / (1024 * 1024 * 1024)
+ // Print results
+ // fmt.Printf("Total Memory: %.2f GB\n", totalMemGB)
+ // fmt.Printf("Number of CPUs: %d\n", numCPUs)
+}