From 7aa5548f35cd2add551659b173178430265c1b46 Mon Sep 17 00:00:00 2001 From: fatevase Date: Fri, 5 Apr 2024 15:21:33 +0800 Subject: [PATCH] fixed linux mem invalid value. #108 (#124) --- memorycheck.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memorycheck.go b/memorycheck.go index 95e7f8d..4a319c2 100644 --- a/memorycheck.go +++ b/memorycheck.go @@ -50,7 +50,7 @@ func (task *MemoryCheckTask) checkMemory() { if runtime.GOOS == "windows" { cmd = exec.Command("wmic", "OS", "get", "FreePhysicalMemory", "/Value") } else { - cmd = exec.Command("sh", "-c", "free | grep Mem | awk '{print $3/$2 * 100.0}'") + cmd = exec.Command("sh", "-c", "free | awk 'NR==2{print $3/$2 * 100.0}'") } var out bytes.Buffer