Calculate total clients if necessary

This commit is contained in:
Julian Kornberger 2016-07-13 16:50:59 +02:00
parent 4a9b78367c
commit 6450ae05a5
1 changed files with 8 additions and 2 deletions

View File

@ -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
}