From baf8c94b2e643e41a4319f0ca55e9c66b64970b0 Mon Sep 17 00:00:00 2001 From: mhsanaei Date: Tue, 28 May 2024 15:11:46 +0200 Subject: [PATCH] new - vCPUs --- web/html/xui/index.html | 9 ++++++++- web/service/server.go | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/web/html/xui/index.html b/web/html/xui/index.html index cda44a8e..243a26bf 100644 --- a/web/html/xui/index.html +++ b/web/html/xui/index.html @@ -45,7 +45,12 @@ -
CPU: [[ cpuCoreFormat(status.cpuCores) ]]
+
CPU: [[ cpuCoreFormat(status.cpuCores) ]] + + +
Speed: [[ cpuSpeedFormat(status.cpuSpeedMhz) ]]
@@ -367,6 +372,7 @@ constructor(data) { this.cpu = new CurTotal(0, 0); this.cpuCores = 0; + this.logicalPro = 0; this.cpuSpeedMhz = 0; this.disk = new CurTotal(0, 0); this.loads = [0, 0, 0]; @@ -387,6 +393,7 @@ } this.cpu = new CurTotal(data.cpu, 100); this.cpuCores = data.cpuCores; + this.logicalPro = data.logicalPro; this.cpuSpeedMhz = data.cpuSpeedMhz; this.disk = new CurTotal(data.disk.current, data.disk.total); this.loads = data.loads.map(load => toFixed(load, 2)); diff --git a/web/service/server.go b/web/service/server.go index b2dfd22f..ce7f1994 100644 --- a/web/service/server.go +++ b/web/service/server.go @@ -43,6 +43,7 @@ type Status struct { T time.Time `json:"-"` Cpu float64 `json:"cpu"` CpuCores int `json:"cpuCores"` + LogicalPro int `json:"logicalPro"` CpuSpeedMhz float64 `json:"cpuSpeedMhz"` Mem struct { Current uint64 `json:"current"` @@ -131,6 +132,13 @@ func (s *ServerService) GetStatus(lastStatus *Status) *Status { logger.Warning("get cpu cores count failed:", err) } + status.LogicalPro = runtime.NumCPU() + if p != nil && p.IsRunning() { + status.AppStats.Uptime = p.GetUptime() + } else { + status.AppStats.Uptime = 0 + } + cpuInfos, err := cpu.Info() if err != nil { logger.Warning("get cpu info failed:", err)