From fb258fc66d35b8020bda10f6181a1d4ae6692eea Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Tue, 20 Aug 2019 15:57:30 +0800 Subject: [PATCH] fix AvgLantencyMS --- toolbar/precog/monitor/stats.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/toolbar/precog/monitor/stats.go b/toolbar/precog/monitor/stats.go index 0ea41031..5f80c83b 100644 --- a/toolbar/precog/monitor/stats.go +++ b/toolbar/precog/monitor/stats.go @@ -3,6 +3,7 @@ package monitor import ( "database/sql" "fmt" + "time" "github.com/jinzhu/gorm" log "github.com/sirupsen/logrus" @@ -65,12 +66,16 @@ func (m *monitor) savePeerInfo(peerInfo *peers.PeerInfo) error { return err } - log.Debug("peerInfo.Ping:", peerInfo.Ping) + log.Debugf("peerInfo.Ping: %v", peerInfo.Ping) + ping, err := time.ParseDuration(peerInfo.Ping) + if err != nil { + log.Debugf("Parse ping time err: %v", err) + } ormNodeLiveness := &orm.NodeLiveness{ NodeID: ormNode.ID, BestHeight: ormNode.BestHeight, - AvgLantencyMS: sql.NullInt64{Int64: 1, Valid: true}, + AvgLantencyMS: sql.NullInt64{Int64: ping.Nanoseconds() / 1000, Valid: true}, // PingTimes uint64 // PongTimes uint64 } -- 2.11.0