mirror of
https://github.com/fankes/komari-agent.git
synced 2025-10-20 03:29:24 +08:00
feat: 自动发布realease
This commit is contained in:
33
monitoring/process_linux.go
Normal file
33
monitoring/process_linux.go
Normal file
@@ -0,0 +1,33 @@
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package monitoring
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// ProcessCount returns the number of running processes
|
||||
func ProcessCount() (count int) {
|
||||
return processCountLinux()
|
||||
}
|
||||
|
||||
// processCountLinux counts processes by reading /proc directory
|
||||
func processCountLinux() (count int) {
|
||||
procDir := "/proc"
|
||||
|
||||
entries, err := os.ReadDir(procDir)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
if _, err := strconv.ParseInt(entry.Name(), 10, 64); err == nil {
|
||||
//if _, err := filepath.ParseInt(entry.Name(), 10, 64); err == nil {
|
||||
count++
|
||||
}
|
||||
}
|
||||
|
||||
return count
|
||||
}
|
Reference in New Issue
Block a user