fix: support counting host processes inside containers

Allow configuring custom `/proc` path to count host processes via volume
mount.
This commit is contained in:
joy0x1
2025-12-27 16:36:00 +09:00
parent c22aecbf1d
commit a463360836
2 changed files with 7 additions and 0 deletions

View File

@@ -17,6 +17,12 @@ func ProcessCount() (count int) {
func processCountLinux() (count int) {
procDir := "/proc"
if flags.HostProc != "" {
if info, err := os.Stat(flags.HostProc); err == nil && info.IsDir() {
procDir = flags.HostProc
}
}
entries, err := os.ReadDir(procDir)
if err != nil {
return 0