From 6450ae05a5dbb7fdf37925ef26d0a36148835411 Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Wed, 13 Jul 2016 16:50:59 +0200 Subject: [PATCH] Calculate total clients if necessary --- models/nodes.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/models/nodes.go b/models/nodes.go index 842fa3b..2f816b7 100644 --- a/models/nodes.go +++ b/models/nodes.go @@ -111,9 +111,14 @@ func (nodes *Nodes) GetNodesMini() *meshviewer.Nodes { meshviewerNodes.List[nodeID] = node } + // Calculate Total + total := nodeOrigin.Statistics.Clients.Total + if total == 0 { + total = nodeOrigin.Statistics.Clients.Wifi24 + nodeOrigin.Statistics.Clients.Wifi5 + } + node.Statistics = &meshviewer.Statistics{ NodeId: nodeOrigin.Statistics.NodeId, - Clients: nodeOrigin.Statistics.Clients.Total, Gateway: nodeOrigin.Statistics.Gateway, RootFsUsage: nodeOrigin.Statistics.RootFsUsage, LoadAverage: nodeOrigin.Statistics.LoadAverage, @@ -123,6 +128,7 @@ func (nodes *Nodes) GetNodesMini() *meshviewer.Nodes { Processes: nodeOrigin.Statistics.Processes, MeshVpn: nodeOrigin.Statistics.MeshVpn, Traffic: nodeOrigin.Statistics.Traffic, + Clients: total, } } return meshviewerNodes @@ -139,7 +145,7 @@ func (nodes *Nodes) worker() { // // set node as offline (without statistics) for _, node := range nodes.List { - if node.Statistics != nil && nodes.Timestamp.After(node.Lastseen.Add( time.Second * time.Duration (5 * nodes.config.Respondd.CollectInterval ))) { + if node.Statistics != nil && nodes.Timestamp.After(node.Lastseen.Add(time.Second*time.Duration(5*nodes.config.Respondd.CollectInterval))) { if node.Flags != nil { node.Flags.Online = false }