From 36f47562c0142209b4dac9eb58eade077d99d909 Mon Sep 17 00:00:00 2001 From: Luca Berruti Date: Sun, 4 Sep 2016 11:57:16 +0200 Subject: [PATCH] Fix: wrong swap values on i686 / 4GB ram. According to sysinfo manpages: swap fields need to be interpreted along with the mem_unit (Unit) field. See also http://stackoverflow.com/a/4229727 --- mem/mem_linux.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mem/mem_linux.go b/mem/mem_linux.go index 7df4c3e..31ec3c5 100644 --- a/mem/mem_linux.go +++ b/mem/mem_linux.go @@ -70,8 +70,8 @@ func SwapMemory() (*SwapMemoryStat, error) { return nil, err } ret := &SwapMemoryStat{ - Total: uint64(sysinfo.Totalswap), - Free: uint64(sysinfo.Freeswap), + Total: uint64(sysinfo.Totalswap) * uint64(sysinfo.Unit), + Free: uint64(sysinfo.Freeswap) * uint64(sysinfo.Unit), } ret.Used = ret.Total - ret.Free //check Infinity