clarify docs and add warning if execd is misconfigured (#7866)
This commit is contained in:
parent
641b1d60cd
commit
de313fcde6
|
|
@ -17,7 +17,8 @@ STDERR from the process will be relayed to Telegraf as errors in the logs.
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[[inputs.execd]]
|
[[inputs.execd]]
|
||||||
## Program to run as daemon
|
## One program to run as daemon.
|
||||||
|
## NOTE: process and each argument should each be their own string
|
||||||
command = ["telegraf-smartctl", "-d", "/dev/sda"]
|
command = ["telegraf-smartctl", "-d", "/dev/sda"]
|
||||||
|
|
||||||
## Define how the process is signaled on each collection interval.
|
## Define how the process is signaled on each collection interval.
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
|
|
@ -75,6 +76,13 @@ func (e *Execd) Start(acc telegraf.Accumulator) error {
|
||||||
e.process.ReadStderrFn = e.cmdReadErr
|
e.process.ReadStderrFn = e.cmdReadErr
|
||||||
|
|
||||||
if err = e.process.Start(); err != nil {
|
if err = e.process.Start(); err != nil {
|
||||||
|
// if there was only one argument, and it contained spaces, warn the user
|
||||||
|
// that they may have configured it wrong.
|
||||||
|
if len(e.Command) == 1 && strings.Contains(e.Command[0], " ") {
|
||||||
|
e.Log.Warn("The inputs.execd Command contained spaces but no arguments. " +
|
||||||
|
"This setting expects the program and arguments as an array of strings, " +
|
||||||
|
"not as a space-delimited string. See the plugin readme for an example.")
|
||||||
|
}
|
||||||
return fmt.Errorf("failed to start process %s: %w", e.Command, err)
|
return fmt.Errorf("failed to start process %s: %w", e.Command, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ Telegraf minimum version: Telegraf 1.15.0
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[[outputs.execd]]
|
[[outputs.execd]]
|
||||||
## Program to run as daemon
|
## One program to run as daemon.
|
||||||
|
## NOTE: process and each argument should each be their own string
|
||||||
command = ["my-telegraf-output", "--some-flag", "value"]
|
command = ["my-telegraf-output", "--some-flag", "value"]
|
||||||
|
|
||||||
## Delay before the process is restarted after an unexpected termination
|
## Delay before the process is restarted after an unexpected termination
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
|
|
@ -69,6 +70,13 @@ func (e *Execd) Init() error {
|
||||||
|
|
||||||
func (e *Execd) Connect() error {
|
func (e *Execd) Connect() error {
|
||||||
if err := e.process.Start(); err != nil {
|
if err := e.process.Start(); err != nil {
|
||||||
|
// if there was only one argument, and it contained spaces, warn the user
|
||||||
|
// that they may have configured it wrong.
|
||||||
|
if len(e.Command) == 1 && strings.Contains(e.Command[0], " ") {
|
||||||
|
e.Log.Warn("The outputs.execd Command contained spaces but no arguments. " +
|
||||||
|
"This setting expects the program and arguments as an array of strings, " +
|
||||||
|
"not as a space-delimited string. See the plugin readme for an example.")
|
||||||
|
}
|
||||||
return fmt.Errorf("failed to start process %s: %w", e.Command, err)
|
return fmt.Errorf("failed to start process %s: %w", e.Command, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ Telegraf minimum version: Telegraf 1.15.0
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[[processor.execd]]
|
[[processor.execd]]
|
||||||
## Program to run as daemon
|
## One program to run as daemon.
|
||||||
|
## NOTE: process and each argument should each be their own string
|
||||||
## eg: command = ["/path/to/your_program", "arg1", "arg2"]
|
## eg: command = ["/path/to/your_program", "arg1", "arg2"]
|
||||||
command = ["cat"]
|
command = ["cat"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
|
|
@ -79,6 +80,13 @@ func (e *Execd) Start(acc telegraf.Accumulator) error {
|
||||||
e.process.ReadStderrFn = e.cmdReadErr
|
e.process.ReadStderrFn = e.cmdReadErr
|
||||||
|
|
||||||
if err = e.process.Start(); err != nil {
|
if err = e.process.Start(); err != nil {
|
||||||
|
// if there was only one argument, and it contained spaces, warn the user
|
||||||
|
// that they may have configured it wrong.
|
||||||
|
if len(e.Command) == 1 && strings.Contains(e.Command[0], " ") {
|
||||||
|
e.Log.Warn("The processors.execd Command contained spaces but no arguments. " +
|
||||||
|
"This setting expects the program and arguments as an array of strings, " +
|
||||||
|
"not as a space-delimited string. See the plugin readme for an example.")
|
||||||
|
}
|
||||||
return fmt.Errorf("failed to start process %s: %w", e.Command, err)
|
return fmt.Errorf("failed to start process %s: %w", e.Command, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue