mirror of
https://github.com/fankes/komari-agent.git
synced 2026-03-26 21:35:12 +08:00
Merge pull request #60 from joy0x1/main
fix: support counting host processes inside containers
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user