mirror of
https://github.com/fankes/komari-agent.git
synced 2025-10-19 11:09:22 +08:00
feat: 添加对Darwin和FreeBSD的GPU及操作系统名称获取功能
This commit is contained in:
28
monitoring/unit/gpu_freebsd.go
Normal file
28
monitoring/unit/gpu_freebsd.go
Normal file
@@ -0,0 +1,28 @@
|
||||
//go:build freebsd
|
||||
// +build freebsd
|
||||
|
||||
package monitoring
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GpuName returns the name of the GPU on FreeBSD
|
||||
func GpuName() string {
|
||||
cmd := exec.Command("pciconf", "-lv")
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
return "Unknown"
|
||||
}
|
||||
|
||||
lines := strings.Split(string(output), "\n")
|
||||
for _, line := range lines {
|
||||
line = strings.TrimSpace(line)
|
||||
if strings.Contains(line, "VGA") || strings.Contains(line, "Display") {
|
||||
return line
|
||||
}
|
||||
}
|
||||
|
||||
return "Unknown"
|
||||
}
|
Reference in New Issue
Block a user