From 4d48100cfbd559f8245bb7e423cd1af1ce62da2e Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Thu, 7 Apr 2022 09:45:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81/CPU?= =?UTF-8?q?=E7=9B=91=E6=8E=A7=E4=BF=A1=E6=81=AF=E5=A2=9E=E5=8A=A0CPU?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E6=A0=B8=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/client_conn_traffic.go | 21 +++++++++++---------- internal/nodes/node_status_executor.go | 1 + 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/internal/nodes/client_conn_traffic.go b/internal/nodes/client_conn_traffic.go index 22f3ce5..ed3feb6 100644 --- a/internal/nodes/client_conn_traffic.go +++ b/internal/nodes/client_conn_traffic.go @@ -20,20 +20,21 @@ func init() { goman.New(func() { for range ticker.C { // 加入到数据队列中 - if teaconst.InTrafficBytes > 0 { + var inBytes = atomic.LoadUint64(&teaconst.InTrafficBytes) + atomic.StoreUint64(&teaconst.InTrafficBytes, 0) // 重置数据 + if inBytes > 0 { monitor.SharedValueQueue.Add(nodeconfigs.NodeValueItemTrafficIn, maps.Map{ - "total": teaconst.InTrafficBytes, - }) - } - if teaconst.OutTrafficBytes > 0 { - monitor.SharedValueQueue.Add(nodeconfigs.NodeValueItemTrafficOut, maps.Map{ - "total": teaconst.OutTrafficBytes, + "total": inBytes, }) } - // 重置数据 - atomic.StoreUint64(&teaconst.InTrafficBytes, 0) - atomic.StoreUint64(&teaconst.OutTrafficBytes, 0) + var outBytes = atomic.LoadUint64(&teaconst.OutTrafficBytes) + atomic.StoreUint64(&teaconst.OutTrafficBytes, 0) // 重置数据 + if outBytes > 0 { + monitor.SharedValueQueue.Add(nodeconfigs.NodeValueItemTrafficOut, maps.Map{ + "total": outBytes, + }) + } } }) }) diff --git a/internal/nodes/node_status_executor.go b/internal/nodes/node_status_executor.go index 9cacce2..03d94a7 100644 --- a/internal/nodes/node_status_executor.go +++ b/internal/nodes/node_status_executor.go @@ -148,6 +148,7 @@ func (this *NodeStatusExecutor) updateCPU(status *nodeconfigs.NodeStatus) { // 记录监控数据 monitor.SharedValueQueue.Add(nodeconfigs.NodeValueItemCPU, maps.Map{ "usage": status.CPUUsage, + "cores": runtime.NumCPU(), }) if this.cpuLogicalCount == 0 && this.cpuPhysicalCount == 0 {