Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2023-05-25 15:18:23 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2023-05-25 15:18:23 +0300
commit15211f81b1cfa370c94bd8f5af154a1ec0b828f2 (patch)
tree0b02486332bdb940cad42a7fa14eba02ed9a1376 /web/service
parentb3f7a6572efa8a6959b2ea21771e585c9788c2ad (diff)
New - CPU Speed
logical Processors removed
Diffstat (limited to 'web/service')
-rw-r--r--web/service/server.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/web/service/server.go b/web/service/server.go
index cace8eba..198aa590 100644
--- a/web/service/server.go
+++ b/web/service/server.go
@@ -38,11 +38,11 @@ const (
)
type Status struct {
- T time.Time `json:"-"`
- Cpu float64 `json:"cpu"`
- CpuCores int `json:"cpuCores"`
- LogicalProcessors int `json:"logicalProcessors"`
- Mem struct {
+ T time.Time `json:"-"`
+ Cpu float64 `json:"cpu"`
+ CpuCores int `json:"cpuCores"`
+ CpuSpeedMhz float64 `json:"cpuSpeedMhz"`
+ Mem struct {
Current uint64 `json:"current"`
Total uint64 `json:"total"`
} `json:"mem"`
@@ -131,7 +131,15 @@ func (s *ServerService) GetStatus(lastStatus *Status) *Status {
logger.Warning("get cpu cores count failed:", err)
}
- status.LogicalProcessors = runtime.NumCPU()
+ cpuInfos, err := cpu.Info()
+ if err != nil {
+ logger.Warning("get cpu info failed:", err)
+ } else if len(cpuInfos) > 0 {
+ cpuInfo := cpuInfos[0]
+ status.CpuSpeedMhz = cpuInfo.Mhz // setting CPU speed in MHz
+ } else {
+ logger.Warning("could not find cpu info")
+ }
upTime, err := host.Uptime()
if err != nil {