fix traffic sent and recieved metric

This commit is contained in:
Abhishek Kondur 2023-03-14 07:00:59 +04:00
parent 959ca622e3
commit a701956d99

View file

@ -367,8 +367,16 @@ func updateNodeMetrics(currentNode *models.Node, newMetrics *models.Metrics) boo
currMetric.TotalReceived += oldMetric.TotalReceived
currMetric.TotalSent += oldMetric.TotalSent
} else {
currMetric.TotalReceived += int64(math.Abs(float64(currMetric.TotalReceived) - float64(oldMetric.TotalReceived)))
currMetric.TotalSent += int64(math.Abs(float64(currMetric.TotalSent) - float64(oldMetric.TotalSent)))
if currMetric.TotalReceived < oldMetric.TotalReceived {
currMetric.TotalReceived += oldMetric.TotalReceived
} else {
currMetric.TotalReceived += int64(math.Abs(float64(currMetric.TotalReceived) - float64(oldMetric.TotalReceived)))
}
if currMetric.TotalSent < oldMetric.TotalSent {
currMetric.TotalSent += oldMetric.TotalSent
} else {
currMetric.TotalSent += int64(math.Abs(float64(currMetric.TotalSent) - float64(oldMetric.TotalSent)))
}
}
if currMetric.Uptime == 0 || currMetric.TotalTime == 0 {
currMetric.PercentUp = 0