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"
func main() {
system.GetSystemInfo()
system.CheckSystemInfo()
}

View File

@@ -2,6 +2,7 @@ package system
import (
"fmt"
"runtime"
"strconv"
"github.com/oneclickvirt/basics/system/model"
@@ -16,8 +17,8 @@ var (
cpuType string
)
// GetHost 获取主机硬件信息
func GetHost() *model.SystemInfo {
// GetSystemInfo 获取主机硬件信息
func GetSystemInfo() *model.SystemInfo {
var ret = &model.SystemInfo{}
// 系统信息查询
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
}
func GetSystemInfo() {
ret := GetHost()
func CheckSystemInfo() {
ret := GetSystemInfo()
fmt.Println("Cpu Model :", ret.CpuModel)
fmt.Println("Cpu Cores :", ret.CpuCores)
if 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("RAM :", ret.MemoryUsage+" / "+ret.MemoryTotal)
if ret.VirtioBalloon != "" {