From cea341c690955299b0cd52f301ea25244db76ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=A5=E5=B1=B1=E5=8F=B2=E9=83=8E?= Date: Thu, 26 Feb 2015 16:23:35 +0900 Subject: [PATCH] mem: add 0 check to darwin.swapmem. --- mem/mem_darwin.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mem/mem_darwin.go b/mem/mem_darwin.go index a454894a..6f901d25 100644 --- a/mem/mem_darwin.go +++ b/mem/mem_darwin.go @@ -92,7 +92,10 @@ func SwapMemory() (*SwapMemoryStat, error) { return nil, err } - u := ((total_v - free_v) / total_v) * 100.0 + u := float64(0) + if total_v != 0 { + u = ((total_v - free_v) / total_v) * 100.0 + } // vm.swapusage shows "M", multiply 1000 ret = &SwapMemoryStat{