exec

package
v1.23.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2022 License: MIT Imports: 13 Imported by: 1

README

Exec Output Plugin

This plugin sends telegraf metrics to an external application over stdin.

The command should be defined similar to docker's exec form:

["executable", "param1", "param2"]

On non-zero exit stderr will be logged at error level.

For better performance, consider execd, which runs continuously.

Configuration

# Send metrics to command as input over stdin
[[outputs.exec]]
  ## Command to ingest metrics via stdin.
  command = ["tee", "-a", "/dev/null"]

  ## 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 = []

  ## Timeout for command to complete.
  # timeout = "5s"

  ## Data format to output.
  ## 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_OUTPUT.md
  # data_format = "influx"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandRunner

type CommandRunner struct {
	// contains filtered or unexported fields
}

CommandRunner runs a command with the ability to kill the process before the timeout.

func (*CommandRunner) Run

func (c *CommandRunner) Run(timeout time.Duration, command []string, environments []string, buffer io.Reader) error

Run runs the command.

type Exec

type Exec struct {
	Command     []string        `toml:"command"`
	Environment []string        `toml:"environment"`
	Timeout     config.Duration `toml:"timeout"`
	Log         telegraf.Logger `toml:"-"`
	// contains filtered or unexported fields
}

Exec defines the exec output plugin.

func (*Exec) Close

func (e *Exec) Close() error

Close satisfies the Output interface.

func (*Exec) Connect

func (e *Exec) Connect() error

Connect satisfies the Output interface.

func (*Exec) Init added in v1.18.1

func (e *Exec) Init() error

func (*Exec) SampleConfig

func (*Exec) SampleConfig() string

func (*Exec) SetSerializer

func (e *Exec) SetSerializer(serializer serializers.Serializer)

SetSerializer sets the serializer for the output.

func (*Exec) Write

func (e *Exec) Write(metrics []telegraf.Metric) error

Write writes the metrics to the configured command.

type Runner

type Runner interface {
	Run(time.Duration, []string, []string, io.Reader) error
}

Runner provides an interface for running exec.Cmd.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL