修复windows系统获取文件打开数bug

This commit is contained in:
zhuhoujiu 2025-03-16 09:59:38 +08:00
parent 8c1007fab1
commit 53b26348d6

View File

@ -30,7 +30,9 @@ import (
"github.com/winc-link/hummingbird/internal/pkg/di"
"github.com/winc-link/hummingbird/internal/pkg/logger"
"github.com/winc-link/hummingbird/internal/pkg/utils"
"runtime"
"strconv"
"strings"
"time"
)
@ -202,6 +204,7 @@ func getNetwork(ethMap map[string]*dtos.SystemNetwork) map[string]dtos.SystemNet
func getOpenfiles() int {
// only linux
// https://github.com/shirou/gopsutil#process-class
if strings.ToLower(runtime.GOOS) == "linux" {
processes, _ := process.Processes()
var openfiles int
for _, pid := range processes {
@ -209,6 +212,8 @@ func getOpenfiles() int {
openfiles += len(files)
}
return openfiles
}
return 0
}
func getPlatform() {