Close stdin on exit in execd input
This commit is contained in:
parent
a20e6953d2
commit
a34180459a
|
@ -14,6 +14,7 @@
|
|||
- [infiniband](/plugins/inputs/infiniband/README.md) - Contributed by @willfurnell
|
||||
- [modbus](/plugins/inputs/modbus/README.md) - Contributed by @garciaolais
|
||||
- [monit](/plugins/inputs/monit/README.md) - Contributed by @SirishaGopigiri
|
||||
- [execd](/plugins/inputs/execd/README.md) - Contributed by @jgraichen
|
||||
|
||||
#### New Processors
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# Execd Input Plugin
|
||||
|
||||
The `execd` plugin runs an external program as a daemon. The programs must output metrics in any one of the accepted [Input Data Formats](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md) on its standard output.
|
||||
The `execd` plugin runs an external program as a daemon. The programs must output metrics in any one of the accepted
|
||||
[Input Data Formats](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md) on its standard output.
|
||||
|
||||
The `signal` can be configured to send a signal the running daemon on each collection interval.
|
||||
|
||||
|
@ -9,11 +10,11 @@ Program output on standard error is mirrored to the telegraf log.
|
|||
### Configuration:
|
||||
|
||||
```toml
|
||||
[[inputs.execd]]
|
||||
## Program to run as daemon
|
||||
command = ["telegraf-smartctl", "-d", "/dev/sda"]
|
||||
|
||||
## Define how the process is signaled on each collection interval.
|
||||
|
||||
## Valid values are:
|
||||
## "none" : Do not signal anything.
|
||||
## The process must output metrics by itself.
|
||||
|
|
|
@ -21,12 +21,13 @@ const sampleConfig = `
|
|||
command = ["telegraf-smartctl", "-d", "/dev/sda"]
|
||||
|
||||
## Define how the process is signaled on each collection interval.
|
||||
|
||||
## Valid values are:
|
||||
## "none" : Do not signal anything.
|
||||
## The process must output metrics by itself.
|
||||
## "STDIN" : Send a newline on STDIN.
|
||||
## "SIGHUP" : Send a HUP signal. Not available on Windows.
|
||||
## "SIGUSR1" : Send a USR1 signal. Not available on Windows.
|
||||
## "SIGUSR2" : Send a USR2 signal. Not available on Windows.
|
||||
signal = "none"
|
||||
|
||||
## Delay before the process is restarted after an unexpected termination
|
||||
|
@ -100,9 +101,10 @@ func (e *Execd) cmdLoop(ctx context.Context) {
|
|||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
e.stdin.Close()
|
||||
// Immediately exit process but with a graceful shutdown
|
||||
// period before killing
|
||||
internal.WaitTimeout(e.cmd, 0)
|
||||
internal.WaitTimeout(e.cmd, 200*time.Millisecond)
|
||||
return
|
||||
case err := <-done:
|
||||
log.Printf("E! [inputs.execd] Process %s terminated: %s", e.Command, err)
|
||||
|
|
Loading…
Reference in New Issue