exec

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2015 License: MIT Imports: 11 Imported by: 0

README

Exec Plugin

The exec plugin can execute arbitrary commands which output JSON. Then it flattens JSON and finds all numeric values, treating them as floats.

For example, if you have a json-returning command called mycollector, you could setup the exec plugin with:

[[exec.commands]]
command = "/usr/bin/mycollector --output=json"
name = "mycollector"
interval = 10

The name is used as a prefix for the measurements.

The interval is used to determine how often a particular command should be run. Each time the exec plugin runs, it will only run a particular command if it has been at least interval seconds since the exec plugin last ran the command.

Sample

Let's say that we have a command named "mycollector", which gives the following output:

{
    "a": 0.5,
    "b": {
        "c": "some text",
        "d": 0.1,
        "e": 5
    }
}

The collected metrics will be:

exec_mycollector_a value=0.5
exec_mycollector_b_d value=0.1
exec_mycollector_b_e value=5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock added in v0.2.0

type Clock interface {
	Now() time.Time
}

type Command

type Command struct {
	Command  string
	Name     string
	Interval int
	// contains filtered or unexported fields
}

type CommandRunner

type CommandRunner struct{}

func (CommandRunner) Run

func (c CommandRunner) Run(command *Command) ([]byte, error)

type Exec

type Exec struct {
	Commands []*Command
	// contains filtered or unexported fields
}

func NewExec

func NewExec() *Exec

func (*Exec) Description

func (e *Exec) Description() string

func (*Exec) Gather

func (e *Exec) Gather(acc plugins.Accumulator) error

func (*Exec) SampleConfig

func (e *Exec) SampleConfig() string

type RealClock added in v0.2.0

type RealClock struct{}

func (RealClock) Now added in v0.2.0

func (c RealClock) Now() time.Time

type Runner

type Runner interface {
	Run(*Command) ([]byte, error)
}

Jump to

Keyboard shortcuts

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