mirror of
https://github.com/fankes/komari-agent.git
synced 2025-10-18 18:49:23 +08:00
feat: 添加对Darwin和FreeBSD的GPU及操作系统名称获取功能
This commit is contained in:
27
monitoring/unit/process_darwin.go
Normal file
27
monitoring/unit/process_darwin.go
Normal file
@@ -0,0 +1,27 @@
|
||||
//go:build darwin
|
||||
// +build darwin
|
||||
|
||||
package monitoring
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ProcessCount returns the number of running processes on Darwin (macOS)
|
||||
func ProcessCount() (count int) {
|
||||
return processCountDarwin()
|
||||
}
|
||||
|
||||
// processCountDarwin counts processes using the `ps` command
|
||||
func processCountDarwin() (count int) {
|
||||
cmd := exec.Command("ps", "-A")
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user