OSDN Git Service

add RequiredRttMS
authorHAOYUatHZ <haoyu@protonmail.com>
Mon, 2 Sep 2019 02:19:07 +0000 (10:19 +0800)
committerHAOYUatHZ <haoyu@protonmail.com>
Mon, 2 Sep 2019 02:19:07 +0000 (10:19 +0800)
docs/precog/config_example.json
toolbar/precog/monitor/stats.go

index 8a5f2ec..dcb586b 100644 (file)
@@ -14,6 +14,9 @@
         "log_mode" : true
     },
     "check_frequency_minutes" : 30,
+    "policy" : {
+        "required_rtt_ms" : 2000,
+    },
     "seeds" : [
         {
             "xpub" : "f2767279cd01ed8793808e0542a18958e1a2f3a6b6fe5328ec79596a022bc6f085951a98a631917563f86bb91db9159dd2969ff9d690fc12b250baff2b6f6a1d",
index 13c8818..dd06b7e 100644 (file)
@@ -147,9 +147,9 @@ func (m *monitor) processPeerInfo(dbTx *gorm.DB, peerInfo *peers.PeerInfo) error
        // update latest liveness
        latestLiveness := ormNodeLivenesses[0]
        rttMS := ping.Nanoseconds() / 1000000
-       if rttMS > 0 && rttMS < 2000 {
+       if rttMS > 0 && uint64(rttMS) <= m.cfg.Policy.RequiredRttMS {
                ormNode.Status = common.NodeHealthyStatus
-       } else if rttMS > 2000 {
+       } else if uint64(rttMS) > m.cfg.Policy.RequiredRttMS {
                ormNode.Status = common.NodeCongestedStatus
        }
        if rttMS != 0 {