From a2e530c78ebc3e3652fadc81003f37297b842547 Mon Sep 17 00:00:00 2001 From: Rassyan Date: Thu, 17 Sep 2020 15:47:57 +0800 Subject: [PATCH] 7.x somehow cause os.cpu.percent=-1, fix it & update to latest --- app/models/overview/Node.scala | 6 ++++-- public/overview.html | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/models/overview/Node.scala b/app/models/overview/Node.scala index f82d480b..5b6629d6 100644 --- a/app/models/overview/Node.scala +++ b/app/models/overview/Node.scala @@ -59,8 +59,10 @@ object Node extends NodeInfo { } def cpuPercent(nodeStats: JsValue): JsNumber = { - val cpu = (nodeStats \ "os" \ "cpu" \ "percent").asOpt[Int].getOrElse(// 5.X - (nodeStats \ "os" \ "cpu_percent").asOpt[Int].getOrElse(0) // FIXME 2.X + val cpu = (nodeStats \ "os" \ "cpu" \ "percent").asOpt[Int].filter(i => i > 0).getOrElse(// 5.X + (nodeStats \ "process" \ "cpu" \ "percent").asOpt[Int].filter(i => i > 0).getOrElse( // 7.X + (nodeStats \ "os" \ "cpu_percent").asOpt[Int].getOrElse(0) // FIXME 2.X + ) ) JsNumber(BigDecimal(cpu)) } diff --git a/public/overview.html b/public/overview.html index b84e0bdd..69d60e79 100644 --- a/public/overview.html +++ b/public/overview.html @@ -75,6 +75,12 @@ +
+ + +
-
- - -