Compare commits

...

5 Commits

Author SHA1 Message Date
David Norton 81caa56859 move plugin interfaces into separate package 2016-12-23 10:18:27 -05:00
David Norton 3e6c4a53a4 fix plugin namespacing 2016-12-22 12:06:04 -05:00
David Norton ba8f91a038 update Circle build to use go1.8beta1 2016-12-22 12:06:04 -05:00
David Norton 2b77751df8 make plugin dir configurable and fix namespacing 2016-12-22 12:06:04 -05:00
David Norton 70d678c442 load external plugins 2016-12-22 12:06:04 -05:00
183 changed files with 906 additions and 814 deletions

View File

@ -4,7 +4,7 @@ import (
"log"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/selfstat"
)
@ -18,14 +18,14 @@ type MetricMaker interface {
measurement string,
fields map[string]interface{},
tags map[string]string,
mType telegraf.ValueType,
mType plugins.ValueType,
t time.Time,
) telegraf.Metric
) plugins.Metric
}
func NewAccumulator(
maker MetricMaker,
metrics chan telegraf.Metric,
metrics chan plugins.Metric,
) *accumulator {
acc := accumulator{
maker: maker,
@ -36,7 +36,7 @@ func NewAccumulator(
}
type accumulator struct {
metrics chan telegraf.Metric
metrics chan plugins.Metric
maker MetricMaker
@ -49,7 +49,7 @@ func (ac *accumulator) AddFields(
tags map[string]string,
t ...time.Time,
) {
if m := ac.maker.MakeMetric(measurement, fields, tags, telegraf.Untyped, ac.getTime(t)); m != nil {
if m := ac.maker.MakeMetric(measurement, fields, tags, plugins.Untyped, ac.getTime(t)); m != nil {
ac.metrics <- m
}
}
@ -60,7 +60,7 @@ func (ac *accumulator) AddGauge(
tags map[string]string,
t ...time.Time,
) {
if m := ac.maker.MakeMetric(measurement, fields, tags, telegraf.Gauge, ac.getTime(t)); m != nil {
if m := ac.maker.MakeMetric(measurement, fields, tags, plugins.Gauge, ac.getTime(t)); m != nil {
ac.metrics <- m
}
}
@ -71,7 +71,7 @@ func (ac *accumulator) AddCounter(
tags map[string]string,
t ...time.Time,
) {
if m := ac.maker.MakeMetric(measurement, fields, tags, telegraf.Counter, ac.getTime(t)); m != nil {
if m := ac.maker.MakeMetric(measurement, fields, tags, plugins.Counter, ac.getTime(t)); m != nil {
ac.metrics <- m
}
}

View File

@ -8,7 +8,7 @@ import (
"testing"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/metric"
"github.com/stretchr/testify/assert"
@ -17,7 +17,7 @@ import (
func TestAdd(t *testing.T) {
now := time.Now()
metrics := make(chan telegraf.Metric, 10)
metrics := make(chan plugins.Metric, 10)
defer close(metrics)
a := NewAccumulator(&TestMetricMaker{}, metrics)
@ -48,7 +48,7 @@ func TestAdd(t *testing.T) {
func TestAddFields(t *testing.T) {
now := time.Now()
metrics := make(chan telegraf.Metric, 10)
metrics := make(chan plugins.Metric, 10)
defer close(metrics)
a := NewAccumulator(&TestMetricMaker{}, metrics)
@ -79,7 +79,7 @@ func TestAccAddError(t *testing.T) {
log.SetOutput(errBuf)
defer log.SetOutput(os.Stderr)
metrics := make(chan telegraf.Metric, 10)
metrics := make(chan plugins.Metric, 10)
defer close(metrics)
a := NewAccumulator(&TestMetricMaker{}, metrics)
@ -100,7 +100,7 @@ func TestAccAddError(t *testing.T) {
func TestAddNoIntervalWithPrecision(t *testing.T) {
now := time.Date(2006, time.February, 10, 12, 0, 0, 82912748, time.UTC)
metrics := make(chan telegraf.Metric, 10)
metrics := make(chan plugins.Metric, 10)
defer close(metrics)
a := NewAccumulator(&TestMetricMaker{}, metrics)
a.SetPrecision(0, time.Second)
@ -132,7 +132,7 @@ func TestAddNoIntervalWithPrecision(t *testing.T) {
func TestAddDisablePrecision(t *testing.T) {
now := time.Date(2006, time.February, 10, 12, 0, 0, 82912748, time.UTC)
metrics := make(chan telegraf.Metric, 10)
metrics := make(chan plugins.Metric, 10)
defer close(metrics)
a := NewAccumulator(&TestMetricMaker{}, metrics)
@ -164,7 +164,7 @@ func TestAddDisablePrecision(t *testing.T) {
func TestAddNoPrecisionWithInterval(t *testing.T) {
now := time.Date(2006, time.February, 10, 12, 0, 0, 82912748, time.UTC)
metrics := make(chan telegraf.Metric, 10)
metrics := make(chan plugins.Metric, 10)
defer close(metrics)
a := NewAccumulator(&TestMetricMaker{}, metrics)
@ -196,7 +196,7 @@ func TestAddNoPrecisionWithInterval(t *testing.T) {
func TestDifferentPrecisions(t *testing.T) {
now := time.Date(2006, time.February, 10, 12, 0, 0, 82912748, time.UTC)
metrics := make(chan telegraf.Metric, 10)
metrics := make(chan plugins.Metric, 10)
defer close(metrics)
a := NewAccumulator(&TestMetricMaker{}, metrics)
@ -243,7 +243,7 @@ func TestDifferentPrecisions(t *testing.T) {
func TestAddGauge(t *testing.T) {
now := time.Now()
metrics := make(chan telegraf.Metric, 10)
metrics := make(chan plugins.Metric, 10)
defer close(metrics)
a := NewAccumulator(&TestMetricMaker{}, metrics)
@ -260,24 +260,24 @@ func TestAddGauge(t *testing.T) {
testm := <-metrics
actual := testm.String()
assert.Contains(t, actual, "acctest value=101")
assert.Equal(t, testm.Type(), telegraf.Gauge)
assert.Equal(t, testm.Type(), plugins.Gauge)
testm = <-metrics
actual = testm.String()
assert.Contains(t, actual, "acctest,acc=test value=101")
assert.Equal(t, testm.Type(), telegraf.Gauge)
assert.Equal(t, testm.Type(), plugins.Gauge)
testm = <-metrics
actual = testm.String()
assert.Equal(t,
fmt.Sprintf("acctest,acc=test value=101 %d\n", now.UnixNano()),
actual)
assert.Equal(t, testm.Type(), telegraf.Gauge)
assert.Equal(t, testm.Type(), plugins.Gauge)
}
func TestAddCounter(t *testing.T) {
now := time.Now()
metrics := make(chan telegraf.Metric, 10)
metrics := make(chan plugins.Metric, 10)
defer close(metrics)
a := NewAccumulator(&TestMetricMaker{}, metrics)
@ -294,19 +294,19 @@ func TestAddCounter(t *testing.T) {
testm := <-metrics
actual := testm.String()
assert.Contains(t, actual, "acctest value=101")
assert.Equal(t, testm.Type(), telegraf.Counter)
assert.Equal(t, testm.Type(), plugins.Counter)
testm = <-metrics
actual = testm.String()
assert.Contains(t, actual, "acctest,acc=test value=101")
assert.Equal(t, testm.Type(), telegraf.Counter)
assert.Equal(t, testm.Type(), plugins.Counter)
testm = <-metrics
actual = testm.String()
assert.Equal(t,
fmt.Sprintf("acctest,acc=test value=101 %d\n", now.UnixNano()),
actual)
assert.Equal(t, testm.Type(), telegraf.Counter)
assert.Equal(t, testm.Type(), plugins.Counter)
}
type TestMetricMaker struct {
@ -319,20 +319,20 @@ func (tm *TestMetricMaker) MakeMetric(
measurement string,
fields map[string]interface{},
tags map[string]string,
mType telegraf.ValueType,
mType plugins.ValueType,
t time.Time,
) telegraf.Metric {
) plugins.Metric {
switch mType {
case telegraf.Untyped:
case plugins.Untyped:
if m, err := metric.New(measurement, tags, fields, t); err == nil {
return m
}
case telegraf.Counter:
if m, err := metric.New(measurement, tags, fields, t, telegraf.Counter); err == nil {
case plugins.Counter:
if m, err := metric.New(measurement, tags, fields, t, plugins.Counter); err == nil {
return m
}
case telegraf.Gauge:
if m, err := metric.New(measurement, tags, fields, t, telegraf.Gauge); err == nil {
case plugins.Gauge:
if m, err := metric.New(measurement, tags, fields, t, plugins.Gauge); err == nil {
return m
}
}

View File

@ -8,10 +8,10 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/internal/config"
"github.com/influxdata/telegraf/internal/models"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/selfstat"
)
@ -46,7 +46,7 @@ func NewAgent(config *config.Config) (*Agent, error) {
func (a *Agent) Connect() error {
for _, o := range a.Config.Outputs {
switch ot := o.Output.(type) {
case telegraf.ServiceOutput:
case plugins.ServiceOutput:
if err := ot.Start(); err != nil {
log.Printf("E! Service for output %s failed to start, exiting\n%s\n",
o.Name, err.Error())
@ -76,7 +76,7 @@ func (a *Agent) Close() error {
for _, o := range a.Config.Outputs {
err = o.Output.Close()
switch ot := o.Output.(type) {
case telegraf.ServiceOutput:
case plugins.ServiceOutput:
ot.Stop()
}
}
@ -101,7 +101,7 @@ func (a *Agent) gatherer(
shutdown chan struct{},
input *models.RunningInput,
interval time.Duration,
metricC chan telegraf.Metric,
metricC chan plugins.Metric,
) {
defer panicRecover(input)
@ -176,7 +176,7 @@ func gatherWithTimeout(
func (a *Agent) Test() error {
shutdown := make(chan struct{})
defer close(shutdown)
metricC := make(chan telegraf.Metric)
metricC := make(chan plugins.Metric)
// dummy receiver for the point channel
go func() {
@ -241,14 +241,14 @@ func (a *Agent) flush() {
}
// flusher monitors the metrics input channel and flushes on the minimum interval
func (a *Agent) flusher(shutdown chan struct{}, metricC chan telegraf.Metric) error {
func (a *Agent) flusher(shutdown chan struct{}, metricC chan plugins.Metric) error {
// Inelegant, but this sleep is to allow the Gather threads to run, so that
// the flusher will flush after metrics are collected.
time.Sleep(time.Millisecond * 300)
// create an output metric channel and a gorouting that continously passes
// each metric onto the output plugins & aggregators.
outMetricC := make(chan telegraf.Metric, 100)
outMetricC := make(chan plugins.Metric, 100)
var wg sync.WaitGroup
wg.Add(1)
go func() {
@ -300,7 +300,7 @@ func (a *Agent) flusher(shutdown chan struct{}, metricC chan telegraf.Metric) er
case metric := <-metricC:
// NOTE potential bottleneck here as we put each metric through the
// processors serially.
mS := []telegraf.Metric{metric}
mS := []plugins.Metric{metric}
for _, processor := range a.Config.Processors {
mS = processor.Apply(mS...)
}
@ -321,13 +321,13 @@ func (a *Agent) Run(shutdown chan struct{}) error {
a.Config.Agent.Hostname, a.Config.Agent.FlushInterval.Duration)
// channel shared between all input threads for accumulating metrics
metricC := make(chan telegraf.Metric, 100)
metricC := make(chan plugins.Metric, 100)
// Start all ServicePlugins
for _, input := range a.Config.Inputs {
input.SetDefaultTags(a.Config.Tags)
switch p := input.Input.(type) {
case telegraf.ServiceInput:
case plugins.ServiceInput:
acc := NewAccumulator(input, metricC)
// Service input plugins should set their own precision of their
// metrics.

View File

@ -5,8 +5,8 @@ machine:
- sudo service zookeeper stop
- go version
- go version | grep 1.7.4 || sudo rm -rf /usr/local/go
- wget https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz
- sudo tar -C /usr/local -xzf go1.7.4.linux-amd64.tar.gz
- wget https://storage.googleapis.com/golang/go1.8beta1.linux-amd64.tar.gz
- sudo tar -C /usr/local -xzf go1.8beta1.linux-amd64.tar.gz
- go version
dependencies:

View File

@ -6,6 +6,9 @@ import (
"log"
"os"
"os/signal"
"path"
"path/filepath"
"plugin"
"runtime"
"strings"
"syscall"
@ -13,11 +16,14 @@ import (
"github.com/influxdata/telegraf/agent"
"github.com/influxdata/telegraf/internal/config"
"github.com/influxdata/telegraf/logger"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/aggregators"
_ "github.com/influxdata/telegraf/plugins/aggregators/all"
"github.com/influxdata/telegraf/plugins/inputs"
_ "github.com/influxdata/telegraf/plugins/inputs/all"
"github.com/influxdata/telegraf/plugins/outputs"
_ "github.com/influxdata/telegraf/plugins/outputs/all"
"github.com/influxdata/telegraf/plugins/processors"
_ "github.com/influxdata/telegraf/plugins/processors/all"
"github.com/kardianos/service"
)
@ -50,6 +56,8 @@ var fUsage = flag.String("usage", "",
"print usage for a plugin, ie, 'telegraf -usage mysql'")
var fService = flag.String("service", "",
"operate on the service")
var fPlugins = flag.String("plugins", "",
"path to directory containing external plugins")
// Telegraf version, populated linker.
// ie, -ldflags "-X main.version=`git describe --always --tags`"
@ -304,9 +312,93 @@ func (p *program) Stop(s service.Service) error {
return nil
}
// loadExternalPlugins loads external plugins from shared libraries (.so, .dll, etc.)
// in the specified directory.
func loadExternalPlugins(dir string) error {
return filepath.Walk(dir, func(pth string, info os.FileInfo, err error) error {
// Stop if there was an error.
if err != nil {
return err
}
// Ignore directories.
if info.IsDir() {
return nil
}
// Ignore files that aren't shared libraries.
ext := strings.ToLower(path.Ext(pth))
if ext != ".so" && ext != ".dll" {
return nil
}
// Load plugin.
p, err := plugin.Open(pth)
if err != nil {
return err
}
// Register plugin.
if err := registerPlugin(dir, pth, p); err != nil {
return err
}
return nil
})
}
// registerPlugin registers an external plugin with telegraf.
func registerPlugin(pluginsDir, filePath string, p *plugin.Plugin) error {
// Clean the file path and make sure it's relative to the root plugins directory.
// This is done because plugin names are namespaced using the directory
// structure. E.g., if the root plugin directory, passed in the pluginsDir
// argument, is '/home/jdoe/bin/telegraf/plugins' and we're registering plugin
// '/home/jdoe/bin/telegraf/plugins/input/mysql.so'
pluginsDir = filepath.Clean(pluginsDir)
parentDir, _ := filepath.Split(pluginsDir)
var err error
if filePath, err = filepath.Rel(parentDir, filePath); err != nil {
return err
}
// Strip the file extension and save it.
ext := path.Ext(filePath)
filePath = strings.TrimSuffix(filePath, ext)
// Convert path separators to "." to generate a plugin name namespaced by directory names.
name := strings.Replace(filePath, string(os.PathSeparator), ".", -1)
if create, err := p.Lookup("NewInput"); err == nil {
inputs.Add(name, inputs.Creator(create.(func() plugins.Input)))
} else if create, err := p.Lookup("NewOutput"); err == nil {
outputs.Add(name, outputs.Creator(create.(func() plugins.Output)))
} else if create, err := p.Lookup("NewProcessor"); err == nil {
processors.Add(name, processors.Creator(create.(func() plugins.Processor)))
} else if create, err := p.Lookup("NewAggregator"); err == nil {
aggregators.Add(name, aggregators.Creator(create.(func() plugins.Aggregator)))
} else {
return fmt.Errorf("not a telegraf plugin: %s%s", filePath, ext)
}
log.Printf("I! Registered: %s (from %s%s)\n", name, filePath, ext)
return nil
}
func main() {
flag.Usage = func() { usageExit(0) }
flag.Parse()
// Load external plugins, if requested.
if *fPlugins != "" {
pluginsDir, err := filepath.Abs(*fPlugins)
if err != nil {
log.Fatal("E! " + err.Error())
}
log.Printf("I! Loading external plugins from: %s\n", pluginsDir)
if err := loadExternalPlugins(*fPlugins); err != nil {
log.Fatal("E! " + err.Error())
}
}
if runtime.GOOS == "windows" {
svcConfig := &service.Config{
Name: "telegraf",

View File

@ -3,7 +3,7 @@ package buffer
import (
"sync"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/selfstat"
)
@ -14,7 +14,7 @@ var (
// Buffer is an object for storing metrics in a circular buffer.
type Buffer struct {
buf chan telegraf.Metric
buf chan plugins.Metric
mu sync.Mutex
}
@ -24,7 +24,7 @@ type Buffer struct {
// called when the buffer is full, then the oldest metric(s) will be dropped.
func NewBuffer(size int) *Buffer {
return &Buffer{
buf: make(chan telegraf.Metric, size),
buf: make(chan plugins.Metric, size),
}
}
@ -39,7 +39,7 @@ func (b *Buffer) Len() int {
}
// Add adds metrics to the buffer.
func (b *Buffer) Add(metrics ...telegraf.Metric) {
func (b *Buffer) Add(metrics ...plugins.Metric) {
for i, _ := range metrics {
MetricsWritten.Incr(1)
select {
@ -55,10 +55,10 @@ func (b *Buffer) Add(metrics ...telegraf.Metric) {
// Batch returns a batch of metrics of size batchSize.
// the batch will be of maximum length batchSize. It can be less than batchSize,
// if the length of Buffer is less than batchSize.
func (b *Buffer) Batch(batchSize int) []telegraf.Metric {
func (b *Buffer) Batch(batchSize int) []plugins.Metric {
b.mu.Lock()
n := min(len(b.buf), batchSize)
out := make([]telegraf.Metric, n)
out := make([]plugins.Metric, n)
for i := 0; i < n; i++ {
out[i] = <-b.buf
}

View File

@ -3,13 +3,13 @@ package buffer
import (
"testing"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/testutil"
"github.com/stretchr/testify/assert"
)
var metricList = []telegraf.Metric{
var metricList = []plugins.Metric{
testutil.TestMetric(2, "mymetric1"),
testutil.TestMetric(1, "mymetric2"),
testutil.TestMetric(11, "mymetric3"),

View File

@ -15,9 +15,9 @@ import (
"strings"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/internal/models"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/aggregators"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/influxdata/telegraf/plugins/outputs"
@ -399,7 +399,7 @@ func printFilteredInputs(inputFilters []string, commented bool) {
sort.Strings(pnames)
// cache service inputs to print them at the end
servInputs := make(map[string]telegraf.ServiceInput)
servInputs := make(map[string]plugins.ServiceInput)
// for alphabetical looping:
servInputNames := []string{}
@ -409,7 +409,7 @@ func printFilteredInputs(inputFilters []string, commented bool) {
input := creator()
switch p := input.(type) {
case telegraf.ServiceInput:
case plugins.ServiceInput:
servInputs[pname] = p
servInputNames = append(servInputNames, pname)
continue

View File

@ -5,8 +5,8 @@ import (
"math"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/metric"
"github.com/influxdata/telegraf/plugins"
)
// makemetric is used by both RunningAggregator & RunningInput
@ -32,9 +32,9 @@ func makemetric(
daemonTags map[string]string,
filter Filter,
applyFilter bool,
mType telegraf.ValueType,
mType plugins.ValueType,
t time.Time,
) telegraf.Metric {
) plugins.Metric {
if len(fields) == 0 || len(measurement) == 0 {
return nil
}

View File

@ -3,28 +3,28 @@ package models
import (
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/metric"
"github.com/influxdata/telegraf/plugins"
)
type RunningAggregator struct {
a telegraf.Aggregator
a plugins.Aggregator
Config *AggregatorConfig
metrics chan telegraf.Metric
metrics chan plugins.Metric
periodStart time.Time
periodEnd time.Time
}
func NewRunningAggregator(
a telegraf.Aggregator,
a plugins.Aggregator,
conf *AggregatorConfig,
) *RunningAggregator {
return &RunningAggregator{
a: a,
Config: conf,
metrics: make(chan telegraf.Metric, 100),
metrics: make(chan plugins.Metric, 100),
}
}
@ -52,9 +52,9 @@ func (r *RunningAggregator) MakeMetric(
measurement string,
fields map[string]interface{},
tags map[string]string,
mType telegraf.ValueType,
mType plugins.ValueType,
t time.Time,
) telegraf.Metric {
) plugins.Metric {
m := makemetric(
measurement,
fields,
@ -80,7 +80,7 @@ func (r *RunningAggregator) MakeMetric(
// Add applies the given metric to the aggregator.
// Before applying to the plugin, it will run any defined filters on the metric.
// Apply returns true if the original metric should be dropped.
func (r *RunningAggregator) Add(in telegraf.Metric) bool {
func (r *RunningAggregator) Add(in plugins.Metric) bool {
if r.Config.Filter.IsActive() {
// check if the aggregator should apply this metric
name := in.Name()
@ -98,11 +98,11 @@ func (r *RunningAggregator) Add(in telegraf.Metric) bool {
r.metrics <- in
return r.Config.DropOriginal
}
func (r *RunningAggregator) add(in telegraf.Metric) {
func (r *RunningAggregator) add(in plugins.Metric) {
r.a.Add(in)
}
func (r *RunningAggregator) push(acc telegraf.Accumulator) {
func (r *RunningAggregator) push(acc plugins.Accumulator) {
r.a.Push(acc)
}
@ -113,7 +113,7 @@ func (r *RunningAggregator) reset() {
// Run runs the running aggregator, listens for incoming metrics, and waits
// for period ticks to tell it when to push and reset the aggregator.
func (r *RunningAggregator) Run(
acc telegraf.Accumulator,
acc plugins.Accumulator,
shutdown chan struct{},
) {
// The start of the period is truncated to the nearest second.

View File

@ -7,7 +7,7 @@ import (
"testing"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/testutil"
"github.com/stretchr/testify/assert"
@ -30,7 +30,7 @@ func TestAdd(t *testing.T) {
"RITest",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
time.Now().Add(time.Millisecond*150),
)
assert.False(t, ra.Add(m))
@ -62,7 +62,7 @@ func TestAddMetricsOutsideCurrentPeriod(t *testing.T) {
"RITest",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
time.Now().Add(-time.Hour),
)
assert.False(t, ra.Add(m))
@ -72,7 +72,7 @@ func TestAddMetricsOutsideCurrentPeriod(t *testing.T) {
"RITest",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
time.Now().Add(time.Hour),
)
assert.False(t, ra.Add(m))
@ -82,7 +82,7 @@ func TestAddMetricsOutsideCurrentPeriod(t *testing.T) {
"RITest",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
time.Now().Add(time.Millisecond*50),
)
assert.False(t, ra.Add(m))
@ -120,7 +120,7 @@ func TestAddAndPushOnePeriod(t *testing.T) {
"RITest",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
time.Now().Add(time.Millisecond*100),
)
assert.False(t, ra.Add(m))
@ -151,7 +151,7 @@ func TestAddDropOriginal(t *testing.T) {
"RITest",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
time.Now(),
)
assert.True(t, ra.Add(m))
@ -161,7 +161,7 @@ func TestAddDropOriginal(t *testing.T) {
"foobar",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
time.Now(),
)
assert.False(t, ra.Add(m2))
@ -179,7 +179,7 @@ func TestMakeMetricA(t *testing.T) {
"RITest",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
now,
)
assert.Equal(
@ -190,14 +190,14 @@ func TestMakeMetricA(t *testing.T) {
assert.Equal(
t,
m.Type(),
telegraf.Untyped,
plugins.Untyped,
)
m = ra.MakeMetric(
"RITest",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Counter,
plugins.Counter,
now,
)
assert.Equal(
@ -208,14 +208,14 @@ func TestMakeMetricA(t *testing.T) {
assert.Equal(
t,
m.Type(),
telegraf.Counter,
plugins.Counter,
)
m = ra.MakeMetric(
"RITest",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Gauge,
plugins.Gauge,
now,
)
assert.Equal(
@ -226,7 +226,7 @@ func TestMakeMetricA(t *testing.T) {
assert.Equal(
t,
m.Type(),
telegraf.Gauge,
plugins.Gauge,
)
}
@ -240,14 +240,14 @@ func (t *TestAggregator) Reset() {
atomic.StoreInt64(&t.sum, 0)
}
func (t *TestAggregator) Push(acc telegraf.Accumulator) {
func (t *TestAggregator) Push(acc plugins.Accumulator) {
acc.AddFields("TestMetric",
map[string]interface{}{"sum": t.sum},
map[string]string{},
)
}
func (t *TestAggregator) Add(in telegraf.Metric) {
func (t *TestAggregator) Add(in plugins.Metric) {
for _, v := range in.Fields() {
if vi, ok := v.(int64); ok {
atomic.AddInt64(&t.sum, vi)

View File

@ -4,14 +4,14 @@ import (
"fmt"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/selfstat"
)
var GlobalMetricsGathered = selfstat.Register("agent", "metrics_gathered", map[string]string{})
type RunningInput struct {
Input telegraf.Input
Input plugins.Input
Config *InputConfig
trace bool
@ -21,7 +21,7 @@ type RunningInput struct {
}
func NewRunningInput(
input telegraf.Input,
input plugins.Input,
config *InputConfig,
) *RunningInput {
return &RunningInput{
@ -56,9 +56,9 @@ func (r *RunningInput) MakeMetric(
measurement string,
fields map[string]interface{},
tags map[string]string,
mType telegraf.ValueType,
mType plugins.ValueType,
t time.Time,
) telegraf.Metric {
) plugins.Metric {
m := makemetric(
measurement,
fields,

View File

@ -6,7 +6,7 @@ import (
"testing"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/stretchr/testify/assert"
)
@ -21,7 +21,7 @@ func TestMakeMetricNoFields(t *testing.T) {
"RITest",
map[string]interface{}{},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
now,
)
assert.Nil(t, m)
@ -41,7 +41,7 @@ func TestMakeMetricNilFields(t *testing.T) {
"nil": nil,
},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
now,
)
assert.Equal(
@ -66,7 +66,7 @@ func TestMakeMetric(t *testing.T) {
"RITest",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
now,
)
assert.Equal(
@ -77,14 +77,14 @@ func TestMakeMetric(t *testing.T) {
assert.Equal(
t,
m.Type(),
telegraf.Untyped,
plugins.Untyped,
)
m = ri.MakeMetric(
"RITest",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Counter,
plugins.Counter,
now,
)
assert.Equal(
@ -95,14 +95,14 @@ func TestMakeMetric(t *testing.T) {
assert.Equal(
t,
m.Type(),
telegraf.Counter,
plugins.Counter,
)
m = ri.MakeMetric(
"RITest",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Gauge,
plugins.Gauge,
now,
)
assert.Equal(
@ -113,7 +113,7 @@ func TestMakeMetric(t *testing.T) {
assert.Equal(
t,
m.Type(),
telegraf.Gauge,
plugins.Gauge,
)
}
@ -133,7 +133,7 @@ func TestMakeMetricWithPluginTags(t *testing.T) {
"RITest",
map[string]interface{}{"value": int(101)},
nil,
telegraf.Untyped,
plugins.Untyped,
now,
)
assert.Equal(
@ -161,7 +161,7 @@ func TestMakeMetricFilteredOut(t *testing.T) {
"RITest",
map[string]interface{}{"value": int(101)},
nil,
telegraf.Untyped,
plugins.Untyped,
now,
)
assert.Nil(t, m)
@ -183,7 +183,7 @@ func TestMakeMetricWithDaemonTags(t *testing.T) {
"RITest",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
now,
)
assert.Equal(
@ -213,7 +213,7 @@ func TestMakeMetricInfFields(t *testing.T) {
"ninf": ninf,
},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
now,
)
assert.Equal(
@ -250,7 +250,7 @@ func TestMakeMetricAllFieldTypes(t *testing.T) {
"m": true,
},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
now,
)
assert.Contains(t, m.String(), "a=10i")
@ -280,7 +280,7 @@ func TestMakeMetricNameOverride(t *testing.T) {
"RITest",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
now,
)
assert.Equal(
@ -301,7 +301,7 @@ func TestMakeMetricNamePrefix(t *testing.T) {
"RITest",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
now,
)
assert.Equal(
@ -322,7 +322,7 @@ func TestMakeMetricNameSuffix(t *testing.T) {
"RITest",
map[string]interface{}{"value": int(101)},
map[string]string{},
telegraf.Untyped,
plugins.Untyped,
now,
)
assert.Equal(
@ -336,4 +336,4 @@ type testInput struct{}
func (t *testInput) Description() string { return "" }
func (t *testInput) SampleConfig() string { return "" }
func (t *testInput) Gather(acc telegraf.Accumulator) error { return nil }
func (t *testInput) Gather(acc plugins.Accumulator) error { return nil }

View File

@ -4,7 +4,7 @@ import (
"log"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal/buffer"
"github.com/influxdata/telegraf/metric"
"github.com/influxdata/telegraf/selfstat"
@ -21,7 +21,7 @@ const (
// RunningOutput contains the output configuration
type RunningOutput struct {
Name string
Output telegraf.Output
Output plugins.Output
Config *OutputConfig
MetricBufferLimit int
MetricBatchSize int
@ -38,7 +38,7 @@ type RunningOutput struct {
func NewRunningOutput(
name string,
output telegraf.Output,
output plugins.Output,
conf *OutputConfig,
batchSize int,
bufferLimit int,
@ -89,7 +89,7 @@ func NewRunningOutput(
// AddMetric adds a metric to the output. This function can also write cached
// points if FlushBufferWhenFull is true.
func (ro *RunningOutput) AddMetric(m telegraf.Metric) {
func (ro *RunningOutput) AddMetric(m plugins.Metric) {
// Filter any tagexclude/taginclude parameters before adding metric
if ro.Config.Filter.IsActive() {
// In order to filter out tags, we need to create a new metric, since
@ -161,7 +161,7 @@ func (ro *RunningOutput) Write() error {
return nil
}
func (ro *RunningOutput) write(metrics []telegraf.Metric) error {
func (ro *RunningOutput) write(metrics []plugins.Metric) error {
nMetrics := len(metrics)
if nMetrics == 0 {
return nil

View File

@ -5,14 +5,14 @@ import (
"sync"
"testing"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
var first5 = []telegraf.Metric{
var first5 = []plugins.Metric{
testutil.TestMetric(101, "metric1"),
testutil.TestMetric(101, "metric2"),
testutil.TestMetric(101, "metric3"),
@ -20,7 +20,7 @@ var first5 = []telegraf.Metric{
testutil.TestMetric(101, "metric5"),
}
var next5 = []telegraf.Metric{
var next5 = []plugins.Metric{
testutil.TestMetric(101, "metric6"),
testutil.TestMetric(101, "metric7"),
testutil.TestMetric(101, "metric8"),
@ -465,7 +465,7 @@ func TestRunningOutputWriteFailOrder3(t *testing.T) {
type mockOutput struct {
sync.Mutex
metrics []telegraf.Metric
metrics []plugins.Metric
// if true, mock a write failure
failWrite bool
@ -487,7 +487,7 @@ func (m *mockOutput) SampleConfig() string {
return ""
}
func (m *mockOutput) Write(metrics []telegraf.Metric) error {
func (m *mockOutput) Write(metrics []plugins.Metric) error {
m.Lock()
defer m.Unlock()
if m.failWrite {
@ -495,7 +495,7 @@ func (m *mockOutput) Write(metrics []telegraf.Metric) error {
}
if m.metrics == nil {
m.metrics = []telegraf.Metric{}
m.metrics = []plugins.Metric{}
}
for _, metric := range metrics {
@ -504,7 +504,7 @@ func (m *mockOutput) Write(metrics []telegraf.Metric) error {
return nil
}
func (m *mockOutput) Metrics() []telegraf.Metric {
func (m *mockOutput) Metrics() []plugins.Metric {
m.Lock()
defer m.Unlock()
return m.metrics
@ -531,7 +531,7 @@ func (m *perfOutput) SampleConfig() string {
return ""
}
func (m *perfOutput) Write(metrics []telegraf.Metric) error {
func (m *perfOutput) Write(metrics []plugins.Metric) error {
if m.failWrite {
return fmt.Errorf("Failed Write!")
}

View File

@ -1,12 +1,12 @@
package models
import (
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
)
type RunningProcessor struct {
Name string
Processor telegraf.Processor
Processor plugins.Processor
Config *ProcessorConfig
}
@ -23,8 +23,8 @@ type ProcessorConfig struct {
Filter Filter
}
func (rp *RunningProcessor) Apply(in ...telegraf.Metric) []telegraf.Metric {
ret := []telegraf.Metric{}
func (rp *RunningProcessor) Apply(in ...plugins.Metric) []plugins.Metric {
ret := []plugins.Metric{}
for _, metric := range in {
if rp.Config.Filter.IsActive() {

View File

@ -3,7 +3,7 @@ package models
import (
"testing"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/testutil"
"github.com/stretchr/testify/assert"
@ -19,8 +19,8 @@ func (f *TestProcessor) Description() string { return "" }
// "foo" to "fuz"
// "bar" to "baz"
// And it also drops measurements named "dropme"
func (f *TestProcessor) Apply(in ...telegraf.Metric) []telegraf.Metric {
out := make([]telegraf.Metric, 0)
func (f *TestProcessor) Apply(in ...plugins.Metric) []plugins.Metric {
out := make([]plugins.Metric, 0)
for _, m := range in {
switch m.Name() {
case "foo":
@ -46,7 +46,7 @@ func NewTestRunningProcessor() *RunningProcessor {
}
func TestRunningProcessor(t *testing.T) {
inmetrics := []telegraf.Metric{
inmetrics := []plugins.Metric{
testutil.TestMetric(1, "foo"),
testutil.TestMetric(1, "bar"),
testutil.TestMetric(1, "baz"),
@ -69,7 +69,7 @@ func TestRunningProcessor(t *testing.T) {
}
func TestRunningProcessor_WithNameDrop(t *testing.T) {
inmetrics := []telegraf.Metric{
inmetrics := []plugins.Metric{
testutil.TestMetric(1, "foo"),
testutil.TestMetric(1, "bar"),
testutil.TestMetric(1, "baz"),
@ -96,7 +96,7 @@ func TestRunningProcessor_WithNameDrop(t *testing.T) {
}
func TestRunningProcessor_DroppedMetric(t *testing.T) {
inmetrics := []telegraf.Metric{
inmetrics := []plugins.Metric{
testutil.TestMetric(1, "dropme"),
testutil.TestMetric(1, "foo"),
testutil.TestMetric(1, "bar"),

View File

@ -8,7 +8,7 @@ import (
"strconv"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
// TODO remove
"github.com/influxdata/influxdb/client/v2"
@ -21,8 +21,8 @@ func New(
tags map[string]string,
fields map[string]interface{},
t time.Time,
mType ...telegraf.ValueType,
) (telegraf.Metric, error) {
mType ...plugins.ValueType,
) (plugins.Metric, error) {
if len(fields) == 0 {
return nil, fmt.Errorf("Metric cannot be made without any fields")
}
@ -30,11 +30,11 @@ func New(
return nil, fmt.Errorf("Metric cannot be made with an empty name")
}
var thisType telegraf.ValueType
var thisType plugins.ValueType
if len(mType) > 0 {
thisType = mType[0]
} else {
thisType = telegraf.Untyped
thisType = plugins.Untyped
}
m := &metric{
@ -129,7 +129,7 @@ type metric struct {
fields []byte
t []byte
mType telegraf.ValueType
mType plugins.ValueType
aggregate bool
// cached values for reuse in "get" functions
@ -154,7 +154,7 @@ func (m *metric) IsAggregate() bool {
return m.aggregate
}
func (m *metric) Type() telegraf.ValueType {
func (m *metric) Type() plugins.ValueType {
return m.mType
}
@ -178,11 +178,11 @@ func (m *metric) Serialize() []byte {
return tmp
}
func (m *metric) Split(maxSize int) []telegraf.Metric {
func (m *metric) Split(maxSize int) []plugins.Metric {
if m.Len() < maxSize {
return []telegraf.Metric{m}
return []plugins.Metric{m}
}
var out []telegraf.Metric
var out []plugins.Metric
// constant number of bytes for each metric (in addition to field bytes)
constant := len(m.name) + len(m.tags) + len(m.t) + 3
@ -430,11 +430,11 @@ func (m *metric) RemoveField(key string) error {
return nil
}
func (m *metric) Copy() telegraf.Metric {
func (m *metric) Copy() plugins.Metric {
return copyWith(m.name, m.tags, m.fields, m.t)
}
func copyWith(name, tags, fields, t []byte) telegraf.Metric {
func copyWith(name, tags, fields, t []byte) plugins.Metric {
out := metric{
name: make([]byte, len(name)),
tags: make([]byte, len(tags)),

View File

@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
)
// vars for making sure that the compiler doesnt optimize out the benchmarks:
@ -17,7 +17,7 @@ var (
)
func BenchmarkNewMetric(b *testing.B) {
var mt telegraf.Metric
var mt plugins.Metric
for n := 0; n < b.N; n++ {
mt, _ = New("test_metric",
map[string]string{
@ -37,7 +37,7 @@ func BenchmarkNewMetric(b *testing.B) {
}
func BenchmarkAddTag(b *testing.B) {
var mt telegraf.Metric
var mt plugins.Metric
mt = &metric{
name: []byte("cpu"),
tags: []byte(",host=localhost"),
@ -51,14 +51,14 @@ func BenchmarkAddTag(b *testing.B) {
}
func BenchmarkSplit(b *testing.B) {
var mt telegraf.Metric
var mt plugins.Metric
mt = &metric{
name: []byte("cpu"),
tags: []byte(",host=localhost"),
fields: []byte("a=101,b=10i,c=10101,d=101010,e=42"),
t: []byte("1480614053000000000"),
}
var metrics []telegraf.Metric
var metrics []plugins.Metric
for n := 0; n < b.N; n++ {
metrics = mt.Split(60)
}

View File

@ -7,7 +7,7 @@ import (
"testing"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/stretchr/testify/assert"
)
@ -26,7 +26,7 @@ func TestNewMetric(t *testing.T) {
m, err := New("cpu", tags, fields, now)
assert.NoError(t, err)
assert.Equal(t, telegraf.Untyped, m.Type())
assert.Equal(t, plugins.Untyped, m.Type())
assert.Equal(t, tags, m.Tags())
assert.Equal(t, fields, m.Fields())
assert.Equal(t, "cpu", m.Name())
@ -402,10 +402,10 @@ func TestNewGaugeMetric(t *testing.T) {
"usage_idle": float64(99),
"usage_busy": float64(1),
}
m, err := New("cpu", tags, fields, now, telegraf.Gauge)
m, err := New("cpu", tags, fields, now, plugins.Gauge)
assert.NoError(t, err)
assert.Equal(t, telegraf.Gauge, m.Type())
assert.Equal(t, plugins.Gauge, m.Type())
assert.Equal(t, tags, m.Tags())
assert.Equal(t, fields, m.Fields())
assert.Equal(t, "cpu", m.Name())
@ -424,10 +424,10 @@ func TestNewCounterMetric(t *testing.T) {
"usage_idle": float64(99),
"usage_busy": float64(1),
}
m, err := New("cpu", tags, fields, now, telegraf.Counter)
m, err := New("cpu", tags, fields, now, plugins.Counter)
assert.NoError(t, err)
assert.Equal(t, telegraf.Counter, m.Type())
assert.Equal(t, plugins.Counter, m.Type())
assert.Equal(t, tags, m.Tags())
assert.Equal(t, fields, m.Fields())
assert.Equal(t, "cpu", m.Name())

View File

@ -6,7 +6,7 @@ import (
"fmt"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
)
var (
@ -39,15 +39,15 @@ const (
fieldsState
)
func Parse(buf []byte) ([]telegraf.Metric, error) {
func Parse(buf []byte) ([]plugins.Metric, error) {
return ParseWithDefaultTime(buf, time.Now())
}
func ParseWithDefaultTime(buf []byte, t time.Time) ([]telegraf.Metric, error) {
func ParseWithDefaultTime(buf []byte, t time.Time) ([]plugins.Metric, error) {
if len(buf) <= 6 {
return []telegraf.Metric{}, makeError("buffer too short", buf, 0)
return []plugins.Metric{}, makeError("buffer too short", buf, 0)
}
metrics := make([]telegraf.Metric, 0, bytes.Count(buf, []byte("\n"))+1)
metrics := make([]plugins.Metric, 0, bytes.Count(buf, []byte("\n"))+1)
var errStr string
i := 0
for {
@ -77,7 +77,7 @@ func ParseWithDefaultTime(buf []byte, t time.Time) ([]telegraf.Metric, error) {
return metrics, nil
}
func parseMetric(buf []byte, defaultTime time.Time) (telegraf.Metric, error) {
func parseMetric(buf []byte, defaultTime time.Time) (plugins.Metric, error) {
var dTime string
// scan the first block which is measurement[,tag1=value1,tag2=value=2...]
pos, key, err := scanKey(buf, 0)

View File

@ -1,4 +1,4 @@
package telegraf
package plugins
import "time"

View File

@ -1,4 +1,4 @@
package telegraf
package plugins
// Aggregator is an interface for implementing an Aggregator plugin.
// the RunningAggregator wraps this interface and guarantees that

View File

@ -1,7 +1,7 @@
package minmax
import (
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/aggregators"
)
@ -9,7 +9,7 @@ type MinMax struct {
cache map[uint64]aggregate
}
func NewMinMax() telegraf.Aggregator {
func NewMinMax() plugins.Aggregator {
mm := &MinMax{}
mm.Reset()
return mm
@ -43,7 +43,7 @@ func (m *MinMax) Description() string {
return "Keep the aggregate min/max of each metric passing through."
}
func (m *MinMax) Add(in telegraf.Metric) {
func (m *MinMax) Add(in plugins.Metric) {
id := in.HashID()
if _, ok := m.cache[id]; !ok {
// hit an uncached metric, create caches for first time:
@ -86,7 +86,7 @@ func (m *MinMax) Add(in telegraf.Metric) {
}
}
func (m *MinMax) Push(acc telegraf.Accumulator) {
func (m *MinMax) Push(acc plugins.Accumulator) {
for _, aggregate := range m.cache {
fields := map[string]interface{}{}
for k, v := range aggregate.fields {
@ -113,7 +113,7 @@ func convert(in interface{}) (float64, bool) {
}
func init() {
aggregators.Add("minmax", func() telegraf.Aggregator {
aggregators.Add("minmax", func() plugins.Aggregator {
return NewMinMax()
})
}

View File

@ -1,8 +1,8 @@
package aggregators
import "github.com/influxdata/telegraf"
import "github.com/influxdata/telegraf/plugins"
type Creator func() telegraf.Aggregator
type Creator func() plugins.Aggregator
var Aggregators = map[string]Creator{}

View File

@ -1,4 +1,4 @@
package telegraf
package plugins
type Input interface {
// SampleConfig returns the default configuration of the Input

View File

@ -9,7 +9,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
@ -35,7 +35,7 @@ func (a *Aerospike) Description() string {
return "Read stats from aerospike server(s)"
}
func (a *Aerospike) Gather(acc telegraf.Accumulator) error {
func (a *Aerospike) Gather(acc plugins.Accumulator) error {
if len(a.Servers) == 0 {
return a.gatherServer("127.0.0.1:3000", acc)
}
@ -54,7 +54,7 @@ func (a *Aerospike) Gather(acc telegraf.Accumulator) error {
return errChan.Error()
}
func (a *Aerospike) gatherServer(hostport string, acc telegraf.Accumulator) error {
func (a *Aerospike) gatherServer(hostport string, acc plugins.Accumulator) error {
host, port, err := net.SplitHostPort(hostport)
if err != nil {
return err
@ -152,7 +152,7 @@ func copyTags(m map[string]string) map[string]string {
}
func init() {
inputs.Add("aerospike", func() telegraf.Input {
inputs.Add("aerospike", func() plugins.Input {
return &Aerospike{}
})
}

View File

@ -10,7 +10,7 @@ import (
"strings"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -57,7 +57,7 @@ func (n *Apache) Description() string {
return "Read Apache status information (mod_status)"
}
func (n *Apache) Gather(acc telegraf.Accumulator) error {
func (n *Apache) Gather(acc plugins.Accumulator) error {
if len(n.Urls) == 0 {
n.Urls = []string{"http://localhost/server-status?auto"}
}
@ -89,7 +89,7 @@ func (n *Apache) Gather(acc telegraf.Accumulator) error {
return outerr
}
func (n *Apache) gatherUrl(addr *url.URL, acc telegraf.Accumulator) error {
func (n *Apache) gatherUrl(addr *url.URL, acc plugins.Accumulator) error {
var tr *http.Transport
@ -228,7 +228,7 @@ func getTags(addr *url.URL) map[string]string {
}
func init() {
inputs.Add("apache", func() telegraf.Input {
inputs.Add("apache", func() plugins.Input {
return &Apache{}
})
}

View File

@ -8,7 +8,7 @@ import (
"strconv"
"strings"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -70,7 +70,7 @@ func prettyToBytes(v string) uint64 {
return uint64(result)
}
func (b *Bcache) gatherBcache(bdev string, acc telegraf.Accumulator) error {
func (b *Bcache) gatherBcache(bdev string, acc plugins.Accumulator) error {
tags := getTags(bdev)
metrics, err := filepath.Glob(bdev + "/stats_total/*")
if len(metrics) < 0 {
@ -105,7 +105,7 @@ func (b *Bcache) gatherBcache(bdev string, acc telegraf.Accumulator) error {
return nil
}
func (b *Bcache) Gather(acc telegraf.Accumulator) error {
func (b *Bcache) Gather(acc plugins.Accumulator) error {
bcacheDevsChecked := make(map[string]bool)
var restrictDevs bool
if len(b.BcacheDevs) != 0 {
@ -136,7 +136,7 @@ func (b *Bcache) Gather(acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("bcache", func() telegraf.Input {
inputs.Add("bcache", func() plugins.Input {
return &Bcache{}
})
}

View File

@ -4,7 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
"io/ioutil"
"log"
@ -35,13 +35,13 @@ type Cassandra struct {
type javaMetric struct {
host string
metric string
acc telegraf.Accumulator
acc plugins.Accumulator
}
type cassandraMetric struct {
host string
metric string
acc telegraf.Accumulator
acc plugins.Accumulator
}
type jmxMetric interface {
@ -49,12 +49,12 @@ type jmxMetric interface {
}
func newJavaMetric(host string, metric string,
acc telegraf.Accumulator) *javaMetric {
acc plugins.Accumulator) *javaMetric {
return &javaMetric{host: host, metric: metric, acc: acc}
}
func newCassandraMetric(host string, metric string,
acc telegraf.Accumulator) *cassandraMetric {
acc plugins.Accumulator) *cassandraMetric {
return &cassandraMetric{host: host, metric: metric, acc: acc}
}
@ -257,7 +257,7 @@ func parseServerTokens(server string) map[string]string {
return serverTokens
}
func (c *Cassandra) Gather(acc telegraf.Accumulator) error {
func (c *Cassandra) Gather(acc plugins.Accumulator) error {
context := c.Context
servers := c.Servers
metrics := c.Metrics
@ -302,7 +302,7 @@ func (c *Cassandra) Gather(acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("cassandra", func() telegraf.Input {
inputs.Add("cassandra", func() plugins.Input {
return &Cassandra{jClient: &JolokiaClientImpl{client: &http.Client{}}}
})
}

View File

@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
"io/ioutil"
"log"
@ -75,7 +75,7 @@ func (c *Ceph) SampleConfig() string {
return sampleConfig
}
func (c *Ceph) Gather(acc telegraf.Accumulator) error {
func (c *Ceph) Gather(acc plugins.Accumulator) error {
if c.GatherAdminSocketStats {
if err := c.gatherAdminSocketStats(acc); err != nil {
return err
@ -91,7 +91,7 @@ func (c *Ceph) Gather(acc telegraf.Accumulator) error {
return nil
}
func (c *Ceph) gatherAdminSocketStats(acc telegraf.Accumulator) error {
func (c *Ceph) gatherAdminSocketStats(acc plugins.Accumulator) error {
sockets, err := findSockets(c)
if err != nil {
return fmt.Errorf("failed to find sockets at path '%s': %v", c.SocketDir, err)
@ -117,10 +117,10 @@ func (c *Ceph) gatherAdminSocketStats(acc telegraf.Accumulator) error {
return nil
}
func (c *Ceph) gatherClusterStats(acc telegraf.Accumulator) error {
func (c *Ceph) gatherClusterStats(acc plugins.Accumulator) error {
jobs := []struct {
command string
parser func(telegraf.Accumulator, string) error
parser func(plugins.Accumulator, string) error
}{
{"status", decodeStatus},
{"df", decodeDf},
@ -155,7 +155,7 @@ func init() {
GatherClusterStats: false,
}
inputs.Add(measurement, func() telegraf.Input { return &c })
inputs.Add(measurement, func() plugins.Input { return &c })
}
@ -322,7 +322,7 @@ func (c *Ceph) exec(command string) (string, error) {
return output, nil
}
func decodeStatus(acc telegraf.Accumulator, input string) error {
func decodeStatus(acc plugins.Accumulator, input string) error {
data := make(map[string]interface{})
err := json.Unmarshal([]byte(input), &data)
if err != nil {
@ -347,7 +347,7 @@ func decodeStatus(acc telegraf.Accumulator, input string) error {
return nil
}
func decodeStatusOsdmap(acc telegraf.Accumulator, data map[string]interface{}) error {
func decodeStatusOsdmap(acc plugins.Accumulator, data map[string]interface{}) error {
osdmap, ok := data["osdmap"].(map[string]interface{})
if !ok {
return fmt.Errorf("WARNING %s - unable to decode osdmap", measurement)
@ -360,7 +360,7 @@ func decodeStatusOsdmap(acc telegraf.Accumulator, data map[string]interface{}) e
return nil
}
func decodeStatusPgmap(acc telegraf.Accumulator, data map[string]interface{}) error {
func decodeStatusPgmap(acc plugins.Accumulator, data map[string]interface{}) error {
pgmap, ok := data["pgmap"].(map[string]interface{})
if !ok {
return fmt.Errorf("WARNING %s - unable to decode pgmap", measurement)
@ -376,7 +376,7 @@ func decodeStatusPgmap(acc telegraf.Accumulator, data map[string]interface{}) er
return nil
}
func decodeStatusPgmapState(acc telegraf.Accumulator, data map[string]interface{}) error {
func decodeStatusPgmapState(acc plugins.Accumulator, data map[string]interface{}) error {
pgmap, ok := data["pgmap"].(map[string]interface{})
if !ok {
return fmt.Errorf("WARNING %s - unable to decode pgmap", measurement)
@ -409,7 +409,7 @@ func decodeStatusPgmapState(acc telegraf.Accumulator, data map[string]interface{
return nil
}
func decodeDf(acc telegraf.Accumulator, input string) error {
func decodeDf(acc plugins.Accumulator, input string) error {
data := make(map[string]interface{})
err := json.Unmarshal([]byte(input), &data)
if err != nil {
@ -451,7 +451,7 @@ func decodeDf(acc telegraf.Accumulator, input string) error {
return nil
}
func decodeOsdPoolStats(acc telegraf.Accumulator, input string) error {
func decodeOsdPoolStats(acc plugins.Accumulator, input string) error {
data := make([]map[string]interface{}, 0)
err := json.Unmarshal([]byte(input), &data)
if err != nil {

View File

@ -1,7 +1,7 @@
package cgroup
import (
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -34,5 +34,5 @@ func (g *CGroup) Description() string {
}
func init() {
inputs.Add("cgroup", func() telegraf.Input { return &CGroup{} })
inputs.Add("cgroup", func() plugins.Input { return &CGroup{} })
}

View File

@ -11,12 +11,12 @@ import (
"regexp"
"strconv"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
)
const metricName = "cgroup"
func (g *CGroup) Gather(acc telegraf.Accumulator) error {
func (g *CGroup) Gather(acc plugins.Accumulator) error {
list := make(chan pathInfo)
go g.generateDirs(list)
@ -32,7 +32,7 @@ func (g *CGroup) Gather(acc telegraf.Accumulator) error {
return nil
}
func (g *CGroup) gatherDir(dir string, acc telegraf.Accumulator) error {
func (g *CGroup) gatherDir(dir string, acc plugins.Accumulator) error {
fields := make(map[string]interface{})
list := make(chan pathInfo)

View File

@ -3,9 +3,9 @@
package cgroup
import (
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
)
func (g *CGroup) Gather(acc telegraf.Accumulator) error {
func (g *CGroup) Gather(acc plugins.Accumulator) error {
return nil
}

View File

@ -10,7 +10,7 @@ import (
"strings"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -35,7 +35,7 @@ func (*Chrony) SampleConfig() string {
`
}
func (c *Chrony) Gather(acc telegraf.Accumulator) error {
func (c *Chrony) Gather(acc plugins.Accumulator) error {
if len(c.path) == 0 {
return errors.New("chronyc not found: verify that chrony is installed and that chronyc is in your PATH")
}
@ -127,7 +127,7 @@ func init() {
if len(path) > 0 {
c.path = path
}
inputs.Add("chrony", func() telegraf.Input {
inputs.Add("chrony", func() plugins.Input {
return &c
})
}

View File

@ -10,7 +10,7 @@ import (
"github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
internalaws "github.com/influxdata/telegraf/internal/config/aws"
"github.com/influxdata/telegraf/internal/errchan"
@ -176,7 +176,7 @@ func SelectMetrics(c *CloudWatch) ([]*cloudwatch.Metric, error) {
return metrics, nil
}
func (c *CloudWatch) Gather(acc telegraf.Accumulator) error {
func (c *CloudWatch) Gather(acc plugins.Accumulator) error {
if c.client == nil {
c.initializeCloudWatch()
}
@ -210,7 +210,7 @@ func (c *CloudWatch) Gather(acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("cloudwatch", func() telegraf.Input {
inputs.Add("cloudwatch", func() plugins.Input {
ttl, _ := time.ParseDuration("1hr")
return &CloudWatch{
CacheTTL: internal.Duration{Duration: ttl},
@ -281,7 +281,7 @@ func (c *CloudWatch) fetchNamespaceMetrics() ([]*cloudwatch.Metric, error) {
* Gather given Metric and emit any error
*/
func (c *CloudWatch) gatherMetric(
acc telegraf.Accumulator,
acc plugins.Accumulator,
metric *cloudwatch.Metric,
now time.Time,
errChan chan error,

View File

@ -9,7 +9,7 @@ import (
"strconv"
"strings"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
"log"
"path/filepath"
@ -70,7 +70,7 @@ func (c *Conntrack) SampleConfig() string {
return sampleConfig
}
func (c *Conntrack) Gather(acc telegraf.Accumulator) error {
func (c *Conntrack) Gather(acc plugins.Accumulator) error {
c.setDefaults()
var metricKey string
@ -116,5 +116,5 @@ func (c *Conntrack) Gather(acc telegraf.Accumulator) error {
}
func init() {
inputs.Add(inputName, func() telegraf.Input { return &Conntrack{} })
inputs.Add(inputName, func() plugins.Input { return &Conntrack{} })
}

View File

@ -4,7 +4,7 @@ import (
"net/http"
"github.com/hashicorp/consul/api"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -90,7 +90,7 @@ func (c *Consul) createAPIClient() (*api.Client, error) {
return api.NewClient(config)
}
func (c *Consul) GatherHealthCheck(acc telegraf.Accumulator, checks []*api.HealthCheck) {
func (c *Consul) GatherHealthCheck(acc plugins.Accumulator, checks []*api.HealthCheck) {
for _, check := range checks {
record := make(map[string]interface{})
tags := make(map[string]string)
@ -107,7 +107,7 @@ func (c *Consul) GatherHealthCheck(acc telegraf.Accumulator, checks []*api.Healt
}
}
func (c *Consul) Gather(acc telegraf.Accumulator) error {
func (c *Consul) Gather(acc plugins.Accumulator) error {
if c.client == nil {
newClient, err := c.createAPIClient()
@ -130,7 +130,7 @@ func (c *Consul) Gather(acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("consul", func() telegraf.Input {
inputs.Add("consul", func() plugins.Input {
return &Consul{}
})
}

View File

@ -2,7 +2,7 @@ package couchbase
import (
couchbase "github.com/couchbase/go-couchbase"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
"sync"
)
@ -34,7 +34,7 @@ func (r *Couchbase) Description() string {
// Reads stats from all configured clusters. Accumulates stats.
// Returns one of the errors encountered while gathering stats (if any).
func (r *Couchbase) Gather(acc telegraf.Accumulator) error {
func (r *Couchbase) Gather(acc plugins.Accumulator) error {
if len(r.Servers) == 0 {
r.gatherServer("http://localhost:8091/", acc, nil)
return nil
@ -57,7 +57,7 @@ func (r *Couchbase) Gather(acc telegraf.Accumulator) error {
return outerr
}
func (r *Couchbase) gatherServer(addr string, acc telegraf.Accumulator, pool *couchbase.Pool) error {
func (r *Couchbase) gatherServer(addr string, acc plugins.Accumulator, pool *couchbase.Pool) error {
if pool == nil {
client, err := couchbase.Connect(addr)
if err != nil {
@ -98,7 +98,7 @@ func (r *Couchbase) gatherServer(addr string, acc telegraf.Accumulator, pool *co
}
func init() {
inputs.Add("couchbase", func() telegraf.Input {
inputs.Add("couchbase", func() plugins.Input {
return &Couchbase{}
})
}

View File

@ -4,7 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
"net/http"
"reflect"
@ -82,7 +82,7 @@ func (*CouchDB) SampleConfig() string {
`
}
func (c *CouchDB) Gather(accumulator telegraf.Accumulator) error {
func (c *CouchDB) Gather(accumulator plugins.Accumulator) error {
errorChannel := make(chan error, len(c.HOSTs))
var wg sync.WaitGroup
for _, u := range c.HOSTs {
@ -122,7 +122,7 @@ var client = &http.Client{
Timeout: time.Duration(4 * time.Second),
}
func (c *CouchDB) fetchAndInsertData(accumulator telegraf.Accumulator, host string) error {
func (c *CouchDB) fetchAndInsertData(accumulator plugins.Accumulator, host string) error {
response, error := client.Get(host)
if error != nil {
@ -209,7 +209,7 @@ func (c *CouchDB) generateFields(prefix string, obj metaData) map[string]interfa
}
func init() {
inputs.Add("couchdb", func() telegraf.Input {
inputs.Add("couchdb", func() plugins.Input {
return &CouchDB{}
})
}

View File

@ -11,7 +11,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -64,7 +64,7 @@ var ErrProtocolError = errors.New("disque protocol error")
// Reads stats from all configured servers accumulates stats.
// Returns one of the errors encountered while gather stats (if any).
func (g *Disque) Gather(acc telegraf.Accumulator) error {
func (g *Disque) Gather(acc plugins.Accumulator) error {
if len(g.Servers) == 0 {
url := &url.URL{
Host: ":7711",
@ -101,7 +101,7 @@ func (g *Disque) Gather(acc telegraf.Accumulator) error {
const defaultPort = "7711"
func (g *Disque) gatherServer(addr *url.URL, acc telegraf.Accumulator) error {
func (g *Disque) gatherServer(addr *url.URL, acc plugins.Accumulator) error {
if g.c == nil {
_, _, err := net.SplitHostPort(addr.Host)
@ -204,7 +204,7 @@ func (g *Disque) gatherServer(addr *url.URL, acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("disque", func() telegraf.Input {
inputs.Add("disque", func() plugins.Input {
return &Disque{}
})
}

View File

@ -8,7 +8,7 @@ import (
"strconv"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -55,7 +55,7 @@ func (d *DnsQuery) SampleConfig() string {
func (d *DnsQuery) Description() string {
return "Query given DNS server and gives statistics"
}
func (d *DnsQuery) Gather(acc telegraf.Accumulator) error {
func (d *DnsQuery) Gather(acc plugins.Accumulator) error {
d.setDefaultValues()
errChan := errchan.New(len(d.Domains) * len(d.Servers))
@ -156,7 +156,7 @@ func (d *DnsQuery) parseRecordType() (uint16, error) {
}
func init() {
inputs.Add("dns_query", func() telegraf.Input {
inputs.Add("dns_query", func() plugins.Input {
return &DnsQuery{}
})
}

View File

@ -15,7 +15,7 @@ import (
"github.com/docker/engine-api/client"
"github.com/docker/engine-api/types"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -79,7 +79,7 @@ func (d *Docker) Description() string {
func (d *Docker) SampleConfig() string { return sampleConfig }
// Gather starts stats collection
func (d *Docker) Gather(acc telegraf.Accumulator) error {
func (d *Docker) Gather(acc plugins.Accumulator) error {
if d.client == nil {
var c *client.Client
var err error
@ -136,7 +136,7 @@ func (d *Docker) Gather(acc telegraf.Accumulator) error {
return nil
}
func (d *Docker) gatherInfo(acc telegraf.Accumulator) error {
func (d *Docker) gatherInfo(acc plugins.Accumulator) error {
// Init vars
dataFields := make(map[string]interface{})
metadataFields := make(map[string]interface{})
@ -211,7 +211,7 @@ func (d *Docker) gatherInfo(acc telegraf.Accumulator) error {
func (d *Docker) gatherContainer(
container types.Container,
acc telegraf.Accumulator,
acc plugins.Accumulator,
) error {
var v *types.StatsJSON
// Parse container name
@ -272,7 +272,7 @@ func (d *Docker) gatherContainer(
func gatherContainerStats(
stat *types.StatsJSON,
acc telegraf.Accumulator,
acc plugins.Accumulator,
tags map[string]string,
id string,
perDevice bool,
@ -422,7 +422,7 @@ func calculateCPUPercent(stat *types.StatsJSON) float64 {
func gatherBlockIOMetrics(
stat *types.StatsJSON,
acc telegraf.Accumulator,
acc plugins.Accumulator,
tags map[string]string,
now time.Time,
id string,
@ -569,7 +569,7 @@ func parseSize(sizeStr string) (int64, error) {
}
func init() {
inputs.Add("docker", func() telegraf.Input {
inputs.Add("docker", func() plugins.Input {
return &Docker{
PerDevice: true,
Timeout: internal.Duration{Duration: time.Second * 5},

View File

@ -11,7 +11,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -51,7 +51,7 @@ func (d *Dovecot) SampleConfig() string { return sampleConfig }
const defaultPort = "24242"
// Reads stats from all configured servers.
func (d *Dovecot) Gather(acc telegraf.Accumulator) error {
func (d *Dovecot) Gather(acc plugins.Accumulator) error {
if !validQuery[d.Type] {
return fmt.Errorf("Error: %s is not a valid query type\n",
d.Type)
@ -81,7 +81,7 @@ func (d *Dovecot) Gather(acc telegraf.Accumulator) error {
return errChan.Error()
}
func (d *Dovecot) gatherServer(addr string, acc telegraf.Accumulator, qtype string, filter string) error {
func (d *Dovecot) gatherServer(addr string, acc plugins.Accumulator, qtype string, filter string) error {
_, _, err := net.SplitHostPort(addr)
if err != nil {
return fmt.Errorf("Error: %s on url %s\n", err, addr)
@ -111,7 +111,7 @@ func (d *Dovecot) gatherServer(addr string, acc telegraf.Accumulator, qtype stri
return gatherStats(&buf, acc, host, qtype)
}
func gatherStats(buf *bytes.Buffer, acc telegraf.Accumulator, host string, qtype string) error {
func gatherStats(buf *bytes.Buffer, acc plugins.Accumulator, host string, qtype string) error {
lines := strings.Split(buf.String(), "\n")
head := strings.Split(lines[0], "\t")
@ -183,7 +183,7 @@ func secParser(tm string) float64 {
}
func init() {
inputs.Add("dovecot", func() telegraf.Input {
inputs.Add("dovecot", func() plugins.Input {
return &Dovecot{}
})
}

View File

@ -8,7 +8,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
@ -143,7 +143,7 @@ func (e *Elasticsearch) Description() string {
// Gather reads the stats from Elasticsearch and writes it to the
// Accumulator.
func (e *Elasticsearch) Gather(acc telegraf.Accumulator) error {
func (e *Elasticsearch) Gather(acc plugins.Accumulator) error {
if e.client == nil {
client, err := e.createHttpClient()
@ -158,7 +158,7 @@ func (e *Elasticsearch) Gather(acc telegraf.Accumulator) error {
wg.Add(len(e.Servers))
for _, serv := range e.Servers {
go func(s string, acc telegraf.Accumulator) {
go func(s string, acc plugins.Accumulator) {
defer wg.Done()
var url string
if e.Local {
@ -221,7 +221,7 @@ func (e *Elasticsearch) createHttpClient() (*http.Client, error) {
return client, nil
}
func (e *Elasticsearch) gatherNodeStats(url string, acc telegraf.Accumulator) error {
func (e *Elasticsearch) gatherNodeStats(url string, acc plugins.Accumulator) error {
nodeStats := &struct {
ClusterName string `json:"cluster_name"`
Nodes map[string]*nodeStat `json:"nodes"`
@ -273,7 +273,7 @@ func (e *Elasticsearch) gatherNodeStats(url string, acc telegraf.Accumulator) er
return nil
}
func (e *Elasticsearch) gatherClusterHealth(url string, acc telegraf.Accumulator) error {
func (e *Elasticsearch) gatherClusterHealth(url string, acc plugins.Accumulator) error {
healthStats := &clusterHealth{}
if err := e.gatherJsonData(url, healthStats); err != nil {
return err
@ -318,7 +318,7 @@ func (e *Elasticsearch) gatherClusterHealth(url string, acc telegraf.Accumulator
return nil
}
func (e *Elasticsearch) gatherClusterStats(url string, acc telegraf.Accumulator) error {
func (e *Elasticsearch) gatherClusterStats(url string, acc plugins.Accumulator) error {
clusterStats := &clusterStats{}
if err := e.gatherJsonData(url, clusterStats); err != nil {
return err
@ -393,7 +393,7 @@ func (e *Elasticsearch) gatherJsonData(url string, v interface{}) error {
}
func init() {
inputs.Add("elasticsearch", func() telegraf.Input {
inputs.Add("elasticsearch", func() plugins.Input {
return NewElasticsearch()
})
}

View File

@ -13,7 +13,7 @@ import (
"github.com/kballard/go-shellquote"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
@ -61,12 +61,12 @@ func NewExec() *Exec {
}
type Runner interface {
Run(*Exec, string, telegraf.Accumulator) ([]byte, error)
Run(*Exec, string, plugins.Accumulator) ([]byte, error)
}
type CommandRunner struct{}
func AddNagiosState(exitCode error, acc telegraf.Accumulator) error {
func AddNagiosState(exitCode error, acc plugins.Accumulator) error {
nagiosState := 0
if exitCode != nil {
exiterr, ok := exitCode.(*exec.ExitError)
@ -89,7 +89,7 @@ func AddNagiosState(exitCode error, acc telegraf.Accumulator) error {
func (c CommandRunner) Run(
e *Exec,
command string,
acc telegraf.Accumulator,
acc plugins.Accumulator,
) ([]byte, error) {
split_cmd, err := shellquote.Split(command)
if err != nil || len(split_cmd) == 0 {
@ -145,7 +145,7 @@ func removeCarriageReturns(b bytes.Buffer) bytes.Buffer {
}
func (e *Exec) ProcessCommand(command string, acc telegraf.Accumulator, wg *sync.WaitGroup) {
func (e *Exec) ProcessCommand(command string, acc plugins.Accumulator, wg *sync.WaitGroup) {
defer wg.Done()
out, err := e.runner.Run(e, command, acc)
@ -176,7 +176,7 @@ func (e *Exec) SetParser(parser parsers.Parser) {
e.parser = parser
}
func (e *Exec) Gather(acc telegraf.Accumulator) error {
func (e *Exec) Gather(acc plugins.Accumulator) error {
var wg sync.WaitGroup
// Legacy single command support
if e.Command != "" {
@ -226,7 +226,7 @@ func (e *Exec) Gather(acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("exec", func() telegraf.Input {
inputs.Add("exec", func() plugins.Input {
return NewExec()
})
}

View File

@ -6,7 +6,7 @@ import (
"runtime"
"testing"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/parsers"
"github.com/influxdata/telegraf/testutil"
@ -83,7 +83,7 @@ func newRunnerMock(out []byte, err error) Runner {
}
}
func (r runnerMock) Run(e *Exec, command string, acc telegraf.Accumulator) ([]byte, error) {
func (r runnerMock) Run(e *Exec, command string, acc plugins.Accumulator) ([]byte, error) {
if r.err != nil {
return nil, r.err
}

View File

@ -7,7 +7,7 @@ import (
"log"
"os"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal/globpath"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -47,7 +47,7 @@ func (_ *FileStat) Description() string {
func (_ *FileStat) SampleConfig() string { return sampleConfig }
func (f *FileStat) Gather(acc telegraf.Accumulator) error {
func (f *FileStat) Gather(acc plugins.Accumulator) error {
var errS string
var err error
@ -126,7 +126,7 @@ func getMd5(file string) (string, error) {
}
func init() {
inputs.Add("filestat", func() telegraf.Input {
inputs.Add("filestat", func() plugins.Input {
return NewFileStat()
})
}

View File

@ -14,7 +14,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -129,7 +129,7 @@ func (h *GrayLog) Description() string {
}
// Gathers data for all servers.
func (h *GrayLog) Gather(acc telegraf.Accumulator) error {
func (h *GrayLog) Gather(acc plugins.Accumulator) error {
var wg sync.WaitGroup
if h.client.HTTPClient() == nil {
@ -178,14 +178,14 @@ func (h *GrayLog) Gather(acc telegraf.Accumulator) error {
// Gathers data from a particular server
// Parameters:
// acc : The telegraf Accumulator to use
// acc : The plugins.Accumulator to use
// serverURL: endpoint to send request to
// service : the service being queried
//
// Returns:
// error: Any error that may have occurred
func (h *GrayLog) gatherServer(
acc telegraf.Accumulator,
acc plugins.Accumulator,
serverURL string,
) error {
resp, _, err := h.sendRequest(serverURL)
@ -304,7 +304,7 @@ func (h *GrayLog) sendRequest(serverURL string) (string, float64, error) {
}
func init() {
inputs.Add("graylog", func() telegraf.Input {
inputs.Add("graylog", func() plugins.Input {
return &GrayLog{
client: &RealHTTPClient{},
}

View File

@ -13,7 +13,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -115,7 +115,7 @@ func (r *haproxy) Description() string {
// Reads stats from all configured servers accumulates stats.
// Returns one of the errors encountered while gather stats (if any).
func (g *haproxy) Gather(acc telegraf.Accumulator) error {
func (g *haproxy) Gather(acc plugins.Accumulator) error {
if len(g.Servers) == 0 {
return g.gatherServer("http://127.0.0.1:1936/haproxy?stats", acc)
}
@ -160,7 +160,7 @@ func (g *haproxy) Gather(acc telegraf.Accumulator) error {
return errChan.Error()
}
func (g *haproxy) gatherServerSocket(addr string, acc telegraf.Accumulator) error {
func (g *haproxy) gatherServerSocket(addr string, acc plugins.Accumulator) error {
socketPath := getSocketAddr(addr)
c, err := net.Dial("unix", socketPath)
@ -178,7 +178,7 @@ func (g *haproxy) gatherServerSocket(addr string, acc telegraf.Accumulator) erro
return importCsvResult(c, acc, socketPath)
}
func (g *haproxy) gatherServer(addr string, acc telegraf.Accumulator) error {
func (g *haproxy) gatherServer(addr string, acc plugins.Accumulator) error {
if !strings.HasPrefix(addr, "http") {
return g.gatherServerSocket(addr, acc)
}
@ -229,7 +229,7 @@ func getSocketAddr(sock string) string {
}
}
func importCsvResult(r io.Reader, acc telegraf.Accumulator, host string) error {
func importCsvResult(r io.Reader, acc plugins.Accumulator, host string) error {
csv := csv.NewReader(r)
result, err := csv.ReadAll()
now := time.Now()
@ -436,7 +436,7 @@ func importCsvResult(r io.Reader, acc telegraf.Accumulator, host string) error {
}
func init() {
inputs.Add("haproxy", func() telegraf.Input {
inputs.Add("haproxy", func() plugins.Input {
return &haproxy{}
})
}

View File

@ -3,7 +3,7 @@
package hddtemp
import (
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
gohddtemp "github.com/influxdata/telegraf/plugins/inputs/hddtemp/go-hddtemp"
)
@ -40,7 +40,7 @@ func (_ *HDDTemp) SampleConfig() string {
return hddtempSampleConfig
}
func (h *HDDTemp) Gather(acc telegraf.Accumulator) error {
func (h *HDDTemp) Gather(acc plugins.Accumulator) error {
if h.fetcher == nil {
h.fetcher = gohddtemp.New()
}
@ -73,7 +73,7 @@ func (h *HDDTemp) Gather(acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("hddtemp", func() telegraf.Input {
inputs.Add("hddtemp", func() plugins.Input {
return &HDDTemp{
Address: defaultAddress,
Devices: []string{"*"},

View File

@ -10,7 +10,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/influxdata/telegraf/plugins/parsers/influx"
@ -42,7 +42,7 @@ type HTTPListener struct {
listener net.Listener
parser influx.InfluxParser
acc telegraf.Accumulator
acc plugins.Accumulator
pool *pool
BytesRecv selfstat.Stat
@ -84,13 +84,13 @@ func (h *HTTPListener) Description() string {
return "Influx HTTP write listener"
}
func (h *HTTPListener) Gather(_ telegraf.Accumulator) error {
func (h *HTTPListener) Gather(_ plugins.Accumulator) error {
h.BuffersCreated.Set(h.pool.ncreated())
return nil
}
// Start starts the http listener service.
func (h *HTTPListener) Start(acc telegraf.Accumulator) error {
func (h *HTTPListener) Start(acc plugins.Accumulator) error {
h.mu.Lock()
defer h.mu.Unlock()
@ -324,7 +324,7 @@ func badRequest(res http.ResponseWriter) {
}
func init() {
inputs.Add("http_listener", func() telegraf.Input {
inputs.Add("http_listener", func() plugins.Input {
return &HTTPListener{
ServiceAddress: ":8186",
}

View File

@ -8,7 +8,7 @@ import (
"strings"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -141,7 +141,7 @@ func (h *HTTPResponse) HTTPGather() (map[string]interface{}, error) {
}
// Gather gets all metric fields and tags and returns any errors it encounters
func (h *HTTPResponse) Gather(acc telegraf.Accumulator) error {
func (h *HTTPResponse) Gather(acc plugins.Accumulator) error {
// Set default values
if h.ResponseTimeout.Duration < time.Second {
h.ResponseTimeout.Duration = time.Second * 5
@ -174,7 +174,7 @@ func (h *HTTPResponse) Gather(acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("http_response", func() telegraf.Input {
inputs.Add("http_response", func() plugins.Input {
return &HTTPResponse{}
})
}

View File

@ -10,7 +10,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/influxdata/telegraf/plugins/parsers"
@ -120,7 +120,7 @@ func (h *HttpJson) Description() string {
}
// Gathers data for all servers.
func (h *HttpJson) Gather(acc telegraf.Accumulator) error {
func (h *HttpJson) Gather(acc plugins.Accumulator) error {
var wg sync.WaitGroup
if h.client.HTTPClient() == nil {
@ -169,14 +169,14 @@ func (h *HttpJson) Gather(acc telegraf.Accumulator) error {
// Gathers data from a particular server
// Parameters:
// acc : The telegraf Accumulator to use
// acc : The plugins.Accumulator to use
// serverURL: endpoint to send request to
// service : the service being queried
//
// Returns:
// error: Any error that may have occurred
func (h *HttpJson) gatherServer(
acc telegraf.Accumulator,
acc plugins.Accumulator,
serverURL string,
) error {
resp, responseTime, err := h.sendRequest(serverURL)
@ -292,7 +292,7 @@ func (h *HttpJson) sendRequest(serverURL string) (string, float64, error) {
}
func init() {
inputs.Add("httpjson", func() telegraf.Input {
inputs.Add("httpjson", func() plugins.Input {
return &HttpJson{
client: &RealHTTPClient{},
ResponseTimeout: internal.Duration{

View File

@ -9,7 +9,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -43,7 +43,7 @@ func (*InfluxDB) SampleConfig() string {
`
}
func (i *InfluxDB) Gather(acc telegraf.Accumulator) error {
func (i *InfluxDB) Gather(acc plugins.Accumulator) error {
if len(i.URLs) == 0 {
i.URLs = []string{"http://localhost:8086/debug/vars"}
}
@ -125,13 +125,13 @@ type memstats struct {
// Gathers data from a particular URL
// Parameters:
// acc : The telegraf Accumulator to use
// acc : The plugins.Accumulator to use
// url : endpoint to send request to
//
// Returns:
// error: Any error that may have occurred
func (i *InfluxDB) gatherURL(
acc telegraf.Accumulator,
acc plugins.Accumulator,
url string,
) error {
shardCounter := 0
@ -258,7 +258,7 @@ func (i *InfluxDB) gatherURL(
}
func init() {
inputs.Add("influxdb", func() telegraf.Input {
inputs.Add("influxdb", func() plugins.Input {
return &InfluxDB{
Timeout: internal.Duration{Duration: time.Second * 5},
}

View File

@ -3,7 +3,7 @@ package internal
import (
"runtime"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/influxdata/telegraf/selfstat"
)
@ -12,7 +12,7 @@ type Self struct {
CollectMemstats bool
}
func NewSelf() telegraf.Input {
func NewSelf() plugins.Input {
return &Self{
CollectMemstats: true,
}
@ -31,7 +31,7 @@ func (s *Self) SampleConfig() string {
return sampleConfig
}
func (s *Self) Gather(acc telegraf.Accumulator) error {
func (s *Self) Gather(acc plugins.Accumulator) error {
if s.CollectMemstats {
m := &runtime.MemStats{}
runtime.ReadMemStats(m)

View File

@ -5,7 +5,7 @@ import (
"strings"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -37,7 +37,7 @@ func (m *Ipmi) Description() string {
return "Read metrics from one or many bare metal servers"
}
func (m *Ipmi) Gather(acc telegraf.Accumulator) error {
func (m *Ipmi) Gather(acc plugins.Accumulator) error {
if m.runner == nil {
m.runner = CommandRunner{}
}
@ -51,7 +51,7 @@ func (m *Ipmi) Gather(acc telegraf.Accumulator) error {
return nil
}
func (m *Ipmi) gatherServer(serv string, acc telegraf.Accumulator) error {
func (m *Ipmi) gatherServer(serv string, acc plugins.Accumulator) error {
conn := NewConnection(serv)
res, err := m.runner.Run(conn, "sdr")
@ -123,7 +123,7 @@ func transform(s string) string {
}
func init() {
inputs.Add("ipmi_sensor", func() telegraf.Input {
inputs.Add("ipmi_sensor", func() plugins.Input {
return &Ipmi{}
})
}

View File

@ -9,7 +9,7 @@ import (
"strconv"
"strings"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -42,7 +42,7 @@ func (ipt *Iptables) SampleConfig() string {
}
// Gather gathers iptables packets and bytes throughput from the configured tables and chains.
func (ipt *Iptables) Gather(acc telegraf.Accumulator) error {
func (ipt *Iptables) Gather(acc plugins.Accumulator) error {
if ipt.Table == "" || len(ipt.Chains) == 0 {
return nil
}
@ -88,7 +88,7 @@ var chainNameRe = regexp.MustCompile(`^Chain\s+(\S+)`)
var fieldsHeaderRe = regexp.MustCompile(`^\s*pkts\s+bytes\s+`)
var valuesRe = regexp.MustCompile(`^\s*([0-9]+)\s+([0-9]+)\s+.*?(/\*\s(.*)\s\*/)?$`)
func (ipt *Iptables) parseAndGather(data string, acc telegraf.Accumulator) error {
func (ipt *Iptables) parseAndGather(data string, acc plugins.Accumulator) error {
lines := strings.Split(data, "\n")
if len(lines) < 3 {
return nil
@ -120,7 +120,7 @@ func (ipt *Iptables) parseAndGather(data string, acc telegraf.Accumulator) error
type chainLister func(table, chain string) (string, error)
func init() {
inputs.Add("iptables", func() telegraf.Input {
inputs.Add("iptables", func() plugins.Input {
ipt := new(Iptables)
ipt.lister = ipt.chainList
return ipt

View File

@ -10,7 +10,7 @@ import (
"net/url"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -248,7 +248,7 @@ func extractValues(measurement string, value interface{}, fields map[string]inte
}
}
func (j *Jolokia) Gather(acc telegraf.Accumulator) error {
func (j *Jolokia) Gather(acc plugins.Accumulator) error {
if j.jClient == nil {
tr := &http.Transport{ResponseHeaderTimeout: j.ResponseHeaderTimeout.Duration}
@ -297,7 +297,7 @@ func (j *Jolokia) Gather(acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("jolokia", func() telegraf.Input {
inputs.Add("jolokia", func() plugins.Input {
return &Jolokia{
ResponseHeaderTimeout: DefaultResponseHeaderTimeout,
ClientTimeout: DefaultClientTimeout,

View File

@ -5,7 +5,7 @@ import (
"strings"
"sync"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/influxdata/telegraf/plugins/parsers"
@ -37,7 +37,7 @@ type Kafka struct {
done chan struct{}
// keep the accumulator internally:
acc telegraf.Accumulator
acc plugins.Accumulator
// doNotCommitMsgs tells the parser not to call CommitUpTo on the consumer
// this is mostly for test purposes, but there may be a use-case for it later.
@ -75,7 +75,7 @@ func (k *Kafka) SetParser(parser parsers.Parser) {
k.parser = parser
}
func (k *Kafka) Start(acc telegraf.Accumulator) error {
func (k *Kafka) Start(acc plugins.Accumulator) error {
k.Lock()
defer k.Unlock()
var consumerErr error
@ -162,12 +162,12 @@ func (k *Kafka) Stop() {
}
}
func (k *Kafka) Gather(acc telegraf.Accumulator) error {
func (k *Kafka) Gather(acc plugins.Accumulator) error {
return nil
}
func init() {
inputs.Add("kafka_consumer", func() telegraf.Input {
inputs.Add("kafka_consumer", func() plugins.Input {
return &Kafka{}
})
}

View File

@ -9,7 +9,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
@ -54,7 +54,7 @@ const (
)
func init() {
inputs.Add("kubernetes", func() telegraf.Input {
inputs.Add("kubernetes", func() plugins.Input {
return &Kubernetes{}
})
}
@ -70,7 +70,7 @@ func (k *Kubernetes) Description() string {
}
//Gather collects kubernetes metrics from a given URL
func (k *Kubernetes) Gather(acc telegraf.Accumulator) error {
func (k *Kubernetes) Gather(acc plugins.Accumulator) error {
var wg sync.WaitGroup
errChan := errchan.New(1)
wg.Add(1)
@ -91,7 +91,7 @@ func buildURL(endpoint string, base string) (*url.URL, error) {
return addr, nil
}
func (k *Kubernetes) gatherSummary(baseURL string, acc telegraf.Accumulator) error {
func (k *Kubernetes) gatherSummary(baseURL string, acc plugins.Accumulator) error {
url := fmt.Sprintf("%s/stats/summary", baseURL)
var req, err = http.NewRequest("GET", url, nil)
var token []byte
@ -139,7 +139,7 @@ func (k *Kubernetes) gatherSummary(baseURL string, acc telegraf.Accumulator) err
return nil
}
func buildSystemContainerMetrics(summaryMetrics *SummaryMetrics, acc telegraf.Accumulator) {
func buildSystemContainerMetrics(summaryMetrics *SummaryMetrics, acc plugins.Accumulator) {
for _, container := range summaryMetrics.Node.SystemContainers {
tags := map[string]string{
"node_name": summaryMetrics.Node.NodeName,
@ -161,7 +161,7 @@ func buildSystemContainerMetrics(summaryMetrics *SummaryMetrics, acc telegraf.Ac
}
}
func buildNodeMetrics(summaryMetrics *SummaryMetrics, acc telegraf.Accumulator) {
func buildNodeMetrics(summaryMetrics *SummaryMetrics, acc plugins.Accumulator) {
tags := map[string]string{
"node_name": summaryMetrics.Node.NodeName,
}
@ -187,7 +187,7 @@ func buildNodeMetrics(summaryMetrics *SummaryMetrics, acc telegraf.Accumulator)
acc.AddFields("kubernetes_node", fields, tags)
}
func buildPodMetrics(summaryMetrics *SummaryMetrics, acc telegraf.Accumulator) {
func buildPodMetrics(summaryMetrics *SummaryMetrics, acc plugins.Accumulator) {
for _, pod := range summaryMetrics.Pods {
for _, container := range pod.Containers {
tags := map[string]string{

View File

@ -10,7 +10,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -148,7 +148,7 @@ func (l *LeoFS) Description() string {
return "Read metrics from a LeoFS Server via SNMP"
}
func (l *LeoFS) Gather(acc telegraf.Accumulator) error {
func (l *LeoFS) Gather(acc plugins.Accumulator) error {
if len(l.Servers) == 0 {
l.gatherServer(defaultEndpoint, ServerTypeManagerMaster, acc)
return nil
@ -181,7 +181,7 @@ func (l *LeoFS) Gather(acc telegraf.Accumulator) error {
func (l *LeoFS) gatherServer(
endpoint string,
serverType ServerType,
acc telegraf.Accumulator,
acc plugins.Accumulator,
) error {
cmd := exec.Command("snmpwalk", "-v2c", "-cpublic", endpoint, oid)
stdout, err := cmd.StdoutPipe()
@ -231,7 +231,7 @@ func retrieveTokenAfterColon(line string) (string, error) {
}
func init() {
inputs.Add("leofs", func() telegraf.Input {
inputs.Add("leofs", func() plugins.Input {
return &LeoFS{}
})
}

View File

@ -12,7 +12,7 @@ import (
"github.com/vjeantet/grok"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/metric"
)
@ -151,7 +151,7 @@ func (p *Parser) Compile() error {
return p.compileCustomPatterns()
}
func (p *Parser) ParseLine(line string) (telegraf.Metric, error) {
func (p *Parser) ParseLine(line string) (plugins.Metric, error) {
var err error
// values are the parsed fields from the log line
var values map[string]string

View File

@ -4,13 +4,13 @@ import (
"testing"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
var benchM telegraf.Metric
var benchM plugins.Metric
func Benchmark_ParseLine_CommonLogFormat(b *testing.B) {
p := &Parser{
@ -18,7 +18,7 @@ func Benchmark_ParseLine_CommonLogFormat(b *testing.B) {
}
p.Compile()
var m telegraf.Metric
var m plugins.Metric
for n := 0; n < b.N; n++ {
m, _ = p.ParseLine(`127.0.0.1 user-identifier frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326`)
}
@ -31,7 +31,7 @@ func Benchmark_ParseLine_CombinedLogFormat(b *testing.B) {
}
p.Compile()
var m telegraf.Metric
var m plugins.Metric
for n := 0; n < b.N; n++ {
m, _ = p.ParseLine(`127.0.0.1 user-identifier frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "-" "Mozilla"`)
}
@ -50,7 +50,7 @@ func Benchmark_ParseLine_CustomPattern(b *testing.B) {
}
p.Compile()
var m telegraf.Metric
var m plugins.Metric
for n := 0; n < b.N; n++ {
m, _ = p.ParseLine(`[04/Jun/2016:12:41:45 +0100] 1.25 200 192.168.1.1 5.432µs 101`)
}

View File

@ -8,7 +8,7 @@ import (
"github.com/hpcloud/tail"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/internal/globpath"
"github.com/influxdata/telegraf/plugins/inputs"
@ -18,7 +18,7 @@ import (
)
type LogParser interface {
ParseLine(line string) (telegraf.Metric, error)
ParseLine(line string) (plugins.Metric, error)
Compile() error
}
@ -30,7 +30,7 @@ type LogParserPlugin struct {
lines chan string
done chan struct{}
wg sync.WaitGroup
acc telegraf.Accumulator
acc plugins.Accumulator
parsers []LogParser
sync.Mutex
@ -76,11 +76,11 @@ func (l *LogParserPlugin) Description() string {
return "Stream and parse log file(s)."
}
func (l *LogParserPlugin) Gather(acc telegraf.Accumulator) error {
func (l *LogParserPlugin) Gather(acc plugins.Accumulator) error {
return nil
}
func (l *LogParserPlugin) Start(acc telegraf.Accumulator) error {
func (l *LogParserPlugin) Start(acc plugins.Accumulator) error {
l.Lock()
defer l.Unlock()
@ -185,7 +185,7 @@ func (l *LogParserPlugin) receiver(tailer *tail.Tail) {
func (l *LogParserPlugin) parser() {
defer l.wg.Done()
var m telegraf.Metric
var m plugins.Metric
var err error
var line string
for {
@ -225,7 +225,7 @@ func (l *LogParserPlugin) Stop() {
}
func init() {
inputs.Add("logparser", func() telegraf.Input {
inputs.Add("logparser", func() plugins.Input {
return &LogParserPlugin{}
})
}

View File

@ -13,7 +13,7 @@ import (
"strconv"
"strings"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -353,7 +353,7 @@ var wanted_mdt_jobstats_fields = []*mapping{
},
}
func (l *Lustre2) GetLustreProcStats(fileglob string, wanted_fields []*mapping, acc telegraf.Accumulator) error {
func (l *Lustre2) GetLustreProcStats(fileglob string, wanted_fields []*mapping, acc plugins.Accumulator) error {
files, err := filepath.Glob(fileglob)
if err != nil {
return err
@ -422,7 +422,7 @@ func (l *Lustre2) Description() string {
}
// Gather reads stats from all lustre targets
func (l *Lustre2) Gather(acc telegraf.Accumulator) error {
func (l *Lustre2) Gather(acc plugins.Accumulator) error {
l.allFields = make(map[string]map[string]interface{})
if len(l.Ost_procfiles) == 0 {
@ -500,7 +500,7 @@ func (l *Lustre2) Gather(acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("lustre2", func() telegraf.Input {
inputs.Add("lustre2", func() plugins.Input {
return &Lustre2{}
})
}

View File

@ -4,7 +4,7 @@ import (
"fmt"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -35,7 +35,7 @@ func (m *MailChimp) Description() string {
return "Gathers metrics from the /3.0/reports MailChimp API"
}
func (m *MailChimp) Gather(acc telegraf.Accumulator) error {
func (m *MailChimp) Gather(acc plugins.Accumulator) error {
if m.api == nil {
m.api = NewChimpAPI(m.ApiKey)
}
@ -72,7 +72,7 @@ func (m *MailChimp) Gather(acc telegraf.Accumulator) error {
return nil
}
func gatherReport(acc telegraf.Accumulator, report Report, now time.Time) {
func gatherReport(acc plugins.Accumulator, report Report, now time.Time) {
tags := make(map[string]string)
tags["id"] = report.ID
tags["campaign_title"] = report.CampaignTitle
@ -111,7 +111,7 @@ func gatherReport(acc telegraf.Accumulator, report Report, now time.Time) {
}
func init() {
inputs.Add("mailchimp", func() telegraf.Input {
inputs.Add("mailchimp", func() plugins.Input {
return &MailChimp{}
})
}

View File

@ -8,7 +8,7 @@ import (
"strconv"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -69,7 +69,7 @@ func (m *Memcached) Description() string {
}
// Gather reads stats from all configured servers accumulates stats
func (m *Memcached) Gather(acc telegraf.Accumulator) error {
func (m *Memcached) Gather(acc plugins.Accumulator) error {
if len(m.Servers) == 0 && len(m.UnixSockets) == 0 {
return m.gatherServer(":11211", false, acc)
}
@ -89,7 +89,7 @@ func (m *Memcached) Gather(acc telegraf.Accumulator) error {
func (m *Memcached) gatherServer(
address string,
unix bool,
acc telegraf.Accumulator,
acc plugins.Accumulator,
) error {
var conn net.Conn
var err error
@ -180,7 +180,7 @@ func parseResponse(r *bufio.Reader) (map[string]string, error) {
}
func init() {
inputs.Add("memcached", func() telegraf.Input {
inputs.Add("memcached", func() plugins.Input {
return &Memcached{}
})
}

View File

@ -12,7 +12,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
jsonparser "github.com/influxdata/telegraf/plugins/parsers/json"
)
@ -94,7 +94,7 @@ func (m *Mesos) SetDefaults() {
}
// Gather() metrics from given list of Mesos Masters
func (m *Mesos) Gather(acc telegraf.Accumulator) error {
func (m *Mesos) Gather(acc plugins.Accumulator) error {
var wg sync.WaitGroup
var errorChannel chan error
@ -425,7 +425,7 @@ type TaskStats struct {
Statistics map[string]interface{} `json:"statistics"`
}
func (m *Mesos) gatherSlaveTaskMetrics(address string, defaultPort string, acc telegraf.Accumulator) error {
func (m *Mesos) gatherSlaveTaskMetrics(address string, defaultPort string, acc plugins.Accumulator) error {
var metrics []TaskStats
host, _, err := net.SplitHostPort(address)
@ -476,7 +476,7 @@ func (m *Mesos) gatherSlaveTaskMetrics(address string, defaultPort string, acc t
}
// This should not belong to the object
func (m *Mesos) gatherMainMetrics(a string, defaultPort string, role Role, acc telegraf.Accumulator) error {
func (m *Mesos) gatherMainMetrics(a string, defaultPort string, role Role, acc plugins.Accumulator) error {
var jsonOut map[string]interface{}
host, _, err := net.SplitHostPort(a)
@ -532,7 +532,7 @@ func (m *Mesos) gatherMainMetrics(a string, defaultPort string, role Role, acc t
}
func init() {
inputs.Add("mesos", func() telegraf.Input {
inputs.Add("mesos", func() plugins.Input {
return &Mesos{}
})
}

View File

@ -1,7 +1,7 @@
package inputs
import (
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/stretchr/testify/mock"
)
@ -22,7 +22,7 @@ func (m *MockPlugin) SampleConfig() string {
}
// Gather defines what data the plugin will gather.
func (m *MockPlugin) Gather(_a0 telegraf.Accumulator) error {
func (m *MockPlugin) Gather(_a0 plugins.Accumulator) error {
ret := m.Called(_a0)
r0 := ret.Error(0)

View File

@ -9,7 +9,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
"gopkg.in/mgo.v2"
@ -49,7 +49,7 @@ var localhost = &url.URL{Host: "127.0.0.1:27017"}
// Reads stats from all configured servers accumulates stats.
// Returns one of the errors encountered while gather stats (if any).
func (m *MongoDB) Gather(acc telegraf.Accumulator) error {
func (m *MongoDB) Gather(acc plugins.Accumulator) error {
if len(m.Servers) == 0 {
m.gatherServer(m.getMongoServer(localhost), acc)
return nil
@ -89,7 +89,7 @@ func (m *MongoDB) getMongoServer(url *url.URL) *Server {
return m.mongos[url.Host]
}
func (m *MongoDB) gatherServer(server *Server, acc telegraf.Accumulator) error {
func (m *MongoDB) gatherServer(server *Server, acc plugins.Accumulator) error {
if server.Session == nil {
var dialAddrs []string
if server.Url.User != nil {
@ -139,7 +139,7 @@ func (m *MongoDB) gatherServer(server *Server, acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("mongodb", func() telegraf.Input {
inputs.Add("mongodb", func() plugins.Input {
return &MongoDB{
mongos: make(map[string]*Server),
}

View File

@ -5,7 +5,7 @@ import (
"reflect"
"strconv"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
)
type MongodbData struct {
@ -138,7 +138,7 @@ func (d *MongodbData) add(key string, val interface{}) {
d.Fields[key] = val
}
func (d *MongodbData) flush(acc telegraf.Accumulator) {
func (d *MongodbData) flush(acc plugins.Accumulator) {
acc.AddFields(
"mongodb",
d.Fields,

View File

@ -5,7 +5,7 @@ import (
"net/url"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
@ -22,7 +22,7 @@ func (s *Server) getDefaultTags() map[string]string {
return tags
}
func (s *Server) gatherData(acc telegraf.Accumulator, gatherDbStats bool) error {
func (s *Server) gatherData(acc plugins.Accumulator, gatherDbStats bool) error {
s.Session.SetMode(mgo.Eventual, true)
s.Session.SetSocketTimeout(0)
result_server := &ServerStatus{}

View File

@ -7,7 +7,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/influxdata/telegraf/plugins/parsers"
@ -46,7 +46,7 @@ type MQTTConsumer struct {
done chan struct{}
// keep the accumulator internally:
acc telegraf.Accumulator
acc plugins.Accumulator
started bool
}
@ -100,7 +100,7 @@ func (m *MQTTConsumer) SetParser(parser parsers.Parser) {
m.parser = parser
}
func (m *MQTTConsumer) Start(acc telegraf.Accumulator) error {
func (m *MQTTConsumer) Start(acc plugins.Accumulator) error {
m.Lock()
defer m.Unlock()
m.started = false
@ -191,7 +191,7 @@ func (m *MQTTConsumer) Stop() {
m.started = false
}
func (m *MQTTConsumer) Gather(acc telegraf.Accumulator) error {
func (m *MQTTConsumer) Gather(acc plugins.Accumulator) error {
return nil
}
@ -242,7 +242,7 @@ func (m *MQTTConsumer) createOpts() (*mqtt.ClientOptions, error) {
}
func init() {
inputs.Add("mqtt_consumer", func() telegraf.Input {
inputs.Add("mqtt_consumer", func() plugins.Input {
return &MQTTConsumer{}
})
}

View File

@ -9,7 +9,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
@ -118,7 +118,7 @@ func (m *Mysql) InitMysql() {
initDone = true
}
func (m *Mysql) Gather(acc telegraf.Accumulator) error {
func (m *Mysql) Gather(acc plugins.Accumulator) error {
if len(m.Servers) == 0 {
// default to localhost if nothing specified.
return m.gatherServer(localhost, acc)
@ -534,7 +534,7 @@ const (
`
)
func (m *Mysql) gatherServer(serv string, acc telegraf.Accumulator) error {
func (m *Mysql) gatherServer(serv string, acc plugins.Accumulator) error {
serv, err := dsnAddTimeout(serv)
if err != nil {
return err
@ -649,7 +649,7 @@ func (m *Mysql) gatherServer(serv string, acc telegraf.Accumulator) error {
// gatherGlobalVariables can be used to fetch all global variables from
// MySQL environment.
func (m *Mysql) gatherGlobalVariables(db *sql.DB, serv string, acc telegraf.Accumulator) error {
func (m *Mysql) gatherGlobalVariables(db *sql.DB, serv string, acc plugins.Accumulator) error {
// run query
rows, err := db.Query(globalVariablesQuery)
if err != nil {
@ -690,7 +690,7 @@ func (m *Mysql) gatherGlobalVariables(db *sql.DB, serv string, acc telegraf.Accu
// When the server is slave, then it returns only one row.
// If the multi-source replication is set, then everything works differently
// This code does not work with multi-source replication.
func (m *Mysql) gatherSlaveStatuses(db *sql.DB, serv string, acc telegraf.Accumulator) error {
func (m *Mysql) gatherSlaveStatuses(db *sql.DB, serv string, acc plugins.Accumulator) error {
// run query
rows, err := db.Query(slaveStatusQuery)
if err != nil {
@ -734,7 +734,7 @@ func (m *Mysql) gatherSlaveStatuses(db *sql.DB, serv string, acc telegraf.Accumu
// gatherBinaryLogs can be used to collect size and count of all binary files
// binlogs metric requires the MySQL server to turn it on in configuration
func (m *Mysql) gatherBinaryLogs(db *sql.DB, serv string, acc telegraf.Accumulator) error {
func (m *Mysql) gatherBinaryLogs(db *sql.DB, serv string, acc plugins.Accumulator) error {
// run query
rows, err := db.Query(binaryLogsQuery)
if err != nil {
@ -771,7 +771,7 @@ func (m *Mysql) gatherBinaryLogs(db *sql.DB, serv string, acc telegraf.Accumulat
// gatherGlobalStatuses can be used to get MySQL status metrics
// the mappings of actual names and names of each status to be exported
// to output is provided on mappings variable
func (m *Mysql) gatherGlobalStatuses(db *sql.DB, serv string, acc telegraf.Accumulator) error {
func (m *Mysql) gatherGlobalStatuses(db *sql.DB, serv string, acc plugins.Accumulator) error {
// If user forgot the '/', add it
if strings.HasSuffix(serv, ")") {
serv = serv + "/"
@ -889,7 +889,7 @@ func (m *Mysql) gatherGlobalStatuses(db *sql.DB, serv string, acc telegraf.Accum
// GatherProcessList can be used to collect metrics on each running command
// and its state with its running count
func (m *Mysql) GatherProcessListStatuses(db *sql.DB, serv string, acc telegraf.Accumulator) error {
func (m *Mysql) GatherProcessListStatuses(db *sql.DB, serv string, acc plugins.Accumulator) error {
// run query
rows, err := db.Query(infoSchemaProcessListQuery)
if err != nil {
@ -934,7 +934,7 @@ func (m *Mysql) GatherProcessListStatuses(db *sql.DB, serv string, acc telegraf.
// gatherPerfTableIOWaits can be used to get total count and time
// of I/O wait event for each table and process
func (m *Mysql) gatherPerfTableIOWaits(db *sql.DB, serv string, acc telegraf.Accumulator) error {
func (m *Mysql) gatherPerfTableIOWaits(db *sql.DB, serv string, acc plugins.Accumulator) error {
rows, err := db.Query(perfTableIOWaitsQuery)
if err != nil {
return err
@ -983,7 +983,7 @@ func (m *Mysql) gatherPerfTableIOWaits(db *sql.DB, serv string, acc telegraf.Acc
// gatherPerfIndexIOWaits can be used to get total count and time
// of I/O wait event for each index and process
func (m *Mysql) gatherPerfIndexIOWaits(db *sql.DB, serv string, acc telegraf.Accumulator) error {
func (m *Mysql) gatherPerfIndexIOWaits(db *sql.DB, serv string, acc plugins.Accumulator) error {
rows, err := db.Query(perfIndexIOWaitsQuery)
if err != nil {
return err
@ -1036,7 +1036,7 @@ func (m *Mysql) gatherPerfIndexIOWaits(db *sql.DB, serv string, acc telegraf.Acc
}
// gatherInfoSchemaAutoIncStatuses can be used to get auto incremented values of the column
func (m *Mysql) gatherInfoSchemaAutoIncStatuses(db *sql.DB, serv string, acc telegraf.Accumulator) error {
func (m *Mysql) gatherInfoSchemaAutoIncStatuses(db *sql.DB, serv string, acc plugins.Accumulator) error {
rows, err := db.Query(infoSchemaAutoIncQuery)
if err != nil {
return err
@ -1073,7 +1073,7 @@ func (m *Mysql) gatherInfoSchemaAutoIncStatuses(db *sql.DB, serv string, acc tel
// the total number and time for SQL and external lock wait events
// for each table and operation
// requires the MySQL server to be enabled to save this metric
func (m *Mysql) gatherPerfTableLockWaits(db *sql.DB, serv string, acc telegraf.Accumulator) error {
func (m *Mysql) gatherPerfTableLockWaits(db *sql.DB, serv string, acc plugins.Accumulator) error {
// check if table exists,
// if performance_schema is not enabled, tables do not exist
// then there is no need to scan them
@ -1202,7 +1202,7 @@ func (m *Mysql) gatherPerfTableLockWaits(db *sql.DB, serv string, acc telegraf.A
}
// gatherPerfEventWaits can be used to get total time and number of event waits
func (m *Mysql) gatherPerfEventWaits(db *sql.DB, serv string, acc telegraf.Accumulator) error {
func (m *Mysql) gatherPerfEventWaits(db *sql.DB, serv string, acc plugins.Accumulator) error {
rows, err := db.Query(perfEventWaitsQuery)
if err != nil {
return err
@ -1234,7 +1234,7 @@ func (m *Mysql) gatherPerfEventWaits(db *sql.DB, serv string, acc telegraf.Accum
}
// gatherPerfFileEvents can be used to get stats on file events
func (m *Mysql) gatherPerfFileEventsStatuses(db *sql.DB, serv string, acc telegraf.Accumulator) error {
func (m *Mysql) gatherPerfFileEventsStatuses(db *sql.DB, serv string, acc plugins.Accumulator) error {
rows, err := db.Query(perfFileEventsQuery)
if err != nil {
return err
@ -1292,7 +1292,7 @@ func (m *Mysql) gatherPerfFileEventsStatuses(db *sql.DB, serv string, acc telegr
}
// gatherPerfEventsStatements can be used to get attributes of each event
func (m *Mysql) gatherPerfEventsStatements(db *sql.DB, serv string, acc telegraf.Accumulator) error {
func (m *Mysql) gatherPerfEventsStatements(db *sql.DB, serv string, acc plugins.Accumulator) error {
query := fmt.Sprintf(
perfEventsStatementsQuery,
m.PerfEventsStatementsDigestTextLimit,
@ -1359,7 +1359,7 @@ func (m *Mysql) gatherPerfEventsStatements(db *sql.DB, serv string, acc telegraf
}
// gatherTableSchema can be used to gather stats on each schema
func (m *Mysql) gatherTableSchema(db *sql.DB, serv string, acc telegraf.Accumulator) error {
func (m *Mysql) gatherTableSchema(db *sql.DB, serv string, acc plugins.Accumulator) error {
var dbList []string
servtag := getDSNTag(serv)
@ -1539,7 +1539,7 @@ func getDSNTag(dsn string) string {
}
func init() {
inputs.Add("mysql", func() telegraf.Input {
inputs.Add("mysql", func() plugins.Input {
return &Mysql{}
})
}

View File

@ -5,7 +5,7 @@ import (
"log"
"sync"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/influxdata/telegraf/plugins/parsers"
"github.com/nats-io/nats"
@ -47,7 +47,7 @@ type natsConsumer struct {
// channel for all NATS read errors
errs chan error
done chan struct{}
acc telegraf.Accumulator
acc plugins.Accumulator
}
var sampleConfig = `
@ -93,7 +93,7 @@ func (n *natsConsumer) natsErrHandler(c *nats.Conn, s *nats.Subscription, e erro
}
// Start the nats consumer. Caller must call *natsConsumer.Stop() to clean up.
func (n *natsConsumer) Start(acc telegraf.Accumulator) error {
func (n *natsConsumer) Start(acc plugins.Accumulator) error {
n.Lock()
defer n.Unlock()
@ -197,12 +197,12 @@ func (n *natsConsumer) Stop() {
n.Unlock()
}
func (n *natsConsumer) Gather(acc telegraf.Accumulator) error {
func (n *natsConsumer) Gather(acc plugins.Accumulator) error {
return nil
}
func init() {
inputs.Add("nats_consumer", func() telegraf.Input {
inputs.Add("nats_consumer", func() plugins.Input {
return &natsConsumer{
Servers: []string{"nats://localhost:4222"},
Secure: false,

View File

@ -8,7 +8,7 @@ import (
"regexp"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -147,7 +147,7 @@ func (n *NetResponse) UdpGather() (map[string]interface{}, error) {
return fields, nil
}
func (n *NetResponse) Gather(acc telegraf.Accumulator) error {
func (n *NetResponse) Gather(acc plugins.Accumulator) error {
// Set default values
if n.Timeout.Duration == 0 {
n.Timeout.Duration = time.Second
@ -195,7 +195,7 @@ func (n *NetResponse) Gather(acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("net_response", func() telegraf.Input {
inputs.Add("net_response", func() plugins.Input {
return &NetResponse{}
})
}

View File

@ -11,7 +11,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -33,7 +33,7 @@ func (n *Nginx) Description() string {
return "Read Nginx's basic status information (ngx_http_stub_status_module)"
}
func (n *Nginx) Gather(acc telegraf.Accumulator) error {
func (n *Nginx) Gather(acc plugins.Accumulator) error {
var wg sync.WaitGroup
errChan := errchan.New(len(n.Urls))
@ -63,7 +63,7 @@ var client = &http.Client{
Timeout: time.Duration(4 * time.Second),
}
func (n *Nginx) gatherUrl(addr *url.URL, acc telegraf.Accumulator) error {
func (n *Nginx) gatherUrl(addr *url.URL, acc plugins.Accumulator) error {
resp, err := client.Get(addr.String())
if err != nil {
return fmt.Errorf("error making HTTP request to %s: %s", addr.String(), err)
@ -164,7 +164,7 @@ func getTags(addr *url.URL) map[string]string {
}
func init() {
inputs.Add("nginx", func() telegraf.Input {
inputs.Add("nginx", func() plugins.Input {
return &Nginx{}
})
}

View File

@ -31,7 +31,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -51,7 +51,7 @@ const (
)
func init() {
inputs.Add("nsq", func() telegraf.Input {
inputs.Add("nsq", func() plugins.Input {
return &NSQ{}
})
}
@ -64,7 +64,7 @@ func (n *NSQ) Description() string {
return "Read NSQ topic and channel statistics."
}
func (n *NSQ) Gather(acc telegraf.Accumulator) error {
func (n *NSQ) Gather(acc plugins.Accumulator) error {
var wg sync.WaitGroup
errChan := errchan.New(len(n.Endpoints))
for _, e := range n.Endpoints {
@ -88,7 +88,7 @@ var client = &http.Client{
Timeout: time.Duration(4 * time.Second),
}
func (n *NSQ) gatherEndpoint(e string, acc telegraf.Accumulator) error {
func (n *NSQ) gatherEndpoint(e string, acc plugins.Accumulator) error {
u, err := buildURL(e)
if err != nil {
return err
@ -139,7 +139,7 @@ func buildURL(e string) (*url.URL, error) {
return addr, nil
}
func topicStats(t TopicStats, acc telegraf.Accumulator, host, version string) {
func topicStats(t TopicStats, acc plugins.Accumulator, host, version string) {
// per topic overall (tag: name, paused, channel count)
tags := map[string]string{
"server_host": host,
@ -160,7 +160,7 @@ func topicStats(t TopicStats, acc telegraf.Accumulator, host, version string) {
}
}
func channelStats(c ChannelStats, acc telegraf.Accumulator, host, version, topic string) {
func channelStats(c ChannelStats, acc plugins.Accumulator, host, version, topic string) {
tags := map[string]string{
"server_host": host,
"server_version": version,
@ -185,7 +185,7 @@ func channelStats(c ChannelStats, acc telegraf.Accumulator, host, version, topic
}
}
func clientStats(c ClientStats, acc telegraf.Accumulator, host, version, topic, channel string) {
func clientStats(c ClientStats, acc plugins.Accumulator, host, version, topic, channel string) {
tags := map[string]string{
"server_host": host,
"server_version": version,

View File

@ -3,7 +3,7 @@ package nsq_consumer
import (
"log"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/influxdata/telegraf/plugins/parsers"
"github.com/nsqio/go-nsq"
@ -17,7 +17,7 @@ type NSQConsumer struct {
MaxInFlight int
parser parsers.Parser
consumer *nsq.Consumer
acc telegraf.Accumulator
acc plugins.Accumulator
}
var sampleConfig = `
@ -35,7 +35,7 @@ var sampleConfig = `
`
func init() {
inputs.Add("nsq_consumer", func() telegraf.Input {
inputs.Add("nsq_consumer", func() plugins.Input {
return &NSQConsumer{}
})
}
@ -56,7 +56,7 @@ func (n *NSQConsumer) Description() string {
}
// Start pulls data from nsq
func (n *NSQConsumer) Start(acc telegraf.Accumulator) error {
func (n *NSQConsumer) Start(acc plugins.Accumulator) error {
n.acc = acc
n.connect()
n.consumer.AddConcurrentHandlers(nsq.HandlerFunc(func(message *nsq.Message) error {
@ -81,7 +81,7 @@ func (n *NSQConsumer) Stop() {
}
// Gather is a noop
func (n *NSQConsumer) Gather(acc telegraf.Accumulator) error {
func (n *NSQConsumer) Gather(acc plugins.Accumulator) error {
return nil
}

View File

@ -6,7 +6,7 @@ import (
"os"
"strconv"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -58,7 +58,7 @@ func (ns *Nstat) SampleConfig() string {
return sampleConfig
}
func (ns *Nstat) Gather(acc telegraf.Accumulator) error {
func (ns *Nstat) Gather(acc plugins.Accumulator) error {
// load paths, get from env if config values are empty
ns.loadPaths()
@ -95,7 +95,7 @@ func (ns *Nstat) Gather(acc telegraf.Accumulator) error {
return nil
}
func (ns *Nstat) gatherNetstat(data []byte, acc telegraf.Accumulator) error {
func (ns *Nstat) gatherNetstat(data []byte, acc plugins.Accumulator) error {
metrics, err := loadUglyTable(data, ns.DumpZeros)
if err != nil {
return err
@ -107,7 +107,7 @@ func (ns *Nstat) gatherNetstat(data []byte, acc telegraf.Accumulator) error {
return nil
}
func (ns *Nstat) gatherSNMP(data []byte, acc telegraf.Accumulator) error {
func (ns *Nstat) gatherSNMP(data []byte, acc plugins.Accumulator) error {
metrics, err := loadUglyTable(data, ns.DumpZeros)
if err != nil {
return err
@ -119,7 +119,7 @@ func (ns *Nstat) gatherSNMP(data []byte, acc telegraf.Accumulator) error {
return nil
}
func (ns *Nstat) gatherSNMP6(data []byte, acc telegraf.Accumulator) error {
func (ns *Nstat) gatherSNMP6(data []byte, acc plugins.Accumulator) error {
metrics, err := loadGoodTable(data, ns.DumpZeros)
if err != nil {
return err
@ -227,7 +227,7 @@ func proc(env, path string) string {
}
func init() {
inputs.Add("nstat", func() telegraf.Input {
inputs.Add("nstat", func() plugins.Input {
return &Nstat{}
})
}

View File

@ -10,7 +10,7 @@ import (
"strconv"
"strings"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -61,7 +61,7 @@ func (n *NTPQ) SampleConfig() string {
`
}
func (n *NTPQ) Gather(acc telegraf.Accumulator) error {
func (n *NTPQ) Gather(acc plugins.Accumulator) error {
out, err := n.runQ()
if err != nil {
return err
@ -209,7 +209,7 @@ func (n *NTPQ) runq() ([]byte, error) {
}
func init() {
inputs.Add("ntpq", func() telegraf.Input {
inputs.Add("ntpq", func() plugins.Input {
n := &NTPQ{}
n.runQ = n.runq
return n

View File

@ -8,7 +8,7 @@ import (
"strconv"
"strings"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
"golang.org/x/net/html/charset"
)
@ -145,7 +145,7 @@ func (r *passenger) Description() string {
return "Read metrics of passenger using passenger-status"
}
func (g *passenger) Gather(acc telegraf.Accumulator) error {
func (g *passenger) Gather(acc plugins.Accumulator) error {
if g.Command == "" {
g.Command = "passenger-status -v --show=xml"
}
@ -164,7 +164,7 @@ func (g *passenger) Gather(acc telegraf.Accumulator) error {
return nil
}
func importMetric(stat []byte, acc telegraf.Accumulator) error {
func importMetric(stat []byte, acc plugins.Accumulator) error {
var p info
decoder := xml.NewDecoder(bytes.NewReader(stat))
@ -244,7 +244,7 @@ func importMetric(stat []byte, acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("passenger", func() telegraf.Input {
inputs.Add("passenger", func() plugins.Input {
return &passenger{}
})
}

View File

@ -12,7 +12,7 @@ import (
"strings"
"sync"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -73,7 +73,7 @@ func (r *phpfpm) Description() string {
// Reads stats from all configured servers accumulates stats.
// Returns one of the errors encountered while gather stats (if any).
func (g *phpfpm) Gather(acc telegraf.Accumulator) error {
func (g *phpfpm) Gather(acc plugins.Accumulator) error {
if len(g.Urls) == 0 {
return g.gatherServer("http://127.0.0.1/status", acc)
}
@ -96,7 +96,7 @@ func (g *phpfpm) Gather(acc telegraf.Accumulator) error {
}
// Request status page to get stat raw data and import it
func (g *phpfpm) gatherServer(addr string, acc telegraf.Accumulator) error {
func (g *phpfpm) gatherServer(addr string, acc plugins.Accumulator) error {
if g.client == nil {
client := &http.Client{}
g.client = client
@ -154,7 +154,7 @@ func (g *phpfpm) gatherServer(addr string, acc telegraf.Accumulator) error {
}
// Gather stat using fcgi protocol
func (g *phpfpm) gatherFcgi(fcgi *conn, statusPath string, acc telegraf.Accumulator) error {
func (g *phpfpm) gatherFcgi(fcgi *conn, statusPath string, acc plugins.Accumulator) error {
fpmOutput, fpmErr, err := fcgi.Request(map[string]string{
"SCRIPT_NAME": "/" + statusPath,
"SCRIPT_FILENAME": statusPath,
@ -174,7 +174,7 @@ func (g *phpfpm) gatherFcgi(fcgi *conn, statusPath string, acc telegraf.Accumula
}
// Gather stat using http protocol
func (g *phpfpm) gatherHttp(addr string, acc telegraf.Accumulator) error {
func (g *phpfpm) gatherHttp(addr string, acc plugins.Accumulator) error {
u, err := url.Parse(addr)
if err != nil {
return fmt.Errorf("Unable parse server address '%s': %s", addr, err)
@ -199,7 +199,7 @@ func (g *phpfpm) gatherHttp(addr string, acc telegraf.Accumulator) error {
}
// Import stat data into Telegraf system
func importMetric(r io.Reader, acc telegraf.Accumulator) (poolStat, error) {
func importMetric(r io.Reader, acc plugins.Accumulator) (poolStat, error) {
stats := make(poolStat)
var currentPool string
@ -254,7 +254,7 @@ func importMetric(r io.Reader, acc telegraf.Accumulator) (poolStat, error) {
}
func init() {
inputs.Add("phpfpm", func() telegraf.Input {
inputs.Add("phpfpm", func() plugins.Input {
return &phpfpm{}
})
}

View File

@ -11,7 +11,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -65,7 +65,7 @@ func (_ *Ping) SampleConfig() string {
return sampleConfig
}
func (p *Ping) Gather(acc telegraf.Accumulator) error {
func (p *Ping) Gather(acc plugins.Accumulator) error {
var wg sync.WaitGroup
errorChannel := make(chan error, len(p.Urls)*2)
@ -203,7 +203,7 @@ func processPingOutput(out string) (int, int, float64, float64, error) {
}
func init() {
inputs.Add("ping", func() telegraf.Input {
inputs.Add("ping", func() plugins.Input {
return &Ping{
pingHost: hostPinger,
PingInterval: 1.0,

View File

@ -3,7 +3,7 @@ package ping
import (
"errors"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
"os/exec"
@ -144,7 +144,7 @@ func (p *Ping) args(url string) []string {
return args
}
func (p *Ping) Gather(acc telegraf.Accumulator) error {
func (p *Ping) Gather(acc plugins.Accumulator) error {
var wg sync.WaitGroup
errorChannel := make(chan error, len(p.Urls)*2)
var pendingError error = nil
@ -217,7 +217,7 @@ func (p *Ping) Gather(acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("ping", func() telegraf.Input {
inputs.Add("ping", func() plugins.Input {
return &Ping{pingHost: hostPinger}
})
}

View File

@ -8,7 +8,7 @@ import (
"sort"
"strings"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/lib/pq"
@ -64,7 +64,7 @@ func (p *Postgresql) IgnoredColumns() map[string]bool {
var localhost = "host=localhost sslmode=disable"
func (p *Postgresql) Gather(acc telegraf.Accumulator) error {
func (p *Postgresql) Gather(acc plugins.Accumulator) error {
var query string
if p.Address == "" || p.Address == "localhost" {
@ -161,7 +161,7 @@ func (p *Postgresql) SanitizedAddress() (_ string, err error) {
return p.sanitizedAddress, err
}
func (p *Postgresql) accRow(row scanner, acc telegraf.Accumulator) error {
func (p *Postgresql) accRow(row scanner, acc plugins.Accumulator) error {
var columnVars []interface{}
var dbname bytes.Buffer
@ -214,7 +214,7 @@ func (p *Postgresql) accRow(row scanner, acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("postgresql", func() telegraf.Input {
inputs.Add("postgresql", func() plugins.Input {
return &Postgresql{}
})
}

View File

@ -8,7 +8,7 @@ import (
"regexp"
"strings"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/lib/pq"
@ -113,7 +113,7 @@ func (p *Postgresql) IgnoredColumns() map[string]bool {
var localhost = "host=localhost sslmode=disable"
func (p *Postgresql) Gather(acc telegraf.Accumulator) error {
func (p *Postgresql) Gather(acc plugins.Accumulator) error {
var sql_query string
var query_addon string
@ -224,7 +224,7 @@ func (p *Postgresql) SanitizedAddress() (_ string, err error) {
return p.sanitizedAddress, err
}
func (p *Postgresql) accRow(meas_name string, row scanner, acc telegraf.Accumulator) error {
func (p *Postgresql) accRow(meas_name string, row scanner, acc plugins.Accumulator) error {
var columnVars []interface{}
var dbname bytes.Buffer
@ -299,7 +299,7 @@ COLUMN:
}
func init() {
inputs.Add("postgresql_extensible", func() telegraf.Input {
inputs.Add("postgresql_extensible", func() plugins.Input {
return &Postgresql{}
})
}

View File

@ -10,7 +10,7 @@ import (
"strings"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -34,7 +34,7 @@ func (p *Powerdns) Description() string {
return "Read metrics from one or many PowerDNS servers"
}
func (p *Powerdns) Gather(acc telegraf.Accumulator) error {
func (p *Powerdns) Gather(acc plugins.Accumulator) error {
if len(p.UnixSockets) == 0 {
return p.gatherServer("/var/run/pdns.controlsocket", acc)
}
@ -48,7 +48,7 @@ func (p *Powerdns) Gather(acc telegraf.Accumulator) error {
return nil
}
func (p *Powerdns) gatherServer(address string, acc telegraf.Accumulator) error {
func (p *Powerdns) gatherServer(address string, acc plugins.Accumulator) error {
conn, err := net.DialTimeout("unix", address, defaultTimeout)
if err != nil {
return err
@ -121,7 +121,7 @@ func parseResponse(metrics string) map[string]interface{} {
}
func init() {
inputs.Add("powerdns", func() telegraf.Input {
inputs.Add("powerdns", func() plugins.Input {
return &Powerdns{}
})
}

View File

@ -10,7 +10,7 @@ import (
"github.com/shirou/gopsutil/process"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -66,7 +66,7 @@ func (_ *Procstat) Description() string {
return "Monitor process cpu and memory usage"
}
func (p *Procstat) Gather(acc telegraf.Accumulator) error {
func (p *Procstat) Gather(acc plugins.Accumulator) error {
err := p.createProcesses()
if err != nil {
log.Printf("E! Error: procstat getting process, exe: [%s] pidfile: [%s] pattern: [%s] user: [%s] %s",
@ -234,7 +234,7 @@ func (p *Procstat) pidsFromUser() ([]int32, error) {
}
func init() {
inputs.Add("procstat", func() telegraf.Input {
inputs.Add("procstat", func() plugins.Input {
return NewProcstat()
})
}

View File

@ -5,7 +5,7 @@ import (
"github.com/shirou/gopsutil/process"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
)
type SpecProcessor struct {
@ -13,7 +13,7 @@ type SpecProcessor struct {
pid int32
tags map[string]string
fields map[string]interface{}
acc telegraf.Accumulator
acc plugins.Accumulator
proc *process.Process
}
@ -21,7 +21,7 @@ func NewSpecProcessor(
processName string,
prefix string,
pid int32,
acc telegraf.Accumulator,
acc plugins.Accumulator,
p *process.Process,
tags map[string]string,
) *SpecProcessor {

View File

@ -13,7 +13,7 @@ import (
"net/http"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/metric"
"github.com/matttproud/golang_protobuf_extensions/pbutil"
@ -23,8 +23,8 @@ import (
// Parse returns a slice of Metrics from a text representation of a
// metrics
func Parse(buf []byte, header http.Header) ([]telegraf.Metric, error) {
var metrics []telegraf.Metric
func Parse(buf []byte, header http.Header) ([]plugins.Metric, error) {
var metrics []plugins.Metric
var parser expfmt.TextParser
// parse even if the buffer begins with a newline
buf = bytes.TrimPrefix(buf, []byte("\n"))

View File

@ -3,7 +3,7 @@ package prometheus
import (
"errors"
"fmt"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
"io/ioutil"
@ -63,7 +63,7 @@ var ErrProtocolError = errors.New("prometheus protocol error")
// Reads stats from all configured servers accumulates stats.
// Returns one of the errors encountered while gather stats (if any).
func (p *Prometheus) Gather(acc telegraf.Accumulator) error {
func (p *Prometheus) Gather(acc plugins.Accumulator) error {
var wg sync.WaitGroup
var outerr error
@ -90,7 +90,7 @@ var client = &http.Client{
Timeout: time.Duration(4 * time.Second),
}
func (p *Prometheus) gatherURL(url string, acc telegraf.Accumulator) error {
func (p *Prometheus) gatherURL(url string, acc plugins.Accumulator) error {
collectDate := time.Now()
var req, err = http.NewRequest("GET", url, nil)
req.Header.Add("Accept", acceptHeader)
@ -152,7 +152,7 @@ func (p *Prometheus) gatherURL(url string, acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("prometheus", func() telegraf.Input {
inputs.Add("prometheus", func() plugins.Input {
return &Prometheus{ResponseTimeout: internal.Duration{Duration: time.Second * 3}}
})
}

View File

@ -8,7 +8,7 @@ import (
"reflect"
"strings"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -83,7 +83,7 @@ func (pa *PuppetAgent) Description() string {
}
// Gather reads stats from all configured servers accumulates stats
func (pa *PuppetAgent) Gather(acc telegraf.Accumulator) error {
func (pa *PuppetAgent) Gather(acc plugins.Accumulator) error {
if len(pa.Location) == 0 {
pa.Location = "/var/lib/puppet/state/last_run_summary.yaml"
@ -111,7 +111,7 @@ func (pa *PuppetAgent) Gather(acc telegraf.Accumulator) error {
return nil
}
func structPrinter(s *State, acc telegraf.Accumulator, tags map[string]string) {
func structPrinter(s *State, acc plugins.Accumulator, tags map[string]string) {
e := reflect.ValueOf(s).Elem()
fields := make(map[string]interface{})
@ -132,7 +132,7 @@ func structPrinter(s *State, acc telegraf.Accumulator, tags map[string]string) {
}
func init() {
inputs.Add("puppetagent", func() telegraf.Input {
inputs.Add("puppetagent", func() plugins.Input {
return &PuppetAgent{}
})
}

View File

@ -8,7 +8,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
@ -136,7 +136,7 @@ type Node struct {
}
// gatherFunc ...
type gatherFunc func(r *RabbitMQ, acc telegraf.Accumulator, errChan chan error)
type gatherFunc func(r *RabbitMQ, acc plugins.Accumulator, errChan chan error)
var gatherFunctions = []gatherFunc{gatherOverview, gatherNodes, gatherQueues}
@ -179,7 +179,7 @@ func (r *RabbitMQ) Description() string {
}
// Gather ...
func (r *RabbitMQ) Gather(acc telegraf.Accumulator) error {
func (r *RabbitMQ) Gather(acc plugins.Accumulator) error {
if r.Client == nil {
tlsCfg, err := internal.GetTLSConfig(
r.SSLCert, r.SSLKey, r.SSLCA, r.InsecureSkipVerify)
@ -245,7 +245,7 @@ func (r *RabbitMQ) requestJSON(u string, target interface{}) error {
return nil
}
func gatherOverview(r *RabbitMQ, acc telegraf.Accumulator, errChan chan error) {
func gatherOverview(r *RabbitMQ, acc plugins.Accumulator, errChan chan error) {
overview := &OverviewResponse{}
err := r.requestJSON("/api/overview", &overview)
@ -281,7 +281,7 @@ func gatherOverview(r *RabbitMQ, acc telegraf.Accumulator, errChan chan error) {
errChan <- nil
}
func gatherNodes(r *RabbitMQ, acc telegraf.Accumulator, errChan chan error) {
func gatherNodes(r *RabbitMQ, acc plugins.Accumulator, errChan chan error) {
nodes := make([]Node, 0)
// Gather information about nodes
err := r.requestJSON("/api/nodes", &nodes)
@ -318,7 +318,7 @@ func gatherNodes(r *RabbitMQ, acc telegraf.Accumulator, errChan chan error) {
errChan <- nil
}
func gatherQueues(r *RabbitMQ, acc telegraf.Accumulator, errChan chan error) {
func gatherQueues(r *RabbitMQ, acc plugins.Accumulator, errChan chan error) {
// Gather information about queues
queues := make([]Queue, 0)
err := r.requestJSON("/api/queues", &queues)
@ -404,7 +404,7 @@ func (r *RabbitMQ) shouldGatherQueue(queue Queue) bool {
}
func init() {
inputs.Add("rabbitmq", func() telegraf.Input {
inputs.Add("rabbitmq", func() plugins.Input {
return &RabbitMQ{
ResponseHeaderTimeout: internal.Duration{Duration: DefaultResponseHeaderTimeout * time.Second},
ClientTimeout: internal.Duration{Duration: DefaultClientTimeout * time.Second},

View File

@ -11,7 +11,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -33,7 +33,7 @@ func (r *Raindrops) Description() string {
return "Read raindrops stats (raindrops - real-time stats for preforking Rack servers)"
}
func (r *Raindrops) Gather(acc telegraf.Accumulator) error {
func (r *Raindrops) Gather(acc plugins.Accumulator) error {
var wg sync.WaitGroup
var outerr error
@ -55,7 +55,7 @@ func (r *Raindrops) Gather(acc telegraf.Accumulator) error {
return outerr
}
func (r *Raindrops) gatherUrl(addr *url.URL, acc telegraf.Accumulator) error {
func (r *Raindrops) gatherUrl(addr *url.URL, acc plugins.Accumulator) error {
resp, err := r.http_client.Get(addr.String())
if err != nil {
return fmt.Errorf("error making HTTP request to %s: %s", addr.String(), err)
@ -176,7 +176,7 @@ func (r *Raindrops) getTags(addr *url.URL) map[string]string {
}
func init() {
inputs.Add("raindrops", func() telegraf.Input {
inputs.Add("raindrops", func() plugins.Input {
return &Raindrops{http_client: &http.Client{
Transport: &http.Transport{
ResponseHeaderTimeout: time.Duration(3 * time.Second),

View File

@ -11,7 +11,7 @@ import (
"sync"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
)
@ -55,7 +55,7 @@ const defaultPort = "6379"
// Reads stats from all configured servers accumulates stats.
// Returns one of the errors encountered while gather stats (if any).
func (r *Redis) Gather(acc telegraf.Accumulator) error {
func (r *Redis) Gather(acc plugins.Accumulator) error {
if len(r.Servers) == 0 {
url := &url.URL{
Scheme: "tcp",
@ -99,7 +99,7 @@ func (r *Redis) Gather(acc telegraf.Accumulator) error {
return errChan.Error()
}
func (r *Redis) gatherServer(addr *url.URL, acc telegraf.Accumulator) error {
func (r *Redis) gatherServer(addr *url.URL, acc plugins.Accumulator) error {
var address string
if addr.Scheme == "unix" {
@ -154,7 +154,7 @@ func (r *Redis) gatherServer(addr *url.URL, acc telegraf.Accumulator) error {
// gatherInfoOutput gathers
func gatherInfoOutput(
rdr *bufio.Reader,
acc telegraf.Accumulator,
acc plugins.Accumulator,
tags map[string]string,
) error {
var section string
@ -256,7 +256,7 @@ func gatherInfoOutput(
func gatherKeyspaceLine(
name string,
line string,
acc telegraf.Accumulator,
acc plugins.Accumulator,
global_tags map[string]string,
) {
if strings.Contains(line, "keys=") {
@ -279,7 +279,7 @@ func gatherKeyspaceLine(
}
func init() {
inputs.Add("redis", func() telegraf.Input {
inputs.Add("redis", func() plugins.Input {
return &Redis{}
})
}

View File

@ -1,8 +1,8 @@
package inputs
import "github.com/influxdata/telegraf"
import "github.com/influxdata/telegraf/plugins"
type Creator func() telegraf.Input
type Creator func() plugins.Input
var Inputs = map[string]Creator{}

View File

@ -5,7 +5,7 @@ import (
"net/url"
"sync"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
"gopkg.in/dancannon/gorethink.v1"
@ -36,7 +36,7 @@ var localhost = &Server{Url: &url.URL{Host: "127.0.0.1:28015"}}
// Reads stats from all configured servers accumulates stats.
// Returns one of the errors encountered while gather stats (if any).
func (r *RethinkDB) Gather(acc telegraf.Accumulator) error {
func (r *RethinkDB) Gather(acc plugins.Accumulator) error {
if len(r.Servers) == 0 {
r.gatherServer(localhost, acc)
return nil
@ -66,7 +66,7 @@ func (r *RethinkDB) Gather(acc telegraf.Accumulator) error {
return outerr
}
func (r *RethinkDB) gatherServer(server *Server, acc telegraf.Accumulator) error {
func (r *RethinkDB) gatherServer(server *Server, acc plugins.Accumulator) error {
var err error
connectOpts := gorethink.ConnectOpts{
Address: server.Url.Host,
@ -88,7 +88,7 @@ func (r *RethinkDB) gatherServer(server *Server, acc telegraf.Accumulator) error
}
func init() {
inputs.Add("rethinkdb", func() telegraf.Input {
inputs.Add("rethinkdb", func() plugins.Input {
return &RethinkDB{}
})
}

View File

@ -4,7 +4,7 @@ import (
"reflect"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
)
type serverStatus struct {
@ -88,7 +88,7 @@ var engineStats = map[string]string{
func (e *Engine) AddEngineStats(
keys []string,
acc telegraf.Accumulator,
acc plugins.Accumulator,
tags map[string]string,
) {
engine := reflect.ValueOf(e).Elem()
@ -99,7 +99,7 @@ func (e *Engine) AddEngineStats(
acc.AddFields("rethinkdb_engine", fields, tags)
}
func (s *Storage) AddStats(acc telegraf.Accumulator, tags map[string]string) {
func (s *Storage) AddStats(acc plugins.Accumulator, tags map[string]string) {
fields := map[string]interface{}{
"cache_bytes_in_use": s.Cache.BytesInUse,
"disk_read_bytes_per_sec": s.Disk.ReadBytesPerSec,

Some files were not shown because too many files have changed in this diff Show More