feat: 添加对Darwin和FreeBSD的GPU及操作系统名称获取功能

This commit is contained in:
Akizon77
2025-06-29 20:24:05 +08:00
parent 8cd60d448a
commit e1f52b9b77
9 changed files with 230 additions and 3 deletions

View File

@@ -0,0 +1,27 @@
//go:build freebsd
// +build freebsd
package monitoring
import (
"os/exec"
"strings"
)
// ProcessCount returns the number of running processes on FreeBSD
func ProcessCount() (count int) {
return processCountFreeBSD()
}
// processCountFreeBSD counts processes using the `ps` command
func processCountFreeBSD() (count int) {
cmd := exec.Command("ps", "-ax")
output, err := cmd.Output()
if err != nil {
return 0
}
// Count the number of lines in the output, excluding the header line
lines := strings.Split(string(output), "\n")
return len(lines) - 1
}