From 26d1d4dcacd6f36412378a5614ca1d5af422a836 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Sun, 1 Sep 2019 14:49:31 +0800 Subject: [PATCH] fix status --- toolbar/precog/monitor/stats.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/toolbar/precog/monitor/stats.go b/toolbar/precog/monitor/stats.go index af5942b9..4a57da3e 100644 --- a/toolbar/precog/monitor/stats.go +++ b/toolbar/precog/monitor/stats.go @@ -146,13 +146,18 @@ func (m *monitor) processPeerInfo(dbTx *gorm.DB, peerInfo *peers.PeerInfo) error // update latest liveness latestLiveness := ormNodeLivenesses[0] - lantencyMS := ping.Nanoseconds() / 1000000 - if lantencyMS != 0 { + rttMS := ping.Nanoseconds() / 1000000 + if rttMS != 0 { ormNode.AvgRttMS = sql.NullInt64{ - Int64: (ormNode.AvgRttMS.Int64*int64(latestLiveness.PongTimes) + lantencyMS) / int64(latestLiveness.PongTimes+1), + Int64: (ormNode.AvgRttMS.Int64*int64(latestLiveness.PongTimes) + rttMS) / int64(latestLiveness.PongTimes+1), Valid: true, } } + if rttMS > 0 && rttMs < 2000 { + ormNode.Status = common.NodeHealthyStatus + } else if rttMS > 2000 { + ormNode.Status = common.NodeCongestedStatus + } latestLiveness.PongTimes += 1 if peerInfo.Height != 0 { latestLiveness.BestHeight = peerInfo.Height -- 2.11.0