From 49a153b7a2b8267fd43d24ecbaad63ec721cd754 Mon Sep 17 00:00:00 2001 From: Geno Date: Mon, 13 Mar 2017 18:36:39 +0100 Subject: [PATCH] [BUGFIX] Memory calc for meshviewer (#38) Discussed in https://github.com/FreifunkBremen/yanic/issues/35 --- meshviewer/meshviewer.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/meshviewer/meshviewer.go b/meshviewer/meshviewer.go index fd3aa3b..f4879b7 100644 --- a/meshviewer/meshviewer.go +++ b/meshviewer/meshviewer.go @@ -69,9 +69,11 @@ func NewStatistics(stats *data.Statistics) *Statistics { total = stats.Clients.Wifi24 + stats.Clients.Wifi5 } /* The Meshviewer could not handle absolute memory output - * calc the used memory as a float witch 100% equal 1.0 + * calc the used memory as a float which 100% equal 1.0 + * calc is coppied from node statuspage (look discussion: + * https://github.com/FreifunkBremen/yanic/issues/35) */ - memoryUsage := (float64(stats.Memory.Total) - float64(stats.Memory.Free)) / float64(stats.Memory.Total) + memoryUsage := 1 - (float64(stats.Memory.Free)+float64(stats.Memory.Buffers)+float64(stats.Memory.Cached))/float64(stats.Memory.Total) return &Statistics{ NodeID: stats.NodeID,