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