From 81caa5685967e74ac5d190c4f376bde9b7ca604e Mon Sep 17 00:00:00 2001 From: David Norton Date: Fri, 23 Dec 2016 10:18:27 -0500 Subject: [PATCH] move plugin interfaces into separate package --- agent/accumulator.go | 16 +++---- agent/accumulator_test.go | 46 +++++++++---------- agent/agent.go | 20 ++++---- cmd/telegraf/telegraf.go | 10 ++-- internal/buffer/buffer.go | 12 ++--- internal/buffer/buffer_test.go | 4 +- internal/config/config.go | 6 +-- internal/models/makemetric.go | 6 +-- internal/models/running_aggregator.go | 22 ++++----- internal/models/running_aggregator_test.go | 32 ++++++------- internal/models/running_input.go | 10 ++-- internal/models/running_input_test.go | 36 +++++++-------- internal/models/running_output.go | 10 ++-- internal/models/running_output_test.go | 16 +++---- internal/models/running_processor.go | 8 ++-- internal/models/running_processor_test.go | 12 ++--- metric/metric.go | 24 +++++----- metric/metric_benchmark_test.go | 10 ++-- metric/metric_test.go | 12 ++--- metric/parse.go | 12 ++--- accumulator.go => plugins/accumulator.go | 2 +- aggregator.go => plugins/aggregator.go | 2 +- plugins/aggregators/minmax/minmax.go | 10 ++-- plugins/aggregators/registry.go | 4 +- input.go => plugins/input.go | 2 +- plugins/inputs/aerospike/aerospike.go | 8 ++-- plugins/inputs/apache/apache.go | 8 ++-- plugins/inputs/bcache/bcache.go | 8 ++-- plugins/inputs/cassandra/cassandra.go | 14 +++--- plugins/inputs/ceph/ceph.go | 24 +++++----- plugins/inputs/cgroup/cgroup.go | 4 +- plugins/inputs/cgroup/cgroup_linux.go | 6 +-- plugins/inputs/cgroup/cgroup_notlinux.go | 4 +- plugins/inputs/chrony/chrony.go | 6 +-- plugins/inputs/cloudwatch/cloudwatch.go | 8 ++-- plugins/inputs/conntrack/conntrack.go | 6 +-- plugins/inputs/consul/consul.go | 8 ++-- plugins/inputs/couchbase/couchbase.go | 8 ++-- plugins/inputs/couchdb/couchdb.go | 8 ++-- plugins/inputs/disque/disque.go | 8 ++-- plugins/inputs/dns_query/dns_query.go | 6 +-- plugins/inputs/docker/docker.go | 14 +++--- plugins/inputs/dovecot/dovecot.go | 10 ++-- plugins/inputs/elasticsearch/elasticsearch.go | 14 +++--- plugins/inputs/exec/exec.go | 14 +++--- plugins/inputs/exec/exec_test.go | 4 +- plugins/inputs/filestat/filestat.go | 6 +-- plugins/inputs/graylog/graylog.go | 10 ++-- plugins/inputs/haproxy/haproxy.go | 12 ++--- plugins/inputs/hddtemp/hddtemp.go | 6 +-- plugins/inputs/http_listener/http_listener.go | 10 ++-- plugins/inputs/http_response/http_response.go | 6 +-- plugins/inputs/httpjson/httpjson.go | 10 ++-- plugins/inputs/influxdb/influxdb.go | 10 ++-- plugins/inputs/internal/internal.go | 6 +-- plugins/inputs/ipmi_sensor/ipmi.go | 8 ++-- plugins/inputs/iptables/iptables.go | 8 ++-- plugins/inputs/jolokia/jolokia.go | 6 +-- .../inputs/kafka_consumer/kafka_consumer.go | 10 ++-- plugins/inputs/kubernetes/kubernetes.go | 14 +++--- plugins/inputs/leofs/leofs.go | 8 ++-- plugins/inputs/logparser/grok/grok.go | 4 +- plugins/inputs/logparser/grok/grok_test.go | 10 ++-- plugins/inputs/logparser/logparser.go | 14 +++--- plugins/inputs/lustre2/lustre2.go | 8 ++-- plugins/inputs/mailchimp/mailchimp.go | 8 ++-- plugins/inputs/memcached/memcached.go | 8 ++-- plugins/inputs/mesos/mesos.go | 10 ++-- plugins/inputs/mock_Plugin.go | 4 +- plugins/inputs/mongodb/mongodb.go | 8 ++-- plugins/inputs/mongodb/mongodb_data.go | 4 +- plugins/inputs/mongodb/mongodb_server.go | 4 +- plugins/inputs/mqtt_consumer/mqtt_consumer.go | 10 ++-- plugins/inputs/mysql/mysql.go | 34 +++++++------- plugins/inputs/nats_consumer/nats_consumer.go | 10 ++-- plugins/inputs/net_response/net_response.go | 6 +-- plugins/inputs/nginx/nginx.go | 8 ++-- plugins/inputs/nsq/nsq.go | 14 +++--- plugins/inputs/nsq_consumer/nsq_consumer.go | 10 ++-- plugins/inputs/nstat/nstat.go | 12 ++--- plugins/inputs/ntpq/ntpq.go | 6 +-- plugins/inputs/passenger/passenger.go | 8 ++-- plugins/inputs/phpfpm/phpfpm.go | 14 +++--- plugins/inputs/ping/ping.go | 6 +-- plugins/inputs/ping/ping_windows.go | 6 +-- plugins/inputs/postgresql/postgresql.go | 8 ++-- .../postgresql_extensible.go | 8 ++-- plugins/inputs/powerdns/powerdns.go | 8 ++-- plugins/inputs/procstat/procstat.go | 6 +-- plugins/inputs/procstat/spec_processor.go | 6 +-- plugins/inputs/prometheus/parser.go | 6 +-- plugins/inputs/prometheus/prometheus.go | 8 ++-- plugins/inputs/puppetagent/puppetagent.go | 8 ++-- plugins/inputs/rabbitmq/rabbitmq.go | 14 +++--- plugins/inputs/raindrops/raindrops.go | 8 ++-- plugins/inputs/redis/redis.go | 12 ++--- plugins/inputs/registry.go | 4 +- plugins/inputs/rethinkdb/rethinkdb.go | 8 ++-- plugins/inputs/rethinkdb/rethinkdb_data.go | 6 +-- plugins/inputs/rethinkdb/rethinkdb_server.go | 10 ++-- plugins/inputs/riak/riak.go | 8 ++-- plugins/inputs/sensors/sensors.go | 10 ++-- plugins/inputs/snmp/snmp.go | 8 ++-- plugins/inputs/snmp_legacy/snmp_legacy.go | 14 +++--- plugins/inputs/sqlserver/sqlserver.go | 10 ++-- plugins/inputs/statsd/statsd.go | 8 ++-- plugins/inputs/sysstat/sysstat.go | 12 ++--- plugins/inputs/system/cpu.go | 6 +-- plugins/inputs/system/disk.go | 10 ++-- plugins/inputs/system/kernel.go | 6 +-- plugins/inputs/system/kernel_notlinux.go | 6 +-- plugins/inputs/system/kernel_vmstat.go | 6 +-- plugins/inputs/system/memory.go | 10 ++-- plugins/inputs/system/net.go | 6 +-- plugins/inputs/system/netstat.go | 6 +-- plugins/inputs/system/processes.go | 6 +-- plugins/inputs/system/ps.go | 4 +- plugins/inputs/system/system.go | 6 +-- plugins/inputs/tail/tail.go | 12 ++--- plugins/inputs/tcp_listener/tcp_listener.go | 12 ++--- plugins/inputs/trig/trig.go | 6 +-- plugins/inputs/twemproxy/twemproxy.go | 12 ++--- plugins/inputs/udp_listener/udp_listener.go | 12 ++--- plugins/inputs/varnish/varnish.go | 6 +-- .../webhooks/filestack/filestack_webhooks.go | 6 +-- .../inputs/webhooks/github/github_webhooks.go | 6 +-- .../webhooks/github/github_webhooks_models.go | 46 +++++++++---------- .../webhooks/mandrill/mandrill_webhooks.go | 6 +-- .../webhooks/rollbar/rollbar_webhooks.go | 6 +-- plugins/inputs/webhooks/webhooks.go | 12 ++--- .../win_perf_counters/win_perf_counters.go | 6 +-- plugins/inputs/zfs/zfs_freebsd.go | 8 ++-- plugins/inputs/zfs/zfs_linux.go | 8 ++-- plugins/inputs/zfs/zfs_other.go | 6 +-- plugins/inputs/zookeeper/zookeeper.go | 8 ++-- metric.go => plugins/metric.go | 2 +- output.go => plugins/output.go | 2 +- plugins/outputs/amon/amon.go | 8 ++-- plugins/outputs/amon/amon_test.go | 4 +- plugins/outputs/amqp/amqp.go | 6 +-- plugins/outputs/cloudwatch/cloudwatch.go | 10 ++-- plugins/outputs/cloudwatch/cloudwatch_test.go | 4 +- plugins/outputs/datadog/datadog.go | 8 ++-- plugins/outputs/datadog/datadog_test.go | 6 +-- plugins/outputs/discard/discard.go | 6 +-- plugins/outputs/file/file.go | 6 +-- plugins/outputs/graphite/graphite.go | 6 +-- plugins/outputs/graphite/graphite_test.go | 6 +-- plugins/outputs/graylog/graylog.go | 8 ++-- plugins/outputs/influxdb/influxdb.go | 6 +-- plugins/outputs/instrumental/instrumental.go | 8 ++-- .../outputs/instrumental/instrumental_test.go | 6 +-- plugins/outputs/kafka/kafka.go | 6 +-- plugins/outputs/kinesis/kinesis.go | 6 +-- plugins/outputs/librato/librato.go | 8 ++-- plugins/outputs/librato/librato_test.go | 12 ++--- plugins/outputs/mqtt/mqtt.go | 6 +-- plugins/outputs/nats/nats.go | 6 +-- plugins/outputs/nsq/nsq.go | 6 +-- plugins/outputs/opentsdb/opentsdb.go | 10 ++-- plugins/outputs/opentsdb/opentsdb_test.go | 4 +- .../prometheus_client/prometheus_client.go | 10 ++-- .../prometheus_client_test.go | 10 ++-- plugins/outputs/registry.go | 4 +- plugins/outputs/riemann/riemann.go | 8 ++-- plugins/parsers/graphite/parser.go | 8 ++-- plugins/parsers/influx/parser.go | 8 ++-- plugins/parsers/influx/parser_test.go | 4 +- plugins/parsers/json/parser.go | 14 +++--- plugins/parsers/nagios/parser.go | 8 ++-- plugins/parsers/registry.go | 6 +-- plugins/parsers/value/parser.go | 10 ++-- processor.go => plugins/processor.go | 2 +- plugins/processors/printer/printer.go | 6 +-- plugins/processors/registry.go | 4 +- plugins/serializers/graphite/graphite.go | 4 +- plugins/serializers/influx/influx.go | 4 +- plugins/serializers/json/json.go | 4 +- plugins/serializers/registry.go | 4 +- selfstat/selfstat.go | 6 +-- testutil/accumulator.go | 4 +- testutil/testutil.go | 10 ++-- 182 files changed, 817 insertions(+), 817 deletions(-) rename accumulator.go => plugins/accumulator.go (98%) rename aggregator.go => plugins/aggregator.go (97%) rename input.go => plugins/input.go (98%) rename metric.go => plugins/metric.go (98%) rename output.go => plugins/output.go (98%) rename processor.go => plugins/processor.go (94%) diff --git a/agent/accumulator.go b/agent/accumulator.go index 1f9e2270d..097da1881 100644 --- a/agent/accumulator.go +++ b/agent/accumulator.go @@ -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 } } diff --git a/agent/accumulator_test.go b/agent/accumulator_test.go index e13446bac..15bb8d4c0 100644 --- a/agent/accumulator_test.go +++ b/agent/accumulator_test.go @@ -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 } } diff --git a/agent/agent.go b/agent/agent.go index ab64154e0..a4513648b 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -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. diff --git a/cmd/telegraf/telegraf.go b/cmd/telegraf/telegraf.go index dec155d12..d4924156a 100644 --- a/cmd/telegraf/telegraf.go +++ b/cmd/telegraf/telegraf.go @@ -13,10 +13,10 @@ import ( "strings" "syscall" - "github.com/influxdata/telegraf" "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" @@ -367,13 +367,13 @@ func registerPlugin(pluginsDir, filePath string, p *plugin.Plugin) error { name := strings.Replace(filePath, string(os.PathSeparator), ".", -1) if create, err := p.Lookup("NewInput"); err == nil { - inputs.Add(name, inputs.Creator(create.(func() telegraf.Input))) + 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() telegraf.Output))) + 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() telegraf.Processor))) + 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() telegraf.Aggregator))) + aggregators.Add(name, aggregators.Creator(create.(func() plugins.Aggregator))) } else { return fmt.Errorf("not a telegraf plugin: %s%s", filePath, ext) } diff --git a/internal/buffer/buffer.go b/internal/buffer/buffer.go index 5e7818ef1..a049462e9 100644 --- a/internal/buffer/buffer.go +++ b/internal/buffer/buffer.go @@ -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 } diff --git a/internal/buffer/buffer_test.go b/internal/buffer/buffer_test.go index f84d8c66d..b54e1ae39 100644 --- a/internal/buffer/buffer_test.go +++ b/internal/buffer/buffer_test.go @@ -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"), diff --git a/internal/config/config.go b/internal/config/config.go index 24dec4169..465856e9c 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -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 diff --git a/internal/models/makemetric.go b/internal/models/makemetric.go index 4e398043a..dece2832f 100644 --- a/internal/models/makemetric.go +++ b/internal/models/makemetric.go @@ -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 } diff --git a/internal/models/running_aggregator.go b/internal/models/running_aggregator.go index 8189a6667..1ff5f3236 100644 --- a/internal/models/running_aggregator.go +++ b/internal/models/running_aggregator.go @@ -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. diff --git a/internal/models/running_aggregator_test.go b/internal/models/running_aggregator_test.go index 30279f0ee..eb332bc44 100644 --- a/internal/models/running_aggregator_test.go +++ b/internal/models/running_aggregator_test.go @@ -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) diff --git a/internal/models/running_input.go b/internal/models/running_input.go index 4279a7f62..da91c47d1 100644 --- a/internal/models/running_input.go +++ b/internal/models/running_input.go @@ -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, diff --git a/internal/models/running_input_test.go b/internal/models/running_input_test.go index 33c785c6e..adad1896a 100644 --- a/internal/models/running_input_test.go +++ b/internal/models/running_input_test.go @@ -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 } diff --git a/internal/models/running_output.go b/internal/models/running_output.go index 0ae78c983..f3048daff 100644 --- a/internal/models/running_output.go +++ b/internal/models/running_output.go @@ -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 diff --git a/internal/models/running_output_test.go b/internal/models/running_output_test.go index c55334218..e775f42bd 100644 --- a/internal/models/running_output_test.go +++ b/internal/models/running_output_test.go @@ -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!") } diff --git a/internal/models/running_processor.go b/internal/models/running_processor.go index 600b61928..a0dbb9218 100644 --- a/internal/models/running_processor.go +++ b/internal/models/running_processor.go @@ -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() { diff --git a/internal/models/running_processor_test.go b/internal/models/running_processor_test.go index 8a691a9b8..100a6e0e0 100644 --- a/internal/models/running_processor_test.go +++ b/internal/models/running_processor_test.go @@ -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"), diff --git a/metric/metric.go b/metric/metric.go index 8a18c0f2c..c20118fd0 100644 --- a/metric/metric.go +++ b/metric/metric.go @@ -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)), diff --git a/metric/metric_benchmark_test.go b/metric/metric_benchmark_test.go index 9383fb0dc..022c2f646 100644 --- a/metric/metric_benchmark_test.go +++ b/metric/metric_benchmark_test.go @@ -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) } diff --git a/metric/metric_test.go b/metric/metric_test.go index f209dc3e4..31024a6f6 100644 --- a/metric/metric_test.go +++ b/metric/metric_test.go @@ -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()) diff --git a/metric/parse.go b/metric/parse.go index fe2cffdc1..d38f167a2 100644 --- a/metric/parse.go +++ b/metric/parse.go @@ -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) diff --git a/accumulator.go b/plugins/accumulator.go similarity index 98% rename from accumulator.go rename to plugins/accumulator.go index 13fd6e571..52f10abda 100644 --- a/accumulator.go +++ b/plugins/accumulator.go @@ -1,4 +1,4 @@ -package telegraf +package plugins import "time" diff --git a/aggregator.go b/plugins/aggregator.go similarity index 97% rename from aggregator.go rename to plugins/aggregator.go index 48aa8e4bf..d1bc753e8 100644 --- a/aggregator.go +++ b/plugins/aggregator.go @@ -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 diff --git a/plugins/aggregators/minmax/minmax.go b/plugins/aggregators/minmax/minmax.go index 1c83c0cc2..fc2d2f43c 100644 --- a/plugins/aggregators/minmax/minmax.go +++ b/plugins/aggregators/minmax/minmax.go @@ -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() }) } diff --git a/plugins/aggregators/registry.go b/plugins/aggregators/registry.go index 77a9c9a64..339b93375 100644 --- a/plugins/aggregators/registry.go +++ b/plugins/aggregators/registry.go @@ -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{} diff --git a/input.go b/plugins/input.go similarity index 98% rename from input.go rename to plugins/input.go index f7e1493e2..d51eba1e0 100644 --- a/input.go +++ b/plugins/input.go @@ -1,4 +1,4 @@ -package telegraf +package plugins type Input interface { // SampleConfig returns the default configuration of the Input diff --git a/plugins/inputs/aerospike/aerospike.go b/plugins/inputs/aerospike/aerospike.go index 10f7fcd40..026fc42ed 100644 --- a/plugins/inputs/aerospike/aerospike.go +++ b/plugins/inputs/aerospike/aerospike.go @@ -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{} }) } diff --git a/plugins/inputs/apache/apache.go b/plugins/inputs/apache/apache.go index 85e7ee4d9..fe29c484b 100644 --- a/plugins/inputs/apache/apache.go +++ b/plugins/inputs/apache/apache.go @@ -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{} }) } diff --git a/plugins/inputs/bcache/bcache.go b/plugins/inputs/bcache/bcache.go index 1171dbd92..563d397c7 100644 --- a/plugins/inputs/bcache/bcache.go +++ b/plugins/inputs/bcache/bcache.go @@ -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{} }) } diff --git a/plugins/inputs/cassandra/cassandra.go b/plugins/inputs/cassandra/cassandra.go index 710a2b661..3f877d1fb 100644 --- a/plugins/inputs/cassandra/cassandra.go +++ b/plugins/inputs/cassandra/cassandra.go @@ -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{}}} }) } diff --git a/plugins/inputs/ceph/ceph.go b/plugins/inputs/ceph/ceph.go index 9f0a6ac78..7b3e2804c 100644 --- a/plugins/inputs/ceph/ceph.go +++ b/plugins/inputs/ceph/ceph.go @@ -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 { diff --git a/plugins/inputs/cgroup/cgroup.go b/plugins/inputs/cgroup/cgroup.go index cc5e4b496..3b623d243 100644 --- a/plugins/inputs/cgroup/cgroup.go +++ b/plugins/inputs/cgroup/cgroup.go @@ -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{} }) } diff --git a/plugins/inputs/cgroup/cgroup_linux.go b/plugins/inputs/cgroup/cgroup_linux.go index e8ba6f881..a8d39e3a6 100644 --- a/plugins/inputs/cgroup/cgroup_linux.go +++ b/plugins/inputs/cgroup/cgroup_linux.go @@ -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) diff --git a/plugins/inputs/cgroup/cgroup_notlinux.go b/plugins/inputs/cgroup/cgroup_notlinux.go index 2bc227410..61ff47039 100644 --- a/plugins/inputs/cgroup/cgroup_notlinux.go +++ b/plugins/inputs/cgroup/cgroup_notlinux.go @@ -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 } diff --git a/plugins/inputs/chrony/chrony.go b/plugins/inputs/chrony/chrony.go index f39108921..25f9f2006 100644 --- a/plugins/inputs/chrony/chrony.go +++ b/plugins/inputs/chrony/chrony.go @@ -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 }) } diff --git a/plugins/inputs/cloudwatch/cloudwatch.go b/plugins/inputs/cloudwatch/cloudwatch.go index a812c1265..c290578b2 100644 --- a/plugins/inputs/cloudwatch/cloudwatch.go +++ b/plugins/inputs/cloudwatch/cloudwatch.go @@ -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, diff --git a/plugins/inputs/conntrack/conntrack.go b/plugins/inputs/conntrack/conntrack.go index 841aedb54..7e5405577 100644 --- a/plugins/inputs/conntrack/conntrack.go +++ b/plugins/inputs/conntrack/conntrack.go @@ -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{} }) } diff --git a/plugins/inputs/consul/consul.go b/plugins/inputs/consul/consul.go index 4c28f4d12..e28412cab 100644 --- a/plugins/inputs/consul/consul.go +++ b/plugins/inputs/consul/consul.go @@ -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{} }) } diff --git a/plugins/inputs/couchbase/couchbase.go b/plugins/inputs/couchbase/couchbase.go index 48e0c1a75..9a59ee88e 100644 --- a/plugins/inputs/couchbase/couchbase.go +++ b/plugins/inputs/couchbase/couchbase.go @@ -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{} }) } diff --git a/plugins/inputs/couchdb/couchdb.go b/plugins/inputs/couchdb/couchdb.go index bf241649a..86ba09a25 100644 --- a/plugins/inputs/couchdb/couchdb.go +++ b/plugins/inputs/couchdb/couchdb.go @@ -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{} }) } diff --git a/plugins/inputs/disque/disque.go b/plugins/inputs/disque/disque.go index 0e4baf9cb..57208a613 100644 --- a/plugins/inputs/disque/disque.go +++ b/plugins/inputs/disque/disque.go @@ -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{} }) } diff --git a/plugins/inputs/dns_query/dns_query.go b/plugins/inputs/dns_query/dns_query.go index 1bccc52c0..79827af34 100644 --- a/plugins/inputs/dns_query/dns_query.go +++ b/plugins/inputs/dns_query/dns_query.go @@ -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{} }) } diff --git a/plugins/inputs/docker/docker.go b/plugins/inputs/docker/docker.go index 82a3791b6..8be56a1c5 100644 --- a/plugins/inputs/docker/docker.go +++ b/plugins/inputs/docker/docker.go @@ -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}, diff --git a/plugins/inputs/dovecot/dovecot.go b/plugins/inputs/dovecot/dovecot.go index 56290e759..3c1889c28 100644 --- a/plugins/inputs/dovecot/dovecot.go +++ b/plugins/inputs/dovecot/dovecot.go @@ -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{} }) } diff --git a/plugins/inputs/elasticsearch/elasticsearch.go b/plugins/inputs/elasticsearch/elasticsearch.go index 370e3fbdd..221b5f561 100644 --- a/plugins/inputs/elasticsearch/elasticsearch.go +++ b/plugins/inputs/elasticsearch/elasticsearch.go @@ -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() }) } diff --git a/plugins/inputs/exec/exec.go b/plugins/inputs/exec/exec.go index 154080138..bc37b85f7 100644 --- a/plugins/inputs/exec/exec.go +++ b/plugins/inputs/exec/exec.go @@ -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() }) } diff --git a/plugins/inputs/exec/exec_test.go b/plugins/inputs/exec/exec_test.go index 71d33fb71..044cecbf7 100644 --- a/plugins/inputs/exec/exec_test.go +++ b/plugins/inputs/exec/exec_test.go @@ -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 } diff --git a/plugins/inputs/filestat/filestat.go b/plugins/inputs/filestat/filestat.go index 83f511a84..7f98c9af9 100644 --- a/plugins/inputs/filestat/filestat.go +++ b/plugins/inputs/filestat/filestat.go @@ -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() }) } diff --git a/plugins/inputs/graylog/graylog.go b/plugins/inputs/graylog/graylog.go index 52e2ef42a..47b6531c8 100644 --- a/plugins/inputs/graylog/graylog.go +++ b/plugins/inputs/graylog/graylog.go @@ -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{}, } diff --git a/plugins/inputs/haproxy/haproxy.go b/plugins/inputs/haproxy/haproxy.go index c764a5530..1c183d2eb 100644 --- a/plugins/inputs/haproxy/haproxy.go +++ b/plugins/inputs/haproxy/haproxy.go @@ -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{} }) } diff --git a/plugins/inputs/hddtemp/hddtemp.go b/plugins/inputs/hddtemp/hddtemp.go index ac11218dd..3ea117e5d 100644 --- a/plugins/inputs/hddtemp/hddtemp.go +++ b/plugins/inputs/hddtemp/hddtemp.go @@ -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{"*"}, diff --git a/plugins/inputs/http_listener/http_listener.go b/plugins/inputs/http_listener/http_listener.go index 0f426f809..e6846c49e 100644 --- a/plugins/inputs/http_listener/http_listener.go +++ b/plugins/inputs/http_listener/http_listener.go @@ -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", } diff --git a/plugins/inputs/http_response/http_response.go b/plugins/inputs/http_response/http_response.go index 34eadaa4f..c036cba08 100644 --- a/plugins/inputs/http_response/http_response.go +++ b/plugins/inputs/http_response/http_response.go @@ -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{} }) } diff --git a/plugins/inputs/httpjson/httpjson.go b/plugins/inputs/httpjson/httpjson.go index 89bfccf77..6aad6b17c 100644 --- a/plugins/inputs/httpjson/httpjson.go +++ b/plugins/inputs/httpjson/httpjson.go @@ -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{ diff --git a/plugins/inputs/influxdb/influxdb.go b/plugins/inputs/influxdb/influxdb.go index 3c98eead3..291eaa832 100644 --- a/plugins/inputs/influxdb/influxdb.go +++ b/plugins/inputs/influxdb/influxdb.go @@ -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}, } diff --git a/plugins/inputs/internal/internal.go b/plugins/inputs/internal/internal.go index f6123edd5..8729d510f 100644 --- a/plugins/inputs/internal/internal.go +++ b/plugins/inputs/internal/internal.go @@ -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) diff --git a/plugins/inputs/ipmi_sensor/ipmi.go b/plugins/inputs/ipmi_sensor/ipmi.go index aec56a0e4..d7175a7f6 100644 --- a/plugins/inputs/ipmi_sensor/ipmi.go +++ b/plugins/inputs/ipmi_sensor/ipmi.go @@ -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{} }) } diff --git a/plugins/inputs/iptables/iptables.go b/plugins/inputs/iptables/iptables.go index 4ceb45230..2bb79f034 100644 --- a/plugins/inputs/iptables/iptables.go +++ b/plugins/inputs/iptables/iptables.go @@ -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 diff --git a/plugins/inputs/jolokia/jolokia.go b/plugins/inputs/jolokia/jolokia.go index 32e6a9f57..dec2bc743 100644 --- a/plugins/inputs/jolokia/jolokia.go +++ b/plugins/inputs/jolokia/jolokia.go @@ -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, diff --git a/plugins/inputs/kafka_consumer/kafka_consumer.go b/plugins/inputs/kafka_consumer/kafka_consumer.go index 52117759d..ce5413818 100644 --- a/plugins/inputs/kafka_consumer/kafka_consumer.go +++ b/plugins/inputs/kafka_consumer/kafka_consumer.go @@ -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{} }) } diff --git a/plugins/inputs/kubernetes/kubernetes.go b/plugins/inputs/kubernetes/kubernetes.go index ee95d560f..21bd73bae 100644 --- a/plugins/inputs/kubernetes/kubernetes.go +++ b/plugins/inputs/kubernetes/kubernetes.go @@ -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{ diff --git a/plugins/inputs/leofs/leofs.go b/plugins/inputs/leofs/leofs.go index 06c71e932..0afa6a4a1 100644 --- a/plugins/inputs/leofs/leofs.go +++ b/plugins/inputs/leofs/leofs.go @@ -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{} }) } diff --git a/plugins/inputs/logparser/grok/grok.go b/plugins/inputs/logparser/grok/grok.go index 7131b8249..1a8b9e33c 100644 --- a/plugins/inputs/logparser/grok/grok.go +++ b/plugins/inputs/logparser/grok/grok.go @@ -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 diff --git a/plugins/inputs/logparser/grok/grok_test.go b/plugins/inputs/logparser/grok/grok_test.go index 1344896b8..875bc4f42 100644 --- a/plugins/inputs/logparser/grok/grok_test.go +++ b/plugins/inputs/logparser/grok/grok_test.go @@ -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`) } diff --git a/plugins/inputs/logparser/logparser.go b/plugins/inputs/logparser/logparser.go index 0778a8a6d..fc4da38ed 100644 --- a/plugins/inputs/logparser/logparser.go +++ b/plugins/inputs/logparser/logparser.go @@ -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{} }) } diff --git a/plugins/inputs/lustre2/lustre2.go b/plugins/inputs/lustre2/lustre2.go index 8ef9223b5..2f5a935df 100644 --- a/plugins/inputs/lustre2/lustre2.go +++ b/plugins/inputs/lustre2/lustre2.go @@ -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{} }) } diff --git a/plugins/inputs/mailchimp/mailchimp.go b/plugins/inputs/mailchimp/mailchimp.go index d7255191a..67253d8e8 100644 --- a/plugins/inputs/mailchimp/mailchimp.go +++ b/plugins/inputs/mailchimp/mailchimp.go @@ -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{} }) } diff --git a/plugins/inputs/memcached/memcached.go b/plugins/inputs/memcached/memcached.go index 5ee538e93..70507394c 100644 --- a/plugins/inputs/memcached/memcached.go +++ b/plugins/inputs/memcached/memcached.go @@ -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{} }) } diff --git a/plugins/inputs/mesos/mesos.go b/plugins/inputs/mesos/mesos.go index e6c68bd7d..cc2c74d58 100644 --- a/plugins/inputs/mesos/mesos.go +++ b/plugins/inputs/mesos/mesos.go @@ -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{} }) } diff --git a/plugins/inputs/mock_Plugin.go b/plugins/inputs/mock_Plugin.go index 4dec121bc..e967c0038 100644 --- a/plugins/inputs/mock_Plugin.go +++ b/plugins/inputs/mock_Plugin.go @@ -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) diff --git a/plugins/inputs/mongodb/mongodb.go b/plugins/inputs/mongodb/mongodb.go index a4bdabd96..6038452a9 100644 --- a/plugins/inputs/mongodb/mongodb.go +++ b/plugins/inputs/mongodb/mongodb.go @@ -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), } diff --git a/plugins/inputs/mongodb/mongodb_data.go b/plugins/inputs/mongodb/mongodb_data.go index 47f35f199..ed0cba9f9 100644 --- a/plugins/inputs/mongodb/mongodb_data.go +++ b/plugins/inputs/mongodb/mongodb_data.go @@ -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, diff --git a/plugins/inputs/mongodb/mongodb_server.go b/plugins/inputs/mongodb/mongodb_server.go index e843c70f0..be4a3cfda 100644 --- a/plugins/inputs/mongodb/mongodb_server.go +++ b/plugins/inputs/mongodb/mongodb_server.go @@ -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{} diff --git a/plugins/inputs/mqtt_consumer/mqtt_consumer.go b/plugins/inputs/mqtt_consumer/mqtt_consumer.go index cfade2944..76b9597b5 100644 --- a/plugins/inputs/mqtt_consumer/mqtt_consumer.go +++ b/plugins/inputs/mqtt_consumer/mqtt_consumer.go @@ -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{} }) } diff --git a/plugins/inputs/mysql/mysql.go b/plugins/inputs/mysql/mysql.go index 54f296586..6b48f4b08 100644 --- a/plugins/inputs/mysql/mysql.go +++ b/plugins/inputs/mysql/mysql.go @@ -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{} }) } diff --git a/plugins/inputs/nats_consumer/nats_consumer.go b/plugins/inputs/nats_consumer/nats_consumer.go index cbb85e016..910c9bc0e 100644 --- a/plugins/inputs/nats_consumer/nats_consumer.go +++ b/plugins/inputs/nats_consumer/nats_consumer.go @@ -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, diff --git a/plugins/inputs/net_response/net_response.go b/plugins/inputs/net_response/net_response.go index ad0de46c3..e59c30ad2 100644 --- a/plugins/inputs/net_response/net_response.go +++ b/plugins/inputs/net_response/net_response.go @@ -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{} }) } diff --git a/plugins/inputs/nginx/nginx.go b/plugins/inputs/nginx/nginx.go index 3fe8c04d1..f0eeafa3f 100644 --- a/plugins/inputs/nginx/nginx.go +++ b/plugins/inputs/nginx/nginx.go @@ -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{} }) } diff --git a/plugins/inputs/nsq/nsq.go b/plugins/inputs/nsq/nsq.go index 8bfd72788..0dd64e001 100644 --- a/plugins/inputs/nsq/nsq.go +++ b/plugins/inputs/nsq/nsq.go @@ -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, diff --git a/plugins/inputs/nsq_consumer/nsq_consumer.go b/plugins/inputs/nsq_consumer/nsq_consumer.go index d4f4e9679..4f97920ec 100644 --- a/plugins/inputs/nsq_consumer/nsq_consumer.go +++ b/plugins/inputs/nsq_consumer/nsq_consumer.go @@ -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 } diff --git a/plugins/inputs/nstat/nstat.go b/plugins/inputs/nstat/nstat.go index 5096d7b03..98846e1cc 100644 --- a/plugins/inputs/nstat/nstat.go +++ b/plugins/inputs/nstat/nstat.go @@ -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{} }) } diff --git a/plugins/inputs/ntpq/ntpq.go b/plugins/inputs/ntpq/ntpq.go index 674cd7216..194073603 100644 --- a/plugins/inputs/ntpq/ntpq.go +++ b/plugins/inputs/ntpq/ntpq.go @@ -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 diff --git a/plugins/inputs/passenger/passenger.go b/plugins/inputs/passenger/passenger.go index 84e92cb1a..744e1ae23 100644 --- a/plugins/inputs/passenger/passenger.go +++ b/plugins/inputs/passenger/passenger.go @@ -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{} }) } diff --git a/plugins/inputs/phpfpm/phpfpm.go b/plugins/inputs/phpfpm/phpfpm.go index d7a14d0ee..3eb554d23 100644 --- a/plugins/inputs/phpfpm/phpfpm.go +++ b/plugins/inputs/phpfpm/phpfpm.go @@ -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{} }) } diff --git a/plugins/inputs/ping/ping.go b/plugins/inputs/ping/ping.go index 32264eec7..5089578fe 100644 --- a/plugins/inputs/ping/ping.go +++ b/plugins/inputs/ping/ping.go @@ -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, diff --git a/plugins/inputs/ping/ping_windows.go b/plugins/inputs/ping/ping_windows.go index 7fb112810..82bbf8f18 100644 --- a/plugins/inputs/ping/ping_windows.go +++ b/plugins/inputs/ping/ping_windows.go @@ -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} }) } diff --git a/plugins/inputs/postgresql/postgresql.go b/plugins/inputs/postgresql/postgresql.go index 0e7cdb509..425138f17 100644 --- a/plugins/inputs/postgresql/postgresql.go +++ b/plugins/inputs/postgresql/postgresql.go @@ -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{} }) } diff --git a/plugins/inputs/postgresql_extensible/postgresql_extensible.go b/plugins/inputs/postgresql_extensible/postgresql_extensible.go index beb010fce..be8deb537 100644 --- a/plugins/inputs/postgresql_extensible/postgresql_extensible.go +++ b/plugins/inputs/postgresql_extensible/postgresql_extensible.go @@ -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{} }) } diff --git a/plugins/inputs/powerdns/powerdns.go b/plugins/inputs/powerdns/powerdns.go index 68b1696e0..7b1e51e5a 100644 --- a/plugins/inputs/powerdns/powerdns.go +++ b/plugins/inputs/powerdns/powerdns.go @@ -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{} }) } diff --git a/plugins/inputs/procstat/procstat.go b/plugins/inputs/procstat/procstat.go index 929490e4a..021edf0e9 100644 --- a/plugins/inputs/procstat/procstat.go +++ b/plugins/inputs/procstat/procstat.go @@ -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() }) } diff --git a/plugins/inputs/procstat/spec_processor.go b/plugins/inputs/procstat/spec_processor.go index 3b56fbc3e..5036e8d0a 100644 --- a/plugins/inputs/procstat/spec_processor.go +++ b/plugins/inputs/procstat/spec_processor.go @@ -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 { diff --git a/plugins/inputs/prometheus/parser.go b/plugins/inputs/prometheus/parser.go index 975da27bf..4137c7e3c 100644 --- a/plugins/inputs/prometheus/parser.go +++ b/plugins/inputs/prometheus/parser.go @@ -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")) diff --git a/plugins/inputs/prometheus/prometheus.go b/plugins/inputs/prometheus/prometheus.go index 97da17f04..b4de772f2 100644 --- a/plugins/inputs/prometheus/prometheus.go +++ b/plugins/inputs/prometheus/prometheus.go @@ -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}} }) } diff --git a/plugins/inputs/puppetagent/puppetagent.go b/plugins/inputs/puppetagent/puppetagent.go index c8a265bb8..d54e1deff 100644 --- a/plugins/inputs/puppetagent/puppetagent.go +++ b/plugins/inputs/puppetagent/puppetagent.go @@ -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{} }) } diff --git a/plugins/inputs/rabbitmq/rabbitmq.go b/plugins/inputs/rabbitmq/rabbitmq.go index c33b11e66..e6a5395e8 100644 --- a/plugins/inputs/rabbitmq/rabbitmq.go +++ b/plugins/inputs/rabbitmq/rabbitmq.go @@ -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}, diff --git a/plugins/inputs/raindrops/raindrops.go b/plugins/inputs/raindrops/raindrops.go index 6851f5d93..16365102f 100644 --- a/plugins/inputs/raindrops/raindrops.go +++ b/plugins/inputs/raindrops/raindrops.go @@ -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), diff --git a/plugins/inputs/redis/redis.go b/plugins/inputs/redis/redis.go index 2dd947a2a..0b302e4ce 100644 --- a/plugins/inputs/redis/redis.go +++ b/plugins/inputs/redis/redis.go @@ -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{} }) } diff --git a/plugins/inputs/registry.go b/plugins/inputs/registry.go index 9951cd5cd..2e225b8d4 100644 --- a/plugins/inputs/registry.go +++ b/plugins/inputs/registry.go @@ -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{} diff --git a/plugins/inputs/rethinkdb/rethinkdb.go b/plugins/inputs/rethinkdb/rethinkdb.go index 32237a80f..7511e526e 100644 --- a/plugins/inputs/rethinkdb/rethinkdb.go +++ b/plugins/inputs/rethinkdb/rethinkdb.go @@ -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{} }) } diff --git a/plugins/inputs/rethinkdb/rethinkdb_data.go b/plugins/inputs/rethinkdb/rethinkdb_data.go index ca4ac7552..5246fda1d 100644 --- a/plugins/inputs/rethinkdb/rethinkdb_data.go +++ b/plugins/inputs/rethinkdb/rethinkdb_data.go @@ -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, diff --git a/plugins/inputs/rethinkdb/rethinkdb_server.go b/plugins/inputs/rethinkdb/rethinkdb_server.go index f172717d1..357b214df 100644 --- a/plugins/inputs/rethinkdb/rethinkdb_server.go +++ b/plugins/inputs/rethinkdb/rethinkdb_server.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/plugins" "gopkg.in/dancannon/gorethink.v1" ) @@ -20,7 +20,7 @@ type Server struct { serverStatus serverStatus } -func (s *Server) gatherData(acc telegraf.Accumulator) error { +func (s *Server) gatherData(acc plugins.Accumulator) error { if err := s.getServerStatus(); err != nil { return fmt.Errorf("Failed to get server_status, %s\n", err) } @@ -110,7 +110,7 @@ var ClusterTracking = []string{ "written_docs_per_sec", } -func (s *Server) addClusterStats(acc telegraf.Accumulator) error { +func (s *Server) addClusterStats(acc plugins.Accumulator) error { cursor, err := gorethink.DB("rethinkdb").Table("stats").Get([]string{"cluster"}).Run(s.session) if err != nil { return fmt.Errorf("cluster stats query error, %s\n", err.Error()) @@ -138,7 +138,7 @@ var MemberTracking = []string{ "total_writes", } -func (s *Server) addMemberStats(acc telegraf.Accumulator) error { +func (s *Server) addMemberStats(acc plugins.Accumulator) error { cursor, err := gorethink.DB("rethinkdb").Table("stats").Get([]string{"server", s.serverStatus.Id}).Run(s.session) if err != nil { return fmt.Errorf("member stats query error, %s\n", err.Error()) @@ -162,7 +162,7 @@ var TableTracking = []string{ "total_writes", } -func (s *Server) addTableStats(acc telegraf.Accumulator) error { +func (s *Server) addTableStats(acc plugins.Accumulator) error { tablesCursor, err := gorethink.DB("rethinkdb").Table("table_status").Run(s.session) defer tablesCursor.Close() var tables []tableStatus diff --git a/plugins/inputs/riak/riak.go b/plugins/inputs/riak/riak.go index 19bf7df04..6d05758bf 100644 --- a/plugins/inputs/riak/riak.go +++ b/plugins/inputs/riak/riak.go @@ -7,7 +7,7 @@ import ( "net/url" "time" - "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/plugins" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -96,7 +96,7 @@ func (r *Riak) Description() string { } // Reads stats from all configured servers. -func (r *Riak) Gather(acc telegraf.Accumulator) error { +func (r *Riak) Gather(acc plugins.Accumulator) error { // Default to a single server at localhost (default port) if none specified if len(r.Servers) == 0 { r.Servers = []string{"http://127.0.0.1:8098"} @@ -113,7 +113,7 @@ func (r *Riak) Gather(acc telegraf.Accumulator) error { } // Gathers stats from a single server, adding them to the accumulator -func (r *Riak) gatherServer(s string, acc telegraf.Accumulator) error { +func (r *Riak) gatherServer(s string, acc plugins.Accumulator) error { // Parse the given URL to extract the server tag u, err := url.Parse(s) if err != nil { @@ -200,7 +200,7 @@ func (r *Riak) gatherServer(s string, acc telegraf.Accumulator) error { } func init() { - inputs.Add("riak", func() telegraf.Input { + inputs.Add("riak", func() plugins.Input { return NewRiak() }) } diff --git a/plugins/inputs/sensors/sensors.go b/plugins/inputs/sensors/sensors.go index 1caf6ba59..659228104 100644 --- a/plugins/inputs/sensors/sensors.go +++ b/plugins/inputs/sensors/sensors.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/plugins" "github.com/influxdata/telegraf/internal" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -39,7 +39,7 @@ func (*Sensors) SampleConfig() string { } -func (s *Sensors) Gather(acc telegraf.Accumulator) error { +func (s *Sensors) Gather(acc plugins.Accumulator) error { if len(s.path) == 0 { return errors.New("sensors not found: verify that lm-sensors package is installed and that sensors is in your PATH") } @@ -49,8 +49,8 @@ func (s *Sensors) Gather(acc telegraf.Accumulator) error { // parse forks the command: // sensors -u -A -// and parses the output to add it to the telegraf.Accumulator. -func (s *Sensors) parse(acc telegraf.Accumulator) error { +// and parses the output to add it to the plugins.Accumulator. +func (s *Sensors) parse(acc plugins.Accumulator) error { tags := map[string]string{} fields := map[string]interface{}{} chip := "" @@ -107,7 +107,7 @@ func init() { if len(path) > 0 { s.path = path } - inputs.Add("sensors", func() telegraf.Input { + inputs.Add("sensors", func() plugins.Input { return &s }) } diff --git a/plugins/inputs/snmp/snmp.go b/plugins/inputs/snmp/snmp.go index 5426bf28c..007e83ab1 100644 --- a/plugins/inputs/snmp/snmp.go +++ b/plugins/inputs/snmp/snmp.go @@ -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" @@ -309,7 +309,7 @@ func Errorf(err error, msg string, format ...interface{}) error { } func init() { - inputs.Add("snmp", func() telegraf.Input { + inputs.Add("snmp", func() plugins.Input { return &Snmp{ Retries: 3, MaxRepetitions: 10, @@ -333,7 +333,7 @@ func (s *Snmp) Description() string { // Gather retrieves all the configured fields and tables. // Any error encountered does not halt the process. The errors are accumulated // and returned at the end. -func (s *Snmp) Gather(acc telegraf.Accumulator) error { +func (s *Snmp) Gather(acc plugins.Accumulator) error { if err := s.init(); err != nil { return err } @@ -366,7 +366,7 @@ func (s *Snmp) Gather(acc telegraf.Accumulator) error { return nil } -func (s *Snmp) gatherTable(acc telegraf.Accumulator, gs snmpConnection, t Table, topTags map[string]string, walk bool) error { +func (s *Snmp) gatherTable(acc plugins.Accumulator, gs snmpConnection, t Table, topTags map[string]string, walk bool) error { rt, err := t.Build(gs, walk) if err != nil { return err diff --git a/plugins/inputs/snmp_legacy/snmp_legacy.go b/plugins/inputs/snmp_legacy/snmp_legacy.go index e5dbbc459..2a844f2bd 100644 --- a/plugins/inputs/snmp_legacy/snmp_legacy.go +++ b/plugins/inputs/snmp_legacy/snmp_legacy.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/plugins" "github.com/influxdata/telegraf/plugins/inputs" "github.com/soniah/gosnmp" @@ -275,7 +275,7 @@ func findnodename(node Node, ids []string) (string, string) { return node.name, "" } -func (s *Snmp) Gather(acc telegraf.Accumulator) error { +func (s *Snmp) Gather(acc plugins.Accumulator) error { // TODO put this in cache on first run // Create subtables mapping if len(s.subTableMap) == 0 { @@ -410,7 +410,7 @@ func (s *Snmp) Gather(acc telegraf.Accumulator) error { } func (h *Host) SNMPMap( - acc telegraf.Accumulator, + acc plugins.Accumulator, nameToOid map[string]string, subTableMap map[string]Subtable, ) error { @@ -595,7 +595,7 @@ func (h *Host) SNMPMap( return nil } -func (h *Host) SNMPGet(acc telegraf.Accumulator, initNode Node) error { +func (h *Host) SNMPGet(acc plugins.Accumulator, initNode Node) error { // Get snmp client snmpClient, err := h.GetSNMPClient() if err != nil { @@ -636,7 +636,7 @@ func (h *Host) SNMPGet(acc telegraf.Accumulator, initNode Node) error { return nil } -func (h *Host) SNMPBulk(acc telegraf.Accumulator, initNode Node) error { +func (h *Host) SNMPBulk(acc plugins.Accumulator, initNode Node) error { // Get snmp client snmpClient, err := h.GetSNMPClient() if err != nil { @@ -726,7 +726,7 @@ func (h *Host) GetSNMPClient() (*gosnmp.GoSNMP, error) { func (h *Host) HandleResponse( oids map[string]Data, result *gosnmp.SnmpPacket, - acc telegraf.Accumulator, + acc plugins.Accumulator, initNode Node, ) (string, error) { var lastOid string @@ -812,7 +812,7 @@ func (h *Host) HandleResponse( } func init() { - inputs.Add("snmp_legacy", func() telegraf.Input { + inputs.Add("snmp_legacy", func() plugins.Input { return &Snmp{} }) } diff --git a/plugins/inputs/sqlserver/sqlserver.go b/plugins/inputs/sqlserver/sqlserver.go index e428d3098..226dedc4f 100644 --- a/plugins/inputs/sqlserver/sqlserver.go +++ b/plugins/inputs/sqlserver/sqlserver.go @@ -2,7 +2,7 @@ package sqlserver import ( "database/sql" - "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/plugins" "github.com/influxdata/telegraf/plugins/inputs" "sync" "time" @@ -71,7 +71,7 @@ func initQueries() { } // Gather collect data from SQL Server -func (s *SQLServer) Gather(acc telegraf.Accumulator) error { +func (s *SQLServer) Gather(acc plugins.Accumulator) error { initQueries() if len(s.Servers) == 0 { @@ -95,7 +95,7 @@ func (s *SQLServer) Gather(acc telegraf.Accumulator) error { return outerr } -func (s *SQLServer) gatherServer(server string, query Query, acc telegraf.Accumulator) error { +func (s *SQLServer) gatherServer(server string, query Query, acc plugins.Accumulator) error { // deferred opening conn, err := sql.Open("mssql", server) if err != nil { @@ -131,7 +131,7 @@ func (s *SQLServer) gatherServer(server string, query Query, acc telegraf.Accumu return rows.Err() } -func (s *SQLServer) accRow(query Query, acc telegraf.Accumulator, row scanner) error { +func (s *SQLServer) accRow(query Query, acc plugins.Accumulator, row scanner) error { var columnVars []interface{} var fields = make(map[string]interface{}) @@ -183,7 +183,7 @@ func (s *SQLServer) accRow(query Query, acc telegraf.Accumulator, row scanner) e } func init() { - inputs.Add("sqlserver", func() telegraf.Input { + inputs.Add("sqlserver", func() plugins.Input { return &SQLServer{} }) } diff --git a/plugins/inputs/statsd/statsd.go b/plugins/inputs/statsd/statsd.go index d2c627b8a..021d03dc3 100644 --- a/plugins/inputs/statsd/statsd.go +++ b/plugins/inputs/statsd/statsd.go @@ -13,7 +13,7 @@ import ( "github.com/influxdata/telegraf/plugins/parsers/graphite" - "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/plugins" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -177,7 +177,7 @@ func (_ *Statsd) SampleConfig() string { return sampleConfig } -func (s *Statsd) Gather(acc telegraf.Accumulator) error { +func (s *Statsd) Gather(acc plugins.Accumulator) error { s.Lock() defer s.Unlock() now := time.Now() @@ -237,7 +237,7 @@ func (s *Statsd) Gather(acc telegraf.Accumulator) error { return nil } -func (s *Statsd) Start(_ telegraf.Accumulator) error { +func (s *Statsd) Start(_ plugins.Accumulator) error { // Make data structures s.done = make(chan struct{}) s.in = make(chan []byte, s.AllowedPendingMessages) @@ -647,7 +647,7 @@ func (s *Statsd) Stop() { } func init() { - inputs.Add("statsd", func() telegraf.Input { + inputs.Add("statsd", func() plugins.Input { return &Statsd{ ServiceAddress: ":8125", MetricSeparator: "_", diff --git a/plugins/inputs/sysstat/sysstat.go b/plugins/inputs/sysstat/sysstat.go index 9c9ef6b05..d940e1ed3 100644 --- a/plugins/inputs/sysstat/sysstat.go +++ b/plugins/inputs/sysstat/sysstat.go @@ -17,7 +17,7 @@ import ( "sync" "time" - "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/plugins" "github.com/influxdata/telegraf/internal" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -136,7 +136,7 @@ func (*Sysstat) SampleConfig() string { return sampleConfig } -func (s *Sysstat) Gather(acc telegraf.Accumulator) error { +func (s *Sysstat) Gather(acc plugins.Accumulator) error { if s.interval == 0 { if firstTimestamp.IsZero() { firstTimestamp = time.Now() @@ -152,7 +152,7 @@ func (s *Sysstat) Gather(acc telegraf.Accumulator) error { errorChannel := make(chan error, len(s.Options)*2) for option := range s.Options { wg.Add(1) - go func(acc telegraf.Accumulator, option string) { + go func(acc plugins.Accumulator, option string) { defer wg.Done() if err := s.parse(acc, option, ts); err != nil { errorChannel <- err @@ -212,8 +212,8 @@ func (s *Sysstat) collect() error { // parse runs Sadf on the previously saved tmpFile: // Sadf -p -- -p