This commit is contained in:
spiritlhl
2024-05-04 15:08:45 +00:00
parent 6237f6e5d3
commit c75ba6c255
2 changed files with 9 additions and 6 deletions

View File

@@ -3,5 +3,5 @@ package main
import "github.com/oneclickvirt/basics/system" import "github.com/oneclickvirt/basics/system"
func main() { func main() {
system.GetSystemInfo() system.CheckSystemInfo()
} }

View File

@@ -2,6 +2,7 @@ package system
import ( import (
"fmt" "fmt"
"runtime"
"strconv" "strconv"
"github.com/oneclickvirt/basics/system/model" "github.com/oneclickvirt/basics/system/model"
@@ -16,8 +17,8 @@ var (
cpuType string cpuType string
) )
// GetHost 获取主机硬件信息 // GetSystemInfo 获取主机硬件信息
func GetHost() *model.SystemInfo { func GetSystemInfo() *model.SystemInfo {
var ret = &model.SystemInfo{} var ret = &model.SystemInfo{}
// 系统信息查询 // 系统信息查询
cpuType, ret.Uptime, ret.Platform, ret.Kernel, ret.Arch, ret.VmType, ret.NatType, ret.TimeZone, _ = getHostInfo() cpuType, ret.Uptime, ret.Platform, ret.Kernel, ret.Arch, ret.VmType, ret.NatType, ret.TimeZone, _ = getHostInfo()
@@ -40,14 +41,16 @@ func GetHost() *model.SystemInfo {
return ret return ret
} }
func GetSystemInfo() { func CheckSystemInfo() {
ret := GetHost() ret := GetSystemInfo()
fmt.Println("Cpu Model :", ret.CpuModel) fmt.Println("Cpu Model :", ret.CpuModel)
fmt.Println("Cpu Cores :", ret.CpuCores) fmt.Println("Cpu Cores :", ret.CpuCores)
if ret.CpuCache != "" { if ret.CpuCache != "" {
fmt.Println("Cpu Cache :", ret.CpuCache) fmt.Println("Cpu Cache :", ret.CpuCache)
} }
fmt.Println("AES-NI :", ret.CpuAesNi) if runtime.GOOS != "windows" && runtime.GOOS != "macos" {
fmt.Println("AES-NI :", ret.CpuAesNi)
}
fmt.Println("VM-x/AMD-V/Hyper-V :", ret.CpuVAH) fmt.Println("VM-x/AMD-V/Hyper-V :", ret.CpuVAH)
fmt.Println("RAM :", ret.MemoryUsage+" / "+ret.MemoryTotal) fmt.Println("RAM :", ret.MemoryUsage+" / "+ret.MemoryTotal)
if ret.VirtioBalloon != "" { if ret.VirtioBalloon != "" {