2020-02-29 02:46:03 +08:00
|
|
|
# Execd Input Plugin
|
|
|
|
|
|
2022-06-08 05:37:08 +08:00
|
|
|
The `execd` plugin runs an external program as a long-running daemon. The
|
|
|
|
|
programs must output metrics in any one of the accepted [Input Data Formats][]
|
|
|
|
|
on the process's STDOUT, and is expected to stay running. If you'd instead like
|
|
|
|
|
the process to collect metrics and then exit, check out the [inputs.exec][]
|
|
|
|
|
plugin.
|
2020-02-29 02:46:03 +08:00
|
|
|
|
2020-05-05 22:14:57 +08:00
|
|
|
The `signal` can be configured to send a signal the running daemon on each
|
2020-07-07 05:09:23 +08:00
|
|
|
collection interval. This is used for when you want to have Telegraf notify the
|
|
|
|
|
plugin when it's time to run collection. STDIN is recommended, which writes a
|
|
|
|
|
new line to the process's STDIN.
|
2020-02-29 02:46:03 +08:00
|
|
|
|
2024-09-10 00:00:19 +08:00
|
|
|
STDERR from the process will be relayed to Telegraf's logging facilities. By
|
|
|
|
|
default all messages on `stderr` will be logged as errors. However, you can
|
|
|
|
|
log to other levels by prefixing your message with `E!` for error, `W!` for
|
|
|
|
|
warning, `I!` for info, `D!` for debugging and `T!` for trace levels followed by
|
|
|
|
|
a space and the actual message. For example outputting `I! A log message` will
|
|
|
|
|
create a `info` log line in your Telegraf logging output.
|
2020-02-29 02:46:03 +08:00
|
|
|
|
2024-05-11 00:24:56 +08:00
|
|
|
[Input Data Formats]: ../../../docs/DATA_FORMATS_INPUT.md
|
|
|
|
|
[inputs.exec]: ../exec/README.md
|
|
|
|
|
|
2023-03-27 20:12:35 +08:00
|
|
|
## Service Input <!-- @/docs/includes/service_input.md -->
|
|
|
|
|
|
|
|
|
|
This plugin is a service input. Normal plugins gather metrics determined by the
|
|
|
|
|
interval setting. Service plugins start a service to listens and waits for
|
|
|
|
|
metrics or events to occur. Service plugins have two key differences from
|
|
|
|
|
normal plugins:
|
|
|
|
|
|
|
|
|
|
1. The global or plugin specific `interval` setting may not apply
|
|
|
|
|
2. The CLI options of `--test`, `--test-wait`, and `--once` may not produce
|
|
|
|
|
output for this plugin
|
|
|
|
|
|
2022-10-27 03:58:36 +08:00
|
|
|
## Global configuration options <!-- @/docs/includes/plugin_config.md -->
|
|
|
|
|
|
|
|
|
|
In addition to the plugin-specific configuration settings, plugins support
|
|
|
|
|
additional global and plugin configuration settings. These settings are used to
|
|
|
|
|
modify metrics, tags, and field or create aliases and configure ordering, etc.
|
|
|
|
|
See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
|
|
|
|
|
2023-01-12 23:55:21 +08:00
|
|
|
[CONFIGURATION.md]: ../../../docs/CONFIGURATION.md#plugins
|
2022-10-27 03:58:36 +08:00
|
|
|
|
2021-11-25 02:56:26 +08:00
|
|
|
## Configuration
|
2020-02-29 02:46:03 +08:00
|
|
|
|
2022-05-24 21:49:47 +08:00
|
|
|
```toml @sample.conf
|
2022-04-08 06:01:21 +08:00
|
|
|
# Run executable as long-running input plugin
|
2020-02-29 02:58:56 +08:00
|
|
|
[[inputs.execd]]
|
2020-07-21 05:41:04 +08:00
|
|
|
## One program to run as daemon.
|
|
|
|
|
## NOTE: process and each argument should each be their own string
|
2020-02-29 02:46:03 +08:00
|
|
|
command = ["telegraf-smartctl", "-d", "/dev/sda"]
|
|
|
|
|
|
2022-05-11 05:34:05 +08:00
|
|
|
## Environment variables
|
|
|
|
|
## Array of "key=value" pairs to pass as environment variables
|
|
|
|
|
## e.g. "KEY=value", "USERNAME=John Doe",
|
|
|
|
|
## "LD_LIBRARY_PATH=/opt/custom/lib64:/usr/local/libs"
|
|
|
|
|
# environment = []
|
|
|
|
|
|
2020-02-29 02:46:03 +08:00
|
|
|
## Define how the process is signaled on each collection interval.
|
|
|
|
|
## Valid values are:
|
2020-05-05 22:14:57 +08:00
|
|
|
## "none" : Do not signal anything. (Recommended for service inputs)
|
|
|
|
|
## The process must output metrics by itself.
|
|
|
|
|
## "STDIN" : Send a newline on STDIN. (Recommended for gather inputs)
|
|
|
|
|
## "SIGHUP" : Send a HUP signal. Not available on Windows. (not recommended)
|
2020-02-29 02:46:03 +08:00
|
|
|
## "SIGUSR1" : Send a USR1 signal. Not available on Windows.
|
|
|
|
|
## "SIGUSR2" : Send a USR2 signal. Not available on Windows.
|
2024-05-24 02:42:34 +08:00
|
|
|
# signal = "none"
|
2020-02-29 02:46:03 +08:00
|
|
|
|
|
|
|
|
## Delay before the process is restarted after an unexpected termination
|
2024-05-24 02:42:34 +08:00
|
|
|
# restart_delay = "10s"
|
2020-02-29 02:46:03 +08:00
|
|
|
|
2023-03-29 00:40:45 +08:00
|
|
|
## Buffer size used to read from the command output stream
|
|
|
|
|
## Optional parameter. Default is 64 Kib, minimum is 16 bytes
|
|
|
|
|
# buffer_size = "64Kib"
|
|
|
|
|
|
2024-05-24 02:42:34 +08:00
|
|
|
## Disable automatic restart of the program and stop if the program exits
|
|
|
|
|
## with an error (i.e. non-zero error code)
|
|
|
|
|
# stop_on_error = false
|
|
|
|
|
|
2020-02-29 02:46:03 +08:00
|
|
|
## Data format to consume.
|
|
|
|
|
## Each data format has its own unique set of configuration options, read
|
|
|
|
|
## more about them here:
|
|
|
|
|
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
|
2024-05-24 02:42:34 +08:00
|
|
|
# data_format = "influx"
|
2020-02-29 02:46:03 +08:00
|
|
|
```
|
|
|
|
|
|
2021-11-25 02:56:26 +08:00
|
|
|
## Example
|
2020-02-29 02:46:03 +08:00
|
|
|
|
2024-05-11 00:24:56 +08:00
|
|
|
See the examples directory for basic examples in different languages expecting
|
|
|
|
|
various signals from Telegraf:
|
2020-02-29 02:46:03 +08:00
|
|
|
|
2024-05-11 00:24:56 +08:00
|
|
|
- [Go](./examples/count.go): Example expects `signal = "SIGHUP"`
|
|
|
|
|
- [Python](./examples/count.py): Example expects `signal = "none"`
|
|
|
|
|
- [Ruby](./examples/count.rb): Example expects `signal = "none"`
|
|
|
|
|
- [shell](./examples/count.sh): Example expects `signal = "STDIN"`
|
2023-02-09 18:04:41 +08:00
|
|
|
|
|
|
|
|
## Metrics
|
|
|
|
|
|
2024-05-11 00:24:56 +08:00
|
|
|
Varies depending on the users data.
|
|
|
|
|
|
2023-02-09 18:04:41 +08:00
|
|
|
## Example Output
|
2024-05-11 00:24:56 +08:00
|
|
|
|
|
|
|
|
Varies depending on the users data.
|