Revert "exec plugin: allow using glob pattern in command list"
This reverts commit 6381efa7ce.
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
@@ -19,11 +18,8 @@ import (
|
||||
)
|
||||
|
||||
const sampleConfig = `
|
||||
## Full path to executable with parameters,
|
||||
## or a glob pattern to run all matching files.
|
||||
## the glob pattern will be run at every interval, so new files will
|
||||
## automatically be picked up.
|
||||
commands = ["/tmp/test.sh", "/usr/bin/collector --foo=bar", "/tmp/collect_*.sh"]
|
||||
## Commands array
|
||||
commands = ["/tmp/test.sh", "/usr/bin/mycollector --foo=bar"]
|
||||
|
||||
## Timeout for each command to complete.
|
||||
timeout = "5s"
|
||||
@@ -154,19 +150,10 @@ func (e *Exec) Gather(acc telegraf.Accumulator) error {
|
||||
e.Command = ""
|
||||
}
|
||||
|
||||
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.errChan = make(chan error, len(e.Commands))
|
||||
|
||||
e.errChan = make(chan error, len(commands))
|
||||
|
||||
e.wg.Add(len(commands))
|
||||
for _, command := range commands {
|
||||
e.wg.Add(len(e.Commands))
|
||||
for _, command := range e.Commands {
|
||||
go e.ProcessCommand(command, acc)
|
||||
}
|
||||
e.wg.Wait()
|
||||
|
||||
Reference in New Issue
Block a user