Use godirwalk in globpath (#5145)
This commit is contained in:
@@ -75,10 +75,7 @@ func (f *File) refreshFilePaths() error {
|
||||
if len(files) <= 0 {
|
||||
return fmt.Errorf("could not find file: %v", file)
|
||||
}
|
||||
|
||||
for k := range files {
|
||||
allFiles = append(allFiles, k)
|
||||
}
|
||||
allFiles = append(allFiles, files...)
|
||||
}
|
||||
|
||||
f.filenames = allFiles
|
||||
|
||||
@@ -73,13 +73,17 @@ func (f *FileStat) Gather(acc telegraf.Accumulator) error {
|
||||
continue
|
||||
}
|
||||
|
||||
for fileName, fileInfo := range files {
|
||||
for _, fileName := range files {
|
||||
tags := map[string]string{
|
||||
"file": fileName,
|
||||
}
|
||||
fields := map[string]interface{}{
|
||||
"exists": int64(1),
|
||||
}
|
||||
fileInfo, err := os.Stat(fileName)
|
||||
if os.IsNotExist(err) {
|
||||
fields["exists"] = int64(0)
|
||||
}
|
||||
|
||||
if fileInfo == nil {
|
||||
log.Printf("E! Unable to get info for file [%s], possible permissions issue",
|
||||
|
||||
@@ -182,7 +182,7 @@ func (l *LogParserPlugin) tailNewfiles(fromBeginning bool) error {
|
||||
}
|
||||
files := g.Match()
|
||||
|
||||
for file := range files {
|
||||
for _, file := range files {
|
||||
if _, ok := l.tailers[file]; ok {
|
||||
// we're already tailing this file
|
||||
continue
|
||||
|
||||
@@ -111,7 +111,7 @@ func (t *Tail) tailNewFiles(fromBeginning bool) error {
|
||||
if err != nil {
|
||||
t.acc.AddError(fmt.Errorf("E! Error Glob %s failed to compile, %s", filepath, err))
|
||||
}
|
||||
for file := range g.Match() {
|
||||
for _, file := range g.Match() {
|
||||
if _, ok := t.tailers[file]; ok {
|
||||
// we're already tailing this file
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user