mirror of
https://github.com/oneclickvirt/basics.git
synced 2025-10-05 16:48:09 +08:00
update
This commit is contained in:
@@ -46,23 +46,17 @@ func getDiskInfo() (string, string, string, error) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// df -x tmpfs / | awk "NR>1" | sed ":a;N;s/\\n//g;ta" | awk '{print $1}'
|
||||
cmd := exec.Command("df", "-x", "tmpfs", "/")
|
||||
output, err := cmd.Output()
|
||||
if err == nil {
|
||||
awkCmd := exec.Command("awk", "NR>1")
|
||||
awkCmd.Stdin = strings.NewReader(string(output))
|
||||
awkOutput, err := awkCmd.Output()
|
||||
if err == nil {
|
||||
sedCmd := exec.Command("sed", ":a;N;s/\\n//g;ta")
|
||||
sedCmd.Stdin = strings.NewReader(string(awkOutput))
|
||||
sedOutput, err := sedCmd.Output()
|
||||
if err != nil {
|
||||
finalAwkCmd := exec.Command("awk", "{print $1}")
|
||||
finalAwkCmd.Stdin = strings.NewReader(string(sedOutput))
|
||||
finalOutput, err := finalAwkCmd.Output()
|
||||
if err != nil {
|
||||
bootPath = string(finalOutput)
|
||||
}
|
||||
// 解析输出
|
||||
lines := strings.Split(string(output), "\n")
|
||||
if len(lines) >= 2 {
|
||||
// 解析第二行的值
|
||||
fields := strings.Fields(lines[1])
|
||||
if len(fields) < 6 {
|
||||
bootPath = fields[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,11 +3,12 @@ package system
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-nat"
|
||||
"github.com/oneclickvirt/basics/system/utils"
|
||||
"github.com/shirou/gopsutil/host"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
func getHostInfo() (string, string, string, string, string, string, string, string, error) {
|
||||
@@ -22,12 +23,7 @@ func getHostInfo() (string, string, string, string, string, string, string, stri
|
||||
} else {
|
||||
cpuType = "Physical"
|
||||
}
|
||||
if runtime.GOOS == "linux" {
|
||||
Platform = hi.Platform
|
||||
Kernal = hi.PlatformVersion
|
||||
} else {
|
||||
Platform = hi.Platform + " " + hi.PlatformVersion
|
||||
}
|
||||
Arch = hi.KernelArch
|
||||
// 查询虚拟化类型
|
||||
VmType = hi.VirtualizationSystem
|
||||
|
Reference in New Issue
Block a user