mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-06 17:50:24 +08:00
优化代码/CPU监控信息增加CPU逻辑核数
This commit is contained in:
@@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user