mirror of
https://github.com/oneclickvirt/basics.git
synced 2025-10-06 17:17:15 +08:00
update
This commit is contained in:
@@ -85,7 +85,7 @@ func getCpuInfo(ret *model.SystemInfo, cpuType string) (*model.SystemInfo, error
|
|||||||
ret.CpuModel = strings.TrimSpace(strings.Join(fields[1:], " "))
|
ret.CpuModel = strings.TrimSpace(strings.Join(fields[1:], " "))
|
||||||
} else if strings.Contains(fields[0], "cache size") {
|
} else if strings.Contains(fields[0], "cache size") {
|
||||||
ret.CpuCache = strings.TrimSpace(strings.Join(fields[1:], " "))
|
ret.CpuCache = strings.TrimSpace(strings.Join(fields[1:], " "))
|
||||||
} else if strings.Contains(fields[0], "cpu MHz") {
|
} else if strings.Contains(fields[0], "cpu MHz") && !strings.Contains(ret.CpuModel, "@") {
|
||||||
ret.CpuModel += " @ " + strings.TrimSpace(strings.Join(fields[1:], " ")) + " MHz"
|
ret.CpuModel += " @ " + strings.TrimSpace(strings.Join(fields[1:], " ")) + " MHz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,9 +102,9 @@ func getCpuInfo(ret *model.SystemInfo, cpuType string) (*model.SystemInfo, error
|
|||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
fields := strings.Split(line, ":")
|
fields := strings.Split(line, ":")
|
||||||
if len(fields) >= 2 {
|
if len(fields) >= 2 {
|
||||||
if strings.Contains(fields[0], "Model name") {
|
if strings.Contains(fields[0], "Model name") && !strings.Contains(fields[0], "BIOS Model name") && ret.CpuModel == "" {
|
||||||
ret.CpuModel = strings.TrimSpace(strings.Join(fields[1:], " "))
|
ret.CpuModel = strings.TrimSpace(strings.Join(fields[1:], " "))
|
||||||
} else if strings.Contains(fields[0], "CPU MHz") {
|
} else if strings.Contains(fields[0], "CPU MHz") && !strings.Contains(ret.CpuModel, "@") {
|
||||||
ret.CpuModel += " @ " + strings.TrimSpace(strings.Join(fields[1:], " ")) + " MHz"
|
ret.CpuModel += " @ " + strings.TrimSpace(strings.Join(fields[1:], " ")) + " MHz"
|
||||||
} else if strings.Contains(fields[0], "L1d cache") {
|
} else if strings.Contains(fields[0], "L1d cache") {
|
||||||
L1dcache = strings.TrimSpace(strings.Join(fields[1:], " "))
|
L1dcache = strings.TrimSpace(strings.Join(fields[1:], " "))
|
||||||
|
@@ -3,6 +3,7 @@ package system
|
|||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/oneclickvirt/basics/system/model"
|
"github.com/oneclickvirt/basics/system/model"
|
||||||
"github.com/oneclickvirt/basics/system/utils"
|
"github.com/oneclickvirt/basics/system/utils"
|
||||||
)
|
)
|
||||||
@@ -43,16 +44,16 @@ func CheckSystemInfo(language string) string {
|
|||||||
ret := GetSystemInfo()
|
ret := GetSystemInfo()
|
||||||
var res string
|
var res string
|
||||||
if language == "en" {
|
if language == "en" {
|
||||||
res += " Cpu Model : " + ret.CpuModel + "\n"
|
res += " CPU Model : " + ret.CpuModel + "\n"
|
||||||
res += " Cpu Cores : " + ret.CpuCores + "\n"
|
res += " CPU Cores : " + ret.CpuCores + "\n"
|
||||||
if ret.CpuCache != "" {
|
if ret.CpuCache != "" {
|
||||||
res += " Cpu Cache : " + ret.CpuCache + "\n"
|
res += " CPU Cache : " + ret.CpuCache + "\n"
|
||||||
}
|
}
|
||||||
if runtime.GOOS != "windows" && runtime.GOOS != "macos" {
|
if runtime.GOOS != "windows" && runtime.GOOS != "macos" {
|
||||||
res += " AES-NI : " + ret.CpuAesNi + "\n"
|
res += " AES-NI : " + ret.CpuAesNi + "\n"
|
||||||
}
|
}
|
||||||
res += " VM-x/AMD-V/Hyper-V : " + ret.CpuVAH + "\n"
|
res += " VM-x/AMD-V/Hyper-V : " + ret.CpuVAH + "\n"
|
||||||
res += " RAM : " + ret.MemoryUsage+" / "+ret.MemoryTotal + "\n"
|
res += " RAM : " + ret.MemoryUsage + " / " + ret.MemoryTotal + "\n"
|
||||||
if ret.VirtioBalloon != "" {
|
if ret.VirtioBalloon != "" {
|
||||||
res += " Virtio Balloon : " + ret.VirtioBalloon + "\n"
|
res += " Virtio Balloon : " + ret.VirtioBalloon + "\n"
|
||||||
}
|
}
|
||||||
@@ -62,11 +63,11 @@ func CheckSystemInfo(language string) string {
|
|||||||
if ret.SwapTotal == "" && ret.SwapUsage == "" {
|
if ret.SwapTotal == "" && ret.SwapUsage == "" {
|
||||||
res += " Swap : [ no swap partition or swap file detected ]" + "\n"
|
res += " Swap : [ no swap partition or swap file detected ]" + "\n"
|
||||||
} else if ret.SwapTotal != "" && ret.SwapUsage != "" {
|
} else if ret.SwapTotal != "" && ret.SwapUsage != "" {
|
||||||
res += " Swap : " + ret.SwapUsage+" / "+ret.SwapTotal + "\n"
|
res += " Swap : " + ret.SwapUsage + " / " + ret.SwapTotal + "\n"
|
||||||
}
|
}
|
||||||
res += " Disk : " + ret.DiskUsage+" / "+ret.DiskTotal + "\n"
|
res += " Disk : " + ret.DiskUsage + " / " + ret.DiskTotal + "\n"
|
||||||
res += " Boot Path : " + ret.BootPath + "\n"
|
res += " Boot Path : " + ret.BootPath + "\n"
|
||||||
res += " OS Release : " + ret.Platform+" ["+ret.Arch+"] " + "\n"
|
res += " OS Release : " + ret.Platform + " [" + ret.Arch + "] " + "\n"
|
||||||
if ret.Kernel != "" {
|
if ret.Kernel != "" {
|
||||||
res += " Kernel : " + ret.Kernel + "\n"
|
res += " Kernel : " + ret.Kernel + "\n"
|
||||||
}
|
}
|
||||||
@@ -79,16 +80,16 @@ func CheckSystemInfo(language string) string {
|
|||||||
res += " Tcp Accelerate : " + ret.TcpAccelerationMethod + "\n"
|
res += " Tcp Accelerate : " + ret.TcpAccelerationMethod + "\n"
|
||||||
}
|
}
|
||||||
} else if language == "zh" {
|
} else if language == "zh" {
|
||||||
res += " Cpu 型号 : " + ret.CpuModel + "\n"
|
res += " CPU 型号 : " + ret.CpuModel + "\n"
|
||||||
res += " Cpu 数量 : " + ret.CpuCores + "\n"
|
res += " CPU 数量 : " + ret.CpuCores + "\n"
|
||||||
if ret.CpuCache != "" {
|
if ret.CpuCache != "" {
|
||||||
res += " Cpu 缓存 : " + ret.CpuCache + "\n"
|
res += " CPU 缓存 : " + ret.CpuCache + "\n"
|
||||||
}
|
}
|
||||||
if runtime.GOOS != "windows" && runtime.GOOS != "macos" {
|
if runtime.GOOS != "windows" && runtime.GOOS != "macos" {
|
||||||
res += " AES-NI : " + ret.CpuAesNi + "\n"
|
res += " AES-NI : " + ret.CpuAesNi + "\n"
|
||||||
}
|
}
|
||||||
res += " VM-x/AMD-V/Hyper-V : " + ret.CpuVAH + "\n"
|
res += " VM-x/AMD-V/Hyper-V : " + ret.CpuVAH + "\n"
|
||||||
res += " 内存 : " + ret.MemoryUsage+" / "+ret.MemoryTotal + "\n"
|
res += " 内存 : " + ret.MemoryUsage + " / " + ret.MemoryTotal + "\n"
|
||||||
if ret.VirtioBalloon != "" {
|
if ret.VirtioBalloon != "" {
|
||||||
res += " Virtio Balloon : " + ret.VirtioBalloon + "\n"
|
res += " Virtio Balloon : " + ret.VirtioBalloon + "\n"
|
||||||
}
|
}
|
||||||
@@ -98,11 +99,11 @@ func CheckSystemInfo(language string) string {
|
|||||||
if ret.SwapTotal == "" && ret.SwapUsage == "" {
|
if ret.SwapTotal == "" && ret.SwapUsage == "" {
|
||||||
res += " Swap : [ no swap partition or swap file detected ]" + "\n"
|
res += " Swap : [ no swap partition or swap file detected ]" + "\n"
|
||||||
} else if ret.SwapTotal != "" && ret.SwapUsage != "" {
|
} else if ret.SwapTotal != "" && ret.SwapUsage != "" {
|
||||||
res += " Swap : " + ret.SwapUsage+" / "+ret.SwapTotal + "\n"
|
res += " Swap : " + ret.SwapUsage + " / " + ret.SwapTotal + "\n"
|
||||||
}
|
}
|
||||||
res += " 硬盘空间 : " + ret.DiskUsage+" / "+ret.DiskTotal + "\n"
|
res += " 硬盘空间 : " + ret.DiskUsage + " / " + ret.DiskTotal + "\n"
|
||||||
res += " 启动盘路径 : " + ret.BootPath + "\n"
|
res += " 启动盘路径 : " + ret.BootPath + "\n"
|
||||||
res += " 系统 : " + ret.Platform+" ["+ret.Arch+"] " + "\n"
|
res += " 系统 : " + ret.Platform + " [" + ret.Arch + "] " + "\n"
|
||||||
if ret.Kernel != "" {
|
if ret.Kernel != "" {
|
||||||
res += " 内核 : " + ret.Kernel + "\n"
|
res += " 内核 : " + ret.Kernel + "\n"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user