Fix parse port collect file

This commit is contained in:
710leo 2020-05-13 16:09:44 +08:00
parent b19246021d
commit fbb11de178
2 changed files with 11 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package stra
import ( import (
"fmt" "fmt"
"os" "os"
"path/filepath"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -51,13 +52,15 @@ func GetPortCollects() map[int]*model.PortCollect {
continue continue
} }
service, err := file.ToTrimString(StraConfig.PortPath + "/" + f) filePath := filepath.Join(portPath, f)
service, err := file.ToTrimString(filePath)
if err != nil { if err != nil {
logger.Warning(err) logger.Warning(err)
continue continue
} }
info, err := os.Stat(f) info, err := os.Stat(filePath)
if err != nil { if err != nil {
logger.Warning(err) logger.Warning(err)
continue continue

View File

@ -3,6 +3,7 @@ package stra
import ( import (
"fmt" "fmt"
"os" "os"
"path/filepath"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -37,7 +38,8 @@ func GetProcCollects() map[string]*model.ProcCollect {
} }
} }
files, err := file.FilesUnder(StraConfig.ProcPath) procPath := StraConfig.ProcPath
files, err := file.FilesUnder(procPath)
if err != nil { if err != nil {
logger.Error(err) logger.Error(err)
return procs return procs
@ -51,13 +53,14 @@ func GetProcCollects() map[string]*model.ProcCollect {
continue continue
} }
service, err := file.ToTrimString(StraConfig.ProcPath + "/" + f) filePath := filepath.Join(procPath, f)
service, err := file.ToTrimString(filePath)
if err != nil { if err != nil {
logger.Warning(err) logger.Warning(err)
continue continue
} }
info, err := os.Stat(f) info, err := os.Stat(filePath)
if err != nil { if err != nil {
logger.Warning(err) logger.Warning(err)
continue continue