diff --git a/plugins/inputs/exec/exec.go b/plugins/inputs/exec/exec.go index d2e09ccd0..c1decd579 100644 --- a/plugins/inputs/exec/exec.go +++ b/plugins/inputs/exec/exec.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "os/exec" + "path/filepath" "sync" "syscall" @@ -139,10 +140,19 @@ func (e *Exec) Gather(acc telegraf.Accumulator) error { e.Command = "" } - e.errChan = make(chan error, len(e.Commands)) + commands := make([]string, len(e.Commands)) + for _, pattern := range e.Commands { + matches, err := filepath.Glob(pattern) + if err != nil { + return err + } + commands = append(commands, matches...) + } - e.wg.Add(len(e.Commands)) - for _, command := range e.Commands { + e.errChan = make(chan error, len(commands)) + + e.wg.Add(len(commands)) + for _, command := range commands { go e.ProcessCommand(command, acc) } e.wg.Wait()