move plugin interfaces into separate package
This commit is contained in:
parent
3e6c4a53a4
commit
81caa56859
|
@ -4,7 +4,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/selfstat"
|
"github.com/influxdata/telegraf/selfstat"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,14 +18,14 @@ type MetricMaker interface {
|
||||||
measurement string,
|
measurement string,
|
||||||
fields map[string]interface{},
|
fields map[string]interface{},
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
mType telegraf.ValueType,
|
mType plugins.ValueType,
|
||||||
t time.Time,
|
t time.Time,
|
||||||
) telegraf.Metric
|
) plugins.Metric
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAccumulator(
|
func NewAccumulator(
|
||||||
maker MetricMaker,
|
maker MetricMaker,
|
||||||
metrics chan telegraf.Metric,
|
metrics chan plugins.Metric,
|
||||||
) *accumulator {
|
) *accumulator {
|
||||||
acc := accumulator{
|
acc := accumulator{
|
||||||
maker: maker,
|
maker: maker,
|
||||||
|
@ -36,7 +36,7 @@ func NewAccumulator(
|
||||||
}
|
}
|
||||||
|
|
||||||
type accumulator struct {
|
type accumulator struct {
|
||||||
metrics chan telegraf.Metric
|
metrics chan plugins.Metric
|
||||||
|
|
||||||
maker MetricMaker
|
maker MetricMaker
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ func (ac *accumulator) AddFields(
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
t ...time.Time,
|
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
|
ac.metrics <- m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ func (ac *accumulator) AddGauge(
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
t ...time.Time,
|
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
|
ac.metrics <- m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ func (ac *accumulator) AddCounter(
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
t ...time.Time,
|
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
|
ac.metrics <- m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -17,7 +17,7 @@ import (
|
||||||
|
|
||||||
func TestAdd(t *testing.T) {
|
func TestAdd(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
metrics := make(chan telegraf.Metric, 10)
|
metrics := make(chan plugins.Metric, 10)
|
||||||
defer close(metrics)
|
defer close(metrics)
|
||||||
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ func TestAdd(t *testing.T) {
|
||||||
|
|
||||||
func TestAddFields(t *testing.T) {
|
func TestAddFields(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
metrics := make(chan telegraf.Metric, 10)
|
metrics := make(chan plugins.Metric, 10)
|
||||||
defer close(metrics)
|
defer close(metrics)
|
||||||
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ func TestAccAddError(t *testing.T) {
|
||||||
log.SetOutput(errBuf)
|
log.SetOutput(errBuf)
|
||||||
defer log.SetOutput(os.Stderr)
|
defer log.SetOutput(os.Stderr)
|
||||||
|
|
||||||
metrics := make(chan telegraf.Metric, 10)
|
metrics := make(chan plugins.Metric, 10)
|
||||||
defer close(metrics)
|
defer close(metrics)
|
||||||
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ func TestAccAddError(t *testing.T) {
|
||||||
|
|
||||||
func TestAddNoIntervalWithPrecision(t *testing.T) {
|
func TestAddNoIntervalWithPrecision(t *testing.T) {
|
||||||
now := time.Date(2006, time.February, 10, 12, 0, 0, 82912748, time.UTC)
|
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)
|
defer close(metrics)
|
||||||
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
||||||
a.SetPrecision(0, time.Second)
|
a.SetPrecision(0, time.Second)
|
||||||
|
@ -132,7 +132,7 @@ func TestAddNoIntervalWithPrecision(t *testing.T) {
|
||||||
|
|
||||||
func TestAddDisablePrecision(t *testing.T) {
|
func TestAddDisablePrecision(t *testing.T) {
|
||||||
now := time.Date(2006, time.February, 10, 12, 0, 0, 82912748, time.UTC)
|
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)
|
defer close(metrics)
|
||||||
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ func TestAddDisablePrecision(t *testing.T) {
|
||||||
|
|
||||||
func TestAddNoPrecisionWithInterval(t *testing.T) {
|
func TestAddNoPrecisionWithInterval(t *testing.T) {
|
||||||
now := time.Date(2006, time.February, 10, 12, 0, 0, 82912748, time.UTC)
|
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)
|
defer close(metrics)
|
||||||
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ func TestAddNoPrecisionWithInterval(t *testing.T) {
|
||||||
|
|
||||||
func TestDifferentPrecisions(t *testing.T) {
|
func TestDifferentPrecisions(t *testing.T) {
|
||||||
now := time.Date(2006, time.February, 10, 12, 0, 0, 82912748, time.UTC)
|
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)
|
defer close(metrics)
|
||||||
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ func TestDifferentPrecisions(t *testing.T) {
|
||||||
|
|
||||||
func TestAddGauge(t *testing.T) {
|
func TestAddGauge(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
metrics := make(chan telegraf.Metric, 10)
|
metrics := make(chan plugins.Metric, 10)
|
||||||
defer close(metrics)
|
defer close(metrics)
|
||||||
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
||||||
|
|
||||||
|
@ -260,24 +260,24 @@ func TestAddGauge(t *testing.T) {
|
||||||
testm := <-metrics
|
testm := <-metrics
|
||||||
actual := testm.String()
|
actual := testm.String()
|
||||||
assert.Contains(t, actual, "acctest value=101")
|
assert.Contains(t, actual, "acctest value=101")
|
||||||
assert.Equal(t, testm.Type(), telegraf.Gauge)
|
assert.Equal(t, testm.Type(), plugins.Gauge)
|
||||||
|
|
||||||
testm = <-metrics
|
testm = <-metrics
|
||||||
actual = testm.String()
|
actual = testm.String()
|
||||||
assert.Contains(t, actual, "acctest,acc=test value=101")
|
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
|
testm = <-metrics
|
||||||
actual = testm.String()
|
actual = testm.String()
|
||||||
assert.Equal(t,
|
assert.Equal(t,
|
||||||
fmt.Sprintf("acctest,acc=test value=101 %d\n", now.UnixNano()),
|
fmt.Sprintf("acctest,acc=test value=101 %d\n", now.UnixNano()),
|
||||||
actual)
|
actual)
|
||||||
assert.Equal(t, testm.Type(), telegraf.Gauge)
|
assert.Equal(t, testm.Type(), plugins.Gauge)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAddCounter(t *testing.T) {
|
func TestAddCounter(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
metrics := make(chan telegraf.Metric, 10)
|
metrics := make(chan plugins.Metric, 10)
|
||||||
defer close(metrics)
|
defer close(metrics)
|
||||||
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
a := NewAccumulator(&TestMetricMaker{}, metrics)
|
||||||
|
|
||||||
|
@ -294,19 +294,19 @@ func TestAddCounter(t *testing.T) {
|
||||||
testm := <-metrics
|
testm := <-metrics
|
||||||
actual := testm.String()
|
actual := testm.String()
|
||||||
assert.Contains(t, actual, "acctest value=101")
|
assert.Contains(t, actual, "acctest value=101")
|
||||||
assert.Equal(t, testm.Type(), telegraf.Counter)
|
assert.Equal(t, testm.Type(), plugins.Counter)
|
||||||
|
|
||||||
testm = <-metrics
|
testm = <-metrics
|
||||||
actual = testm.String()
|
actual = testm.String()
|
||||||
assert.Contains(t, actual, "acctest,acc=test value=101")
|
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
|
testm = <-metrics
|
||||||
actual = testm.String()
|
actual = testm.String()
|
||||||
assert.Equal(t,
|
assert.Equal(t,
|
||||||
fmt.Sprintf("acctest,acc=test value=101 %d\n", now.UnixNano()),
|
fmt.Sprintf("acctest,acc=test value=101 %d\n", now.UnixNano()),
|
||||||
actual)
|
actual)
|
||||||
assert.Equal(t, testm.Type(), telegraf.Counter)
|
assert.Equal(t, testm.Type(), plugins.Counter)
|
||||||
}
|
}
|
||||||
|
|
||||||
type TestMetricMaker struct {
|
type TestMetricMaker struct {
|
||||||
|
@ -319,20 +319,20 @@ func (tm *TestMetricMaker) MakeMetric(
|
||||||
measurement string,
|
measurement string,
|
||||||
fields map[string]interface{},
|
fields map[string]interface{},
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
mType telegraf.ValueType,
|
mType plugins.ValueType,
|
||||||
t time.Time,
|
t time.Time,
|
||||||
) telegraf.Metric {
|
) plugins.Metric {
|
||||||
switch mType {
|
switch mType {
|
||||||
case telegraf.Untyped:
|
case plugins.Untyped:
|
||||||
if m, err := metric.New(measurement, tags, fields, t); err == nil {
|
if m, err := metric.New(measurement, tags, fields, t); err == nil {
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
case telegraf.Counter:
|
case plugins.Counter:
|
||||||
if m, err := metric.New(measurement, tags, fields, t, telegraf.Counter); err == nil {
|
if m, err := metric.New(measurement, tags, fields, t, plugins.Counter); err == nil {
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
case telegraf.Gauge:
|
case plugins.Gauge:
|
||||||
if m, err := metric.New(measurement, tags, fields, t, telegraf.Gauge); err == nil {
|
if m, err := metric.New(measurement, tags, fields, t, plugins.Gauge); err == nil {
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/internal/config"
|
"github.com/influxdata/telegraf/internal/config"
|
||||||
"github.com/influxdata/telegraf/internal/models"
|
"github.com/influxdata/telegraf/internal/models"
|
||||||
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/selfstat"
|
"github.com/influxdata/telegraf/selfstat"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ func NewAgent(config *config.Config) (*Agent, error) {
|
||||||
func (a *Agent) Connect() error {
|
func (a *Agent) Connect() error {
|
||||||
for _, o := range a.Config.Outputs {
|
for _, o := range a.Config.Outputs {
|
||||||
switch ot := o.Output.(type) {
|
switch ot := o.Output.(type) {
|
||||||
case telegraf.ServiceOutput:
|
case plugins.ServiceOutput:
|
||||||
if err := ot.Start(); err != nil {
|
if err := ot.Start(); err != nil {
|
||||||
log.Printf("E! Service for output %s failed to start, exiting\n%s\n",
|
log.Printf("E! Service for output %s failed to start, exiting\n%s\n",
|
||||||
o.Name, err.Error())
|
o.Name, err.Error())
|
||||||
|
@ -76,7 +76,7 @@ func (a *Agent) Close() error {
|
||||||
for _, o := range a.Config.Outputs {
|
for _, o := range a.Config.Outputs {
|
||||||
err = o.Output.Close()
|
err = o.Output.Close()
|
||||||
switch ot := o.Output.(type) {
|
switch ot := o.Output.(type) {
|
||||||
case telegraf.ServiceOutput:
|
case plugins.ServiceOutput:
|
||||||
ot.Stop()
|
ot.Stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ func (a *Agent) gatherer(
|
||||||
shutdown chan struct{},
|
shutdown chan struct{},
|
||||||
input *models.RunningInput,
|
input *models.RunningInput,
|
||||||
interval time.Duration,
|
interval time.Duration,
|
||||||
metricC chan telegraf.Metric,
|
metricC chan plugins.Metric,
|
||||||
) {
|
) {
|
||||||
defer panicRecover(input)
|
defer panicRecover(input)
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ func gatherWithTimeout(
|
||||||
func (a *Agent) Test() error {
|
func (a *Agent) Test() error {
|
||||||
shutdown := make(chan struct{})
|
shutdown := make(chan struct{})
|
||||||
defer close(shutdown)
|
defer close(shutdown)
|
||||||
metricC := make(chan telegraf.Metric)
|
metricC := make(chan plugins.Metric)
|
||||||
|
|
||||||
// dummy receiver for the point channel
|
// dummy receiver for the point channel
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -241,14 +241,14 @@ func (a *Agent) flush() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// flusher monitors the metrics input channel and flushes on the minimum interval
|
// 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
|
// Inelegant, but this sleep is to allow the Gather threads to run, so that
|
||||||
// the flusher will flush after metrics are collected.
|
// the flusher will flush after metrics are collected.
|
||||||
time.Sleep(time.Millisecond * 300)
|
time.Sleep(time.Millisecond * 300)
|
||||||
|
|
||||||
// create an output metric channel and a gorouting that continously passes
|
// create an output metric channel and a gorouting that continously passes
|
||||||
// each metric onto the output plugins & aggregators.
|
// each metric onto the output plugins & aggregators.
|
||||||
outMetricC := make(chan telegraf.Metric, 100)
|
outMetricC := make(chan plugins.Metric, 100)
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -300,7 +300,7 @@ func (a *Agent) flusher(shutdown chan struct{}, metricC chan telegraf.Metric) er
|
||||||
case metric := <-metricC:
|
case metric := <-metricC:
|
||||||
// NOTE potential bottleneck here as we put each metric through the
|
// NOTE potential bottleneck here as we put each metric through the
|
||||||
// processors serially.
|
// processors serially.
|
||||||
mS := []telegraf.Metric{metric}
|
mS := []plugins.Metric{metric}
|
||||||
for _, processor := range a.Config.Processors {
|
for _, processor := range a.Config.Processors {
|
||||||
mS = processor.Apply(mS...)
|
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)
|
a.Config.Agent.Hostname, a.Config.Agent.FlushInterval.Duration)
|
||||||
|
|
||||||
// channel shared between all input threads for accumulating metrics
|
// channel shared between all input threads for accumulating metrics
|
||||||
metricC := make(chan telegraf.Metric, 100)
|
metricC := make(chan plugins.Metric, 100)
|
||||||
|
|
||||||
// Start all ServicePlugins
|
// Start all ServicePlugins
|
||||||
for _, input := range a.Config.Inputs {
|
for _, input := range a.Config.Inputs {
|
||||||
input.SetDefaultTags(a.Config.Tags)
|
input.SetDefaultTags(a.Config.Tags)
|
||||||
switch p := input.Input.(type) {
|
switch p := input.Input.(type) {
|
||||||
case telegraf.ServiceInput:
|
case plugins.ServiceInput:
|
||||||
acc := NewAccumulator(input, metricC)
|
acc := NewAccumulator(input, metricC)
|
||||||
// Service input plugins should set their own precision of their
|
// Service input plugins should set their own precision of their
|
||||||
// metrics.
|
// metrics.
|
||||||
|
|
|
@ -13,10 +13,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
|
||||||
"github.com/influxdata/telegraf/agent"
|
"github.com/influxdata/telegraf/agent"
|
||||||
"github.com/influxdata/telegraf/internal/config"
|
"github.com/influxdata/telegraf/internal/config"
|
||||||
"github.com/influxdata/telegraf/logger"
|
"github.com/influxdata/telegraf/logger"
|
||||||
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/aggregators"
|
"github.com/influxdata/telegraf/plugins/aggregators"
|
||||||
_ "github.com/influxdata/telegraf/plugins/aggregators/all"
|
_ "github.com/influxdata/telegraf/plugins/aggregators/all"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"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)
|
name := strings.Replace(filePath, string(os.PathSeparator), ".", -1)
|
||||||
|
|
||||||
if create, err := p.Lookup("NewInput"); err == nil {
|
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 {
|
} 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 {
|
} 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 {
|
} 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 {
|
} else {
|
||||||
return fmt.Errorf("not a telegraf plugin: %s%s", filePath, ext)
|
return fmt.Errorf("not a telegraf plugin: %s%s", filePath, ext)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package buffer
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/selfstat"
|
"github.com/influxdata/telegraf/selfstat"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ var (
|
||||||
|
|
||||||
// Buffer is an object for storing metrics in a circular buffer.
|
// Buffer is an object for storing metrics in a circular buffer.
|
||||||
type Buffer struct {
|
type Buffer struct {
|
||||||
buf chan telegraf.Metric
|
buf chan plugins.Metric
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ type Buffer struct {
|
||||||
// called when the buffer is full, then the oldest metric(s) will be dropped.
|
// called when the buffer is full, then the oldest metric(s) will be dropped.
|
||||||
func NewBuffer(size int) *Buffer {
|
func NewBuffer(size int) *Buffer {
|
||||||
return &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.
|
// Add adds metrics to the buffer.
|
||||||
func (b *Buffer) Add(metrics ...telegraf.Metric) {
|
func (b *Buffer) Add(metrics ...plugins.Metric) {
|
||||||
for i, _ := range metrics {
|
for i, _ := range metrics {
|
||||||
MetricsWritten.Incr(1)
|
MetricsWritten.Incr(1)
|
||||||
select {
|
select {
|
||||||
|
@ -55,10 +55,10 @@ func (b *Buffer) Add(metrics ...telegraf.Metric) {
|
||||||
// Batch returns a batch of metrics of size batchSize.
|
// Batch returns a batch of metrics of size batchSize.
|
||||||
// the batch will be of maximum length batchSize. It can be less than batchSize,
|
// the batch will be of maximum length batchSize. It can be less than batchSize,
|
||||||
// if the length of Buffer is 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()
|
b.mu.Lock()
|
||||||
n := min(len(b.buf), batchSize)
|
n := min(len(b.buf), batchSize)
|
||||||
out := make([]telegraf.Metric, n)
|
out := make([]plugins.Metric, n)
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
out[i] = <-b.buf
|
out[i] = <-b.buf
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,13 @@ package buffer
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
var metricList = []telegraf.Metric{
|
var metricList = []plugins.Metric{
|
||||||
testutil.TestMetric(2, "mymetric1"),
|
testutil.TestMetric(2, "mymetric1"),
|
||||||
testutil.TestMetric(1, "mymetric2"),
|
testutil.TestMetric(1, "mymetric2"),
|
||||||
testutil.TestMetric(11, "mymetric3"),
|
testutil.TestMetric(11, "mymetric3"),
|
||||||
|
|
|
@ -15,9 +15,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/internal/models"
|
"github.com/influxdata/telegraf/internal/models"
|
||||||
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/aggregators"
|
"github.com/influxdata/telegraf/plugins/aggregators"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"github.com/influxdata/telegraf/plugins/outputs"
|
"github.com/influxdata/telegraf/plugins/outputs"
|
||||||
|
@ -399,7 +399,7 @@ func printFilteredInputs(inputFilters []string, commented bool) {
|
||||||
sort.Strings(pnames)
|
sort.Strings(pnames)
|
||||||
|
|
||||||
// cache service inputs to print them at the end
|
// cache service inputs to print them at the end
|
||||||
servInputs := make(map[string]telegraf.ServiceInput)
|
servInputs := make(map[string]plugins.ServiceInput)
|
||||||
// for alphabetical looping:
|
// for alphabetical looping:
|
||||||
servInputNames := []string{}
|
servInputNames := []string{}
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ func printFilteredInputs(inputFilters []string, commented bool) {
|
||||||
input := creator()
|
input := creator()
|
||||||
|
|
||||||
switch p := input.(type) {
|
switch p := input.(type) {
|
||||||
case telegraf.ServiceInput:
|
case plugins.ServiceInput:
|
||||||
servInputs[pname] = p
|
servInputs[pname] = p
|
||||||
servInputNames = append(servInputNames, pname)
|
servInputNames = append(servInputNames, pname)
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
|
"github.com/influxdata/telegraf/plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
// makemetric is used by both RunningAggregator & RunningInput
|
// makemetric is used by both RunningAggregator & RunningInput
|
||||||
|
@ -32,9 +32,9 @@ func makemetric(
|
||||||
daemonTags map[string]string,
|
daemonTags map[string]string,
|
||||||
filter Filter,
|
filter Filter,
|
||||||
applyFilter bool,
|
applyFilter bool,
|
||||||
mType telegraf.ValueType,
|
mType plugins.ValueType,
|
||||||
t time.Time,
|
t time.Time,
|
||||||
) telegraf.Metric {
|
) plugins.Metric {
|
||||||
if len(fields) == 0 || len(measurement) == 0 {
|
if len(fields) == 0 || len(measurement) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,28 +3,28 @@ package models
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
|
"github.com/influxdata/telegraf/plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RunningAggregator struct {
|
type RunningAggregator struct {
|
||||||
a telegraf.Aggregator
|
a plugins.Aggregator
|
||||||
Config *AggregatorConfig
|
Config *AggregatorConfig
|
||||||
|
|
||||||
metrics chan telegraf.Metric
|
metrics chan plugins.Metric
|
||||||
|
|
||||||
periodStart time.Time
|
periodStart time.Time
|
||||||
periodEnd time.Time
|
periodEnd time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRunningAggregator(
|
func NewRunningAggregator(
|
||||||
a telegraf.Aggregator,
|
a plugins.Aggregator,
|
||||||
conf *AggregatorConfig,
|
conf *AggregatorConfig,
|
||||||
) *RunningAggregator {
|
) *RunningAggregator {
|
||||||
return &RunningAggregator{
|
return &RunningAggregator{
|
||||||
a: a,
|
a: a,
|
||||||
Config: conf,
|
Config: conf,
|
||||||
metrics: make(chan telegraf.Metric, 100),
|
metrics: make(chan plugins.Metric, 100),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,9 +52,9 @@ func (r *RunningAggregator) MakeMetric(
|
||||||
measurement string,
|
measurement string,
|
||||||
fields map[string]interface{},
|
fields map[string]interface{},
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
mType telegraf.ValueType,
|
mType plugins.ValueType,
|
||||||
t time.Time,
|
t time.Time,
|
||||||
) telegraf.Metric {
|
) plugins.Metric {
|
||||||
m := makemetric(
|
m := makemetric(
|
||||||
measurement,
|
measurement,
|
||||||
fields,
|
fields,
|
||||||
|
@ -80,7 +80,7 @@ func (r *RunningAggregator) MakeMetric(
|
||||||
// Add applies the given metric to the aggregator.
|
// Add applies the given metric to the aggregator.
|
||||||
// Before applying to the plugin, it will run any defined filters on the metric.
|
// Before applying to the plugin, it will run any defined filters on the metric.
|
||||||
// Apply returns true if the original metric should be dropped.
|
// 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() {
|
if r.Config.Filter.IsActive() {
|
||||||
// check if the aggregator should apply this metric
|
// check if the aggregator should apply this metric
|
||||||
name := in.Name()
|
name := in.Name()
|
||||||
|
@ -98,11 +98,11 @@ func (r *RunningAggregator) Add(in telegraf.Metric) bool {
|
||||||
r.metrics <- in
|
r.metrics <- in
|
||||||
return r.Config.DropOriginal
|
return r.Config.DropOriginal
|
||||||
}
|
}
|
||||||
func (r *RunningAggregator) add(in telegraf.Metric) {
|
func (r *RunningAggregator) add(in plugins.Metric) {
|
||||||
r.a.Add(in)
|
r.a.Add(in)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RunningAggregator) push(acc telegraf.Accumulator) {
|
func (r *RunningAggregator) push(acc plugins.Accumulator) {
|
||||||
r.a.Push(acc)
|
r.a.Push(acc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ func (r *RunningAggregator) reset() {
|
||||||
// Run runs the running aggregator, listens for incoming metrics, and waits
|
// Run runs the running aggregator, listens for incoming metrics, and waits
|
||||||
// for period ticks to tell it when to push and reset the aggregator.
|
// for period ticks to tell it when to push and reset the aggregator.
|
||||||
func (r *RunningAggregator) Run(
|
func (r *RunningAggregator) Run(
|
||||||
acc telegraf.Accumulator,
|
acc plugins.Accumulator,
|
||||||
shutdown chan struct{},
|
shutdown chan struct{},
|
||||||
) {
|
) {
|
||||||
// The start of the period is truncated to the nearest second.
|
// The start of the period is truncated to the nearest second.
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -30,7 +30,7 @@ func TestAdd(t *testing.T) {
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
time.Now().Add(time.Millisecond*150),
|
time.Now().Add(time.Millisecond*150),
|
||||||
)
|
)
|
||||||
assert.False(t, ra.Add(m))
|
assert.False(t, ra.Add(m))
|
||||||
|
@ -62,7 +62,7 @@ func TestAddMetricsOutsideCurrentPeriod(t *testing.T) {
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
time.Now().Add(-time.Hour),
|
time.Now().Add(-time.Hour),
|
||||||
)
|
)
|
||||||
assert.False(t, ra.Add(m))
|
assert.False(t, ra.Add(m))
|
||||||
|
@ -72,7 +72,7 @@ func TestAddMetricsOutsideCurrentPeriod(t *testing.T) {
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
time.Now().Add(time.Hour),
|
time.Now().Add(time.Hour),
|
||||||
)
|
)
|
||||||
assert.False(t, ra.Add(m))
|
assert.False(t, ra.Add(m))
|
||||||
|
@ -82,7 +82,7 @@ func TestAddMetricsOutsideCurrentPeriod(t *testing.T) {
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
time.Now().Add(time.Millisecond*50),
|
time.Now().Add(time.Millisecond*50),
|
||||||
)
|
)
|
||||||
assert.False(t, ra.Add(m))
|
assert.False(t, ra.Add(m))
|
||||||
|
@ -120,7 +120,7 @@ func TestAddAndPushOnePeriod(t *testing.T) {
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
time.Now().Add(time.Millisecond*100),
|
time.Now().Add(time.Millisecond*100),
|
||||||
)
|
)
|
||||||
assert.False(t, ra.Add(m))
|
assert.False(t, ra.Add(m))
|
||||||
|
@ -151,7 +151,7 @@ func TestAddDropOriginal(t *testing.T) {
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
time.Now(),
|
time.Now(),
|
||||||
)
|
)
|
||||||
assert.True(t, ra.Add(m))
|
assert.True(t, ra.Add(m))
|
||||||
|
@ -161,7 +161,7 @@ func TestAddDropOriginal(t *testing.T) {
|
||||||
"foobar",
|
"foobar",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
time.Now(),
|
time.Now(),
|
||||||
)
|
)
|
||||||
assert.False(t, ra.Add(m2))
|
assert.False(t, ra.Add(m2))
|
||||||
|
@ -179,7 +179,7 @@ func TestMakeMetricA(t *testing.T) {
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
|
@ -190,14 +190,14 @@ func TestMakeMetricA(t *testing.T) {
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
m.Type(),
|
m.Type(),
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
)
|
)
|
||||||
|
|
||||||
m = ra.MakeMetric(
|
m = ra.MakeMetric(
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Counter,
|
plugins.Counter,
|
||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
|
@ -208,14 +208,14 @@ func TestMakeMetricA(t *testing.T) {
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
m.Type(),
|
m.Type(),
|
||||||
telegraf.Counter,
|
plugins.Counter,
|
||||||
)
|
)
|
||||||
|
|
||||||
m = ra.MakeMetric(
|
m = ra.MakeMetric(
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Gauge,
|
plugins.Gauge,
|
||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
|
@ -226,7 +226,7 @@ func TestMakeMetricA(t *testing.T) {
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
m.Type(),
|
m.Type(),
|
||||||
telegraf.Gauge,
|
plugins.Gauge,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,14 +240,14 @@ func (t *TestAggregator) Reset() {
|
||||||
atomic.StoreInt64(&t.sum, 0)
|
atomic.StoreInt64(&t.sum, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TestAggregator) Push(acc telegraf.Accumulator) {
|
func (t *TestAggregator) Push(acc plugins.Accumulator) {
|
||||||
acc.AddFields("TestMetric",
|
acc.AddFields("TestMetric",
|
||||||
map[string]interface{}{"sum": t.sum},
|
map[string]interface{}{"sum": t.sum},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TestAggregator) Add(in telegraf.Metric) {
|
func (t *TestAggregator) Add(in plugins.Metric) {
|
||||||
for _, v := range in.Fields() {
|
for _, v := range in.Fields() {
|
||||||
if vi, ok := v.(int64); ok {
|
if vi, ok := v.(int64); ok {
|
||||||
atomic.AddInt64(&t.sum, vi)
|
atomic.AddInt64(&t.sum, vi)
|
||||||
|
|
|
@ -4,14 +4,14 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/selfstat"
|
"github.com/influxdata/telegraf/selfstat"
|
||||||
)
|
)
|
||||||
|
|
||||||
var GlobalMetricsGathered = selfstat.Register("agent", "metrics_gathered", map[string]string{})
|
var GlobalMetricsGathered = selfstat.Register("agent", "metrics_gathered", map[string]string{})
|
||||||
|
|
||||||
type RunningInput struct {
|
type RunningInput struct {
|
||||||
Input telegraf.Input
|
Input plugins.Input
|
||||||
Config *InputConfig
|
Config *InputConfig
|
||||||
|
|
||||||
trace bool
|
trace bool
|
||||||
|
@ -21,7 +21,7 @@ type RunningInput struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRunningInput(
|
func NewRunningInput(
|
||||||
input telegraf.Input,
|
input plugins.Input,
|
||||||
config *InputConfig,
|
config *InputConfig,
|
||||||
) *RunningInput {
|
) *RunningInput {
|
||||||
return &RunningInput{
|
return &RunningInput{
|
||||||
|
@ -56,9 +56,9 @@ func (r *RunningInput) MakeMetric(
|
||||||
measurement string,
|
measurement string,
|
||||||
fields map[string]interface{},
|
fields map[string]interface{},
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
mType telegraf.ValueType,
|
mType plugins.ValueType,
|
||||||
t time.Time,
|
t time.Time,
|
||||||
) telegraf.Metric {
|
) plugins.Metric {
|
||||||
m := makemetric(
|
m := makemetric(
|
||||||
measurement,
|
measurement,
|
||||||
fields,
|
fields,
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
@ -21,7 +21,7 @@ func TestMakeMetricNoFields(t *testing.T) {
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
assert.Nil(t, m)
|
assert.Nil(t, m)
|
||||||
|
@ -41,7 +41,7 @@ func TestMakeMetricNilFields(t *testing.T) {
|
||||||
"nil": nil,
|
"nil": nil,
|
||||||
},
|
},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
|
@ -66,7 +66,7 @@ func TestMakeMetric(t *testing.T) {
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
|
@ -77,14 +77,14 @@ func TestMakeMetric(t *testing.T) {
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
m.Type(),
|
m.Type(),
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
)
|
)
|
||||||
|
|
||||||
m = ri.MakeMetric(
|
m = ri.MakeMetric(
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Counter,
|
plugins.Counter,
|
||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
|
@ -95,14 +95,14 @@ func TestMakeMetric(t *testing.T) {
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
m.Type(),
|
m.Type(),
|
||||||
telegraf.Counter,
|
plugins.Counter,
|
||||||
)
|
)
|
||||||
|
|
||||||
m = ri.MakeMetric(
|
m = ri.MakeMetric(
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Gauge,
|
plugins.Gauge,
|
||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
|
@ -113,7 +113,7 @@ func TestMakeMetric(t *testing.T) {
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
m.Type(),
|
m.Type(),
|
||||||
telegraf.Gauge,
|
plugins.Gauge,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ func TestMakeMetricWithPluginTags(t *testing.T) {
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
nil,
|
nil,
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
|
@ -161,7 +161,7 @@ func TestMakeMetricFilteredOut(t *testing.T) {
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
nil,
|
nil,
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
assert.Nil(t, m)
|
assert.Nil(t, m)
|
||||||
|
@ -183,7 +183,7 @@ func TestMakeMetricWithDaemonTags(t *testing.T) {
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
|
@ -213,7 +213,7 @@ func TestMakeMetricInfFields(t *testing.T) {
|
||||||
"ninf": ninf,
|
"ninf": ninf,
|
||||||
},
|
},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
|
@ -250,7 +250,7 @@ func TestMakeMetricAllFieldTypes(t *testing.T) {
|
||||||
"m": true,
|
"m": true,
|
||||||
},
|
},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
assert.Contains(t, m.String(), "a=10i")
|
assert.Contains(t, m.String(), "a=10i")
|
||||||
|
@ -280,7 +280,7 @@ func TestMakeMetricNameOverride(t *testing.T) {
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
|
@ -301,7 +301,7 @@ func TestMakeMetricNamePrefix(t *testing.T) {
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
|
@ -322,7 +322,7 @@ func TestMakeMetricNameSuffix(t *testing.T) {
|
||||||
"RITest",
|
"RITest",
|
||||||
map[string]interface{}{"value": int(101)},
|
map[string]interface{}{"value": int(101)},
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
telegraf.Untyped,
|
plugins.Untyped,
|
||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
|
@ -336,4 +336,4 @@ type testInput struct{}
|
||||||
|
|
||||||
func (t *testInput) Description() string { return "" }
|
func (t *testInput) Description() string { return "" }
|
||||||
func (t *testInput) SampleConfig() 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 }
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal/buffer"
|
"github.com/influxdata/telegraf/internal/buffer"
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
"github.com/influxdata/telegraf/selfstat"
|
"github.com/influxdata/telegraf/selfstat"
|
||||||
|
@ -21,7 +21,7 @@ const (
|
||||||
// RunningOutput contains the output configuration
|
// RunningOutput contains the output configuration
|
||||||
type RunningOutput struct {
|
type RunningOutput struct {
|
||||||
Name string
|
Name string
|
||||||
Output telegraf.Output
|
Output plugins.Output
|
||||||
Config *OutputConfig
|
Config *OutputConfig
|
||||||
MetricBufferLimit int
|
MetricBufferLimit int
|
||||||
MetricBatchSize int
|
MetricBatchSize int
|
||||||
|
@ -38,7 +38,7 @@ type RunningOutput struct {
|
||||||
|
|
||||||
func NewRunningOutput(
|
func NewRunningOutput(
|
||||||
name string,
|
name string,
|
||||||
output telegraf.Output,
|
output plugins.Output,
|
||||||
conf *OutputConfig,
|
conf *OutputConfig,
|
||||||
batchSize int,
|
batchSize int,
|
||||||
bufferLimit int,
|
bufferLimit int,
|
||||||
|
@ -89,7 +89,7 @@ func NewRunningOutput(
|
||||||
|
|
||||||
// AddMetric adds a metric to the output. This function can also write cached
|
// AddMetric adds a metric to the output. This function can also write cached
|
||||||
// points if FlushBufferWhenFull is true.
|
// 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
|
// Filter any tagexclude/taginclude parameters before adding metric
|
||||||
if ro.Config.Filter.IsActive() {
|
if ro.Config.Filter.IsActive() {
|
||||||
// In order to filter out tags, we need to create a new metric, since
|
// 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ro *RunningOutput) write(metrics []telegraf.Metric) error {
|
func (ro *RunningOutput) write(metrics []plugins.Metric) error {
|
||||||
nMetrics := len(metrics)
|
nMetrics := len(metrics)
|
||||||
if nMetrics == 0 {
|
if nMetrics == 0 {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -5,14 +5,14 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
var first5 = []telegraf.Metric{
|
var first5 = []plugins.Metric{
|
||||||
testutil.TestMetric(101, "metric1"),
|
testutil.TestMetric(101, "metric1"),
|
||||||
testutil.TestMetric(101, "metric2"),
|
testutil.TestMetric(101, "metric2"),
|
||||||
testutil.TestMetric(101, "metric3"),
|
testutil.TestMetric(101, "metric3"),
|
||||||
|
@ -20,7 +20,7 @@ var first5 = []telegraf.Metric{
|
||||||
testutil.TestMetric(101, "metric5"),
|
testutil.TestMetric(101, "metric5"),
|
||||||
}
|
}
|
||||||
|
|
||||||
var next5 = []telegraf.Metric{
|
var next5 = []plugins.Metric{
|
||||||
testutil.TestMetric(101, "metric6"),
|
testutil.TestMetric(101, "metric6"),
|
||||||
testutil.TestMetric(101, "metric7"),
|
testutil.TestMetric(101, "metric7"),
|
||||||
testutil.TestMetric(101, "metric8"),
|
testutil.TestMetric(101, "metric8"),
|
||||||
|
@ -465,7 +465,7 @@ func TestRunningOutputWriteFailOrder3(t *testing.T) {
|
||||||
type mockOutput struct {
|
type mockOutput struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
|
|
||||||
metrics []telegraf.Metric
|
metrics []plugins.Metric
|
||||||
|
|
||||||
// if true, mock a write failure
|
// if true, mock a write failure
|
||||||
failWrite bool
|
failWrite bool
|
||||||
|
@ -487,7 +487,7 @@ func (m *mockOutput) SampleConfig() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockOutput) Write(metrics []telegraf.Metric) error {
|
func (m *mockOutput) Write(metrics []plugins.Metric) error {
|
||||||
m.Lock()
|
m.Lock()
|
||||||
defer m.Unlock()
|
defer m.Unlock()
|
||||||
if m.failWrite {
|
if m.failWrite {
|
||||||
|
@ -495,7 +495,7 @@ func (m *mockOutput) Write(metrics []telegraf.Metric) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.metrics == nil {
|
if m.metrics == nil {
|
||||||
m.metrics = []telegraf.Metric{}
|
m.metrics = []plugins.Metric{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, metric := range metrics {
|
for _, metric := range metrics {
|
||||||
|
@ -504,7 +504,7 @@ func (m *mockOutput) Write(metrics []telegraf.Metric) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockOutput) Metrics() []telegraf.Metric {
|
func (m *mockOutput) Metrics() []plugins.Metric {
|
||||||
m.Lock()
|
m.Lock()
|
||||||
defer m.Unlock()
|
defer m.Unlock()
|
||||||
return m.metrics
|
return m.metrics
|
||||||
|
@ -531,7 +531,7 @@ func (m *perfOutput) SampleConfig() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *perfOutput) Write(metrics []telegraf.Metric) error {
|
func (m *perfOutput) Write(metrics []plugins.Metric) error {
|
||||||
if m.failWrite {
|
if m.failWrite {
|
||||||
return fmt.Errorf("Failed Write!")
|
return fmt.Errorf("Failed Write!")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RunningProcessor struct {
|
type RunningProcessor struct {
|
||||||
Name string
|
Name string
|
||||||
Processor telegraf.Processor
|
Processor plugins.Processor
|
||||||
Config *ProcessorConfig
|
Config *ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ type ProcessorConfig struct {
|
||||||
Filter Filter
|
Filter Filter
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rp *RunningProcessor) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
func (rp *RunningProcessor) Apply(in ...plugins.Metric) []plugins.Metric {
|
||||||
ret := []telegraf.Metric{}
|
ret := []plugins.Metric{}
|
||||||
|
|
||||||
for _, metric := range in {
|
for _, metric := range in {
|
||||||
if rp.Config.Filter.IsActive() {
|
if rp.Config.Filter.IsActive() {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package models
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -19,8 +19,8 @@ func (f *TestProcessor) Description() string { return "" }
|
||||||
// "foo" to "fuz"
|
// "foo" to "fuz"
|
||||||
// "bar" to "baz"
|
// "bar" to "baz"
|
||||||
// And it also drops measurements named "dropme"
|
// And it also drops measurements named "dropme"
|
||||||
func (f *TestProcessor) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
func (f *TestProcessor) Apply(in ...plugins.Metric) []plugins.Metric {
|
||||||
out := make([]telegraf.Metric, 0)
|
out := make([]plugins.Metric, 0)
|
||||||
for _, m := range in {
|
for _, m := range in {
|
||||||
switch m.Name() {
|
switch m.Name() {
|
||||||
case "foo":
|
case "foo":
|
||||||
|
@ -46,7 +46,7 @@ func NewTestRunningProcessor() *RunningProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRunningProcessor(t *testing.T) {
|
func TestRunningProcessor(t *testing.T) {
|
||||||
inmetrics := []telegraf.Metric{
|
inmetrics := []plugins.Metric{
|
||||||
testutil.TestMetric(1, "foo"),
|
testutil.TestMetric(1, "foo"),
|
||||||
testutil.TestMetric(1, "bar"),
|
testutil.TestMetric(1, "bar"),
|
||||||
testutil.TestMetric(1, "baz"),
|
testutil.TestMetric(1, "baz"),
|
||||||
|
@ -69,7 +69,7 @@ func TestRunningProcessor(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRunningProcessor_WithNameDrop(t *testing.T) {
|
func TestRunningProcessor_WithNameDrop(t *testing.T) {
|
||||||
inmetrics := []telegraf.Metric{
|
inmetrics := []plugins.Metric{
|
||||||
testutil.TestMetric(1, "foo"),
|
testutil.TestMetric(1, "foo"),
|
||||||
testutil.TestMetric(1, "bar"),
|
testutil.TestMetric(1, "bar"),
|
||||||
testutil.TestMetric(1, "baz"),
|
testutil.TestMetric(1, "baz"),
|
||||||
|
@ -96,7 +96,7 @@ func TestRunningProcessor_WithNameDrop(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRunningProcessor_DroppedMetric(t *testing.T) {
|
func TestRunningProcessor_DroppedMetric(t *testing.T) {
|
||||||
inmetrics := []telegraf.Metric{
|
inmetrics := []plugins.Metric{
|
||||||
testutil.TestMetric(1, "dropme"),
|
testutil.TestMetric(1, "dropme"),
|
||||||
testutil.TestMetric(1, "foo"),
|
testutil.TestMetric(1, "foo"),
|
||||||
testutil.TestMetric(1, "bar"),
|
testutil.TestMetric(1, "bar"),
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
|
|
||||||
// TODO remove
|
// TODO remove
|
||||||
"github.com/influxdata/influxdb/client/v2"
|
"github.com/influxdata/influxdb/client/v2"
|
||||||
|
@ -21,8 +21,8 @@ func New(
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
fields map[string]interface{},
|
fields map[string]interface{},
|
||||||
t time.Time,
|
t time.Time,
|
||||||
mType ...telegraf.ValueType,
|
mType ...plugins.ValueType,
|
||||||
) (telegraf.Metric, error) {
|
) (plugins.Metric, error) {
|
||||||
if len(fields) == 0 {
|
if len(fields) == 0 {
|
||||||
return nil, fmt.Errorf("Metric cannot be made without any fields")
|
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")
|
return nil, fmt.Errorf("Metric cannot be made with an empty name")
|
||||||
}
|
}
|
||||||
|
|
||||||
var thisType telegraf.ValueType
|
var thisType plugins.ValueType
|
||||||
if len(mType) > 0 {
|
if len(mType) > 0 {
|
||||||
thisType = mType[0]
|
thisType = mType[0]
|
||||||
} else {
|
} else {
|
||||||
thisType = telegraf.Untyped
|
thisType = plugins.Untyped
|
||||||
}
|
}
|
||||||
|
|
||||||
m := &metric{
|
m := &metric{
|
||||||
|
@ -129,7 +129,7 @@ type metric struct {
|
||||||
fields []byte
|
fields []byte
|
||||||
t []byte
|
t []byte
|
||||||
|
|
||||||
mType telegraf.ValueType
|
mType plugins.ValueType
|
||||||
aggregate bool
|
aggregate bool
|
||||||
|
|
||||||
// cached values for reuse in "get" functions
|
// cached values for reuse in "get" functions
|
||||||
|
@ -154,7 +154,7 @@ func (m *metric) IsAggregate() bool {
|
||||||
return m.aggregate
|
return m.aggregate
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *metric) Type() telegraf.ValueType {
|
func (m *metric) Type() plugins.ValueType {
|
||||||
return m.mType
|
return m.mType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,11 +178,11 @@ func (m *metric) Serialize() []byte {
|
||||||
return tmp
|
return tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *metric) Split(maxSize int) []telegraf.Metric {
|
func (m *metric) Split(maxSize int) []plugins.Metric {
|
||||||
if m.Len() < maxSize {
|
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 number of bytes for each metric (in addition to field bytes)
|
||||||
constant := len(m.name) + len(m.tags) + len(m.t) + 3
|
constant := len(m.name) + len(m.tags) + len(m.t) + 3
|
||||||
|
@ -430,11 +430,11 @@ func (m *metric) RemoveField(key string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *metric) Copy() telegraf.Metric {
|
func (m *metric) Copy() plugins.Metric {
|
||||||
return copyWith(m.name, m.tags, m.fields, m.t)
|
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{
|
out := metric{
|
||||||
name: make([]byte, len(name)),
|
name: make([]byte, len(name)),
|
||||||
tags: make([]byte, len(tags)),
|
tags: make([]byte, len(tags)),
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
// vars for making sure that the compiler doesnt optimize out the benchmarks:
|
// vars for making sure that the compiler doesnt optimize out the benchmarks:
|
||||||
|
@ -17,7 +17,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func BenchmarkNewMetric(b *testing.B) {
|
func BenchmarkNewMetric(b *testing.B) {
|
||||||
var mt telegraf.Metric
|
var mt plugins.Metric
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
mt, _ = New("test_metric",
|
mt, _ = New("test_metric",
|
||||||
map[string]string{
|
map[string]string{
|
||||||
|
@ -37,7 +37,7 @@ func BenchmarkNewMetric(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkAddTag(b *testing.B) {
|
func BenchmarkAddTag(b *testing.B) {
|
||||||
var mt telegraf.Metric
|
var mt plugins.Metric
|
||||||
mt = &metric{
|
mt = &metric{
|
||||||
name: []byte("cpu"),
|
name: []byte("cpu"),
|
||||||
tags: []byte(",host=localhost"),
|
tags: []byte(",host=localhost"),
|
||||||
|
@ -51,14 +51,14 @@ func BenchmarkAddTag(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkSplit(b *testing.B) {
|
func BenchmarkSplit(b *testing.B) {
|
||||||
var mt telegraf.Metric
|
var mt plugins.Metric
|
||||||
mt = &metric{
|
mt = &metric{
|
||||||
name: []byte("cpu"),
|
name: []byte("cpu"),
|
||||||
tags: []byte(",host=localhost"),
|
tags: []byte(",host=localhost"),
|
||||||
fields: []byte("a=101,b=10i,c=10101,d=101010,e=42"),
|
fields: []byte("a=101,b=10i,c=10101,d=101010,e=42"),
|
||||||
t: []byte("1480614053000000000"),
|
t: []byte("1480614053000000000"),
|
||||||
}
|
}
|
||||||
var metrics []telegraf.Metric
|
var metrics []plugins.Metric
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
metrics = mt.Split(60)
|
metrics = mt.Split(60)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
@ -26,7 +26,7 @@ func TestNewMetric(t *testing.T) {
|
||||||
m, err := New("cpu", tags, fields, now)
|
m, err := New("cpu", tags, fields, now)
|
||||||
assert.NoError(t, err)
|
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, tags, m.Tags())
|
||||||
assert.Equal(t, fields, m.Fields())
|
assert.Equal(t, fields, m.Fields())
|
||||||
assert.Equal(t, "cpu", m.Name())
|
assert.Equal(t, "cpu", m.Name())
|
||||||
|
@ -402,10 +402,10 @@ func TestNewGaugeMetric(t *testing.T) {
|
||||||
"usage_idle": float64(99),
|
"usage_idle": float64(99),
|
||||||
"usage_busy": float64(1),
|
"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.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, tags, m.Tags())
|
||||||
assert.Equal(t, fields, m.Fields())
|
assert.Equal(t, fields, m.Fields())
|
||||||
assert.Equal(t, "cpu", m.Name())
|
assert.Equal(t, "cpu", m.Name())
|
||||||
|
@ -424,10 +424,10 @@ func TestNewCounterMetric(t *testing.T) {
|
||||||
"usage_idle": float64(99),
|
"usage_idle": float64(99),
|
||||||
"usage_busy": float64(1),
|
"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.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, tags, m.Tags())
|
||||||
assert.Equal(t, fields, m.Fields())
|
assert.Equal(t, fields, m.Fields())
|
||||||
assert.Equal(t, "cpu", m.Name())
|
assert.Equal(t, "cpu", m.Name())
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -39,15 +39,15 @@ const (
|
||||||
fieldsState
|
fieldsState
|
||||||
)
|
)
|
||||||
|
|
||||||
func Parse(buf []byte) ([]telegraf.Metric, error) {
|
func Parse(buf []byte) ([]plugins.Metric, error) {
|
||||||
return ParseWithDefaultTime(buf, time.Now())
|
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 {
|
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
|
var errStr string
|
||||||
i := 0
|
i := 0
|
||||||
for {
|
for {
|
||||||
|
@ -77,7 +77,7 @@ func ParseWithDefaultTime(buf []byte, t time.Time) ([]telegraf.Metric, error) {
|
||||||
return metrics, nil
|
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
|
var dTime string
|
||||||
// scan the first block which is measurement[,tag1=value1,tag2=value=2...]
|
// scan the first block which is measurement[,tag1=value1,tag2=value=2...]
|
||||||
pos, key, err := scanKey(buf, 0)
|
pos, key, err := scanKey(buf, 0)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package telegraf
|
package plugins
|
||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package telegraf
|
package plugins
|
||||||
|
|
||||||
// Aggregator is an interface for implementing an Aggregator plugin.
|
// Aggregator is an interface for implementing an Aggregator plugin.
|
||||||
// the RunningAggregator wraps this interface and guarantees that
|
// the RunningAggregator wraps this interface and guarantees that
|
|
@ -1,7 +1,7 @@
|
||||||
package minmax
|
package minmax
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/aggregators"
|
"github.com/influxdata/telegraf/plugins/aggregators"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ type MinMax struct {
|
||||||
cache map[uint64]aggregate
|
cache map[uint64]aggregate
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMinMax() telegraf.Aggregator {
|
func NewMinMax() plugins.Aggregator {
|
||||||
mm := &MinMax{}
|
mm := &MinMax{}
|
||||||
mm.Reset()
|
mm.Reset()
|
||||||
return mm
|
return mm
|
||||||
|
@ -43,7 +43,7 @@ func (m *MinMax) Description() string {
|
||||||
return "Keep the aggregate min/max of each metric passing through."
|
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()
|
id := in.HashID()
|
||||||
if _, ok := m.cache[id]; !ok {
|
if _, ok := m.cache[id]; !ok {
|
||||||
// hit an uncached metric, create caches for first time:
|
// 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 {
|
for _, aggregate := range m.cache {
|
||||||
fields := map[string]interface{}{}
|
fields := map[string]interface{}{}
|
||||||
for k, v := range aggregate.fields {
|
for k, v := range aggregate.fields {
|
||||||
|
@ -113,7 +113,7 @@ func convert(in interface{}) (float64, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
aggregators.Add("minmax", func() telegraf.Aggregator {
|
aggregators.Add("minmax", func() plugins.Aggregator {
|
||||||
return NewMinMax()
|
return NewMinMax()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package aggregators
|
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{}
|
var Aggregators = map[string]Creator{}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package telegraf
|
package plugins
|
||||||
|
|
||||||
type Input interface {
|
type Input interface {
|
||||||
// SampleConfig returns the default configuration of the Input
|
// SampleConfig returns the default configuration of the Input
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal/errchan"
|
"github.com/influxdata/telegraf/internal/errchan"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ func (a *Aerospike) Description() string {
|
||||||
return "Read stats from aerospike server(s)"
|
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 {
|
if len(a.Servers) == 0 {
|
||||||
return a.gatherServer("127.0.0.1:3000", acc)
|
return a.gatherServer("127.0.0.1:3000", acc)
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ func (a *Aerospike) Gather(acc telegraf.Accumulator) error {
|
||||||
return errChan.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)
|
host, port, err := net.SplitHostPort(hostport)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -152,7 +152,7 @@ func copyTags(m map[string]string) map[string]string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("aerospike", func() telegraf.Input {
|
inputs.Add("aerospike", func() plugins.Input {
|
||||||
return &Aerospike{}
|
return &Aerospike{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
@ -57,7 +57,7 @@ func (n *Apache) Description() string {
|
||||||
return "Read Apache status information (mod_status)"
|
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 {
|
if len(n.Urls) == 0 {
|
||||||
n.Urls = []string{"http://localhost/server-status?auto"}
|
n.Urls = []string{"http://localhost/server-status?auto"}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ func (n *Apache) Gather(acc telegraf.Accumulator) error {
|
||||||
return outerr
|
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
|
var tr *http.Transport
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ func getTags(addr *url.URL) map[string]string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("apache", func() telegraf.Input {
|
inputs.Add("apache", func() plugins.Input {
|
||||||
return &Apache{}
|
return &Apache{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ func prettyToBytes(v string) uint64 {
|
||||||
return uint64(result)
|
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)
|
tags := getTags(bdev)
|
||||||
metrics, err := filepath.Glob(bdev + "/stats_total/*")
|
metrics, err := filepath.Glob(bdev + "/stats_total/*")
|
||||||
if len(metrics) < 0 {
|
if len(metrics) < 0 {
|
||||||
|
@ -105,7 +105,7 @@ func (b *Bcache) gatherBcache(bdev string, acc telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bcache) Gather(acc telegraf.Accumulator) error {
|
func (b *Bcache) Gather(acc plugins.Accumulator) error {
|
||||||
bcacheDevsChecked := make(map[string]bool)
|
bcacheDevsChecked := make(map[string]bool)
|
||||||
var restrictDevs bool
|
var restrictDevs bool
|
||||||
if len(b.BcacheDevs) != 0 {
|
if len(b.BcacheDevs) != 0 {
|
||||||
|
@ -136,7 +136,7 @@ func (b *Bcache) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("bcache", func() telegraf.Input {
|
inputs.Add("bcache", func() plugins.Input {
|
||||||
return &Bcache{}
|
return &Bcache{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
@ -35,13 +35,13 @@ type Cassandra struct {
|
||||||
type javaMetric struct {
|
type javaMetric struct {
|
||||||
host string
|
host string
|
||||||
metric string
|
metric string
|
||||||
acc telegraf.Accumulator
|
acc plugins.Accumulator
|
||||||
}
|
}
|
||||||
|
|
||||||
type cassandraMetric struct {
|
type cassandraMetric struct {
|
||||||
host string
|
host string
|
||||||
metric string
|
metric string
|
||||||
acc telegraf.Accumulator
|
acc plugins.Accumulator
|
||||||
}
|
}
|
||||||
|
|
||||||
type jmxMetric interface {
|
type jmxMetric interface {
|
||||||
|
@ -49,12 +49,12 @@ type jmxMetric interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newJavaMetric(host string, metric string,
|
func newJavaMetric(host string, metric string,
|
||||||
acc telegraf.Accumulator) *javaMetric {
|
acc plugins.Accumulator) *javaMetric {
|
||||||
return &javaMetric{host: host, metric: metric, acc: acc}
|
return &javaMetric{host: host, metric: metric, acc: acc}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCassandraMetric(host string, metric string,
|
func newCassandraMetric(host string, metric string,
|
||||||
acc telegraf.Accumulator) *cassandraMetric {
|
acc plugins.Accumulator) *cassandraMetric {
|
||||||
return &cassandraMetric{host: host, metric: metric, acc: acc}
|
return &cassandraMetric{host: host, metric: metric, acc: acc}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ func parseServerTokens(server string) map[string]string {
|
||||||
return serverTokens
|
return serverTokens
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cassandra) Gather(acc telegraf.Accumulator) error {
|
func (c *Cassandra) Gather(acc plugins.Accumulator) error {
|
||||||
context := c.Context
|
context := c.Context
|
||||||
servers := c.Servers
|
servers := c.Servers
|
||||||
metrics := c.Metrics
|
metrics := c.Metrics
|
||||||
|
@ -302,7 +302,7 @@ func (c *Cassandra) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("cassandra", func() telegraf.Input {
|
inputs.Add("cassandra", func() plugins.Input {
|
||||||
return &Cassandra{jClient: &JolokiaClientImpl{client: &http.Client{}}}
|
return &Cassandra{jClient: &JolokiaClientImpl{client: &http.Client{}}}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
@ -75,7 +75,7 @@ func (c *Ceph) SampleConfig() string {
|
||||||
return sampleConfig
|
return sampleConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Ceph) Gather(acc telegraf.Accumulator) error {
|
func (c *Ceph) Gather(acc plugins.Accumulator) error {
|
||||||
if c.GatherAdminSocketStats {
|
if c.GatherAdminSocketStats {
|
||||||
if err := c.gatherAdminSocketStats(acc); err != nil {
|
if err := c.gatherAdminSocketStats(acc); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -91,7 +91,7 @@ func (c *Ceph) Gather(acc telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Ceph) gatherAdminSocketStats(acc telegraf.Accumulator) error {
|
func (c *Ceph) gatherAdminSocketStats(acc plugins.Accumulator) error {
|
||||||
sockets, err := findSockets(c)
|
sockets, err := findSockets(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to find sockets at path '%s': %v", c.SocketDir, err)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Ceph) gatherClusterStats(acc telegraf.Accumulator) error {
|
func (c *Ceph) gatherClusterStats(acc plugins.Accumulator) error {
|
||||||
jobs := []struct {
|
jobs := []struct {
|
||||||
command string
|
command string
|
||||||
parser func(telegraf.Accumulator, string) error
|
parser func(plugins.Accumulator, string) error
|
||||||
}{
|
}{
|
||||||
{"status", decodeStatus},
|
{"status", decodeStatus},
|
||||||
{"df", decodeDf},
|
{"df", decodeDf},
|
||||||
|
@ -155,7 +155,7 @@ func init() {
|
||||||
GatherClusterStats: false,
|
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
|
return output, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeStatus(acc telegraf.Accumulator, input string) error {
|
func decodeStatus(acc plugins.Accumulator, input string) error {
|
||||||
data := make(map[string]interface{})
|
data := make(map[string]interface{})
|
||||||
err := json.Unmarshal([]byte(input), &data)
|
err := json.Unmarshal([]byte(input), &data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -347,7 +347,7 @@ func decodeStatus(acc telegraf.Accumulator, input string) error {
|
||||||
return nil
|
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{})
|
osdmap, ok := data["osdmap"].(map[string]interface{})
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("WARNING %s - unable to decode osdmap", measurement)
|
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
|
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{})
|
pgmap, ok := data["pgmap"].(map[string]interface{})
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("WARNING %s - unable to decode pgmap", measurement)
|
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
|
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{})
|
pgmap, ok := data["pgmap"].(map[string]interface{})
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("WARNING %s - unable to decode pgmap", measurement)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeDf(acc telegraf.Accumulator, input string) error {
|
func decodeDf(acc plugins.Accumulator, input string) error {
|
||||||
data := make(map[string]interface{})
|
data := make(map[string]interface{})
|
||||||
err := json.Unmarshal([]byte(input), &data)
|
err := json.Unmarshal([]byte(input), &data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -451,7 +451,7 @@ func decodeDf(acc telegraf.Accumulator, input string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeOsdPoolStats(acc telegraf.Accumulator, input string) error {
|
func decodeOsdPoolStats(acc plugins.Accumulator, input string) error {
|
||||||
data := make([]map[string]interface{}, 0)
|
data := make([]map[string]interface{}, 0)
|
||||||
err := json.Unmarshal([]byte(input), &data)
|
err := json.Unmarshal([]byte(input), &data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package cgroup
|
package cgroup
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -34,5 +34,5 @@ func (g *CGroup) Description() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("cgroup", func() telegraf.Input { return &CGroup{} })
|
inputs.Add("cgroup", func() plugins.Input { return &CGroup{} })
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,12 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
const metricName = "cgroup"
|
const metricName = "cgroup"
|
||||||
|
|
||||||
func (g *CGroup) Gather(acc telegraf.Accumulator) error {
|
func (g *CGroup) Gather(acc plugins.Accumulator) error {
|
||||||
list := make(chan pathInfo)
|
list := make(chan pathInfo)
|
||||||
go g.generateDirs(list)
|
go g.generateDirs(list)
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ func (g *CGroup) Gather(acc telegraf.Accumulator) error {
|
||||||
return nil
|
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{})
|
fields := make(map[string]interface{})
|
||||||
|
|
||||||
list := make(chan pathInfo)
|
list := make(chan pathInfo)
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
package cgroup
|
package cgroup
|
||||||
|
|
||||||
import (
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"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 {
|
if len(c.path) == 0 {
|
||||||
return errors.New("chronyc not found: verify that chrony is installed and that chronyc is in your PATH")
|
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 {
|
if len(path) > 0 {
|
||||||
c.path = path
|
c.path = path
|
||||||
}
|
}
|
||||||
inputs.Add("chrony", func() telegraf.Input {
|
inputs.Add("chrony", func() plugins.Input {
|
||||||
return &c
|
return &c
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/service/cloudwatch"
|
"github.com/aws/aws-sdk-go/service/cloudwatch"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
internalaws "github.com/influxdata/telegraf/internal/config/aws"
|
internalaws "github.com/influxdata/telegraf/internal/config/aws"
|
||||||
"github.com/influxdata/telegraf/internal/errchan"
|
"github.com/influxdata/telegraf/internal/errchan"
|
||||||
|
@ -176,7 +176,7 @@ func SelectMetrics(c *CloudWatch) ([]*cloudwatch.Metric, error) {
|
||||||
return metrics, nil
|
return metrics, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CloudWatch) Gather(acc telegraf.Accumulator) error {
|
func (c *CloudWatch) Gather(acc plugins.Accumulator) error {
|
||||||
if c.client == nil {
|
if c.client == nil {
|
||||||
c.initializeCloudWatch()
|
c.initializeCloudWatch()
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ func (c *CloudWatch) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("cloudwatch", func() telegraf.Input {
|
inputs.Add("cloudwatch", func() plugins.Input {
|
||||||
ttl, _ := time.ParseDuration("1hr")
|
ttl, _ := time.ParseDuration("1hr")
|
||||||
return &CloudWatch{
|
return &CloudWatch{
|
||||||
CacheTTL: internal.Duration{Duration: ttl},
|
CacheTTL: internal.Duration{Duration: ttl},
|
||||||
|
@ -281,7 +281,7 @@ func (c *CloudWatch) fetchNamespaceMetrics() ([]*cloudwatch.Metric, error) {
|
||||||
* Gather given Metric and emit any error
|
* Gather given Metric and emit any error
|
||||||
*/
|
*/
|
||||||
func (c *CloudWatch) gatherMetric(
|
func (c *CloudWatch) gatherMetric(
|
||||||
acc telegraf.Accumulator,
|
acc plugins.Accumulator,
|
||||||
metric *cloudwatch.Metric,
|
metric *cloudwatch.Metric,
|
||||||
now time.Time,
|
now time.Time,
|
||||||
errChan chan error,
|
errChan chan error,
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"log"
|
"log"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -70,7 +70,7 @@ func (c *Conntrack) SampleConfig() string {
|
||||||
return sampleConfig
|
return sampleConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conntrack) Gather(acc telegraf.Accumulator) error {
|
func (c *Conntrack) Gather(acc plugins.Accumulator) error {
|
||||||
c.setDefaults()
|
c.setDefaults()
|
||||||
|
|
||||||
var metricKey string
|
var metricKey string
|
||||||
|
@ -116,5 +116,5 @@ func (c *Conntrack) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add(inputName, func() telegraf.Input { return &Conntrack{} })
|
inputs.Add(inputName, func() plugins.Input { return &Conntrack{} })
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/hashicorp/consul/api"
|
"github.com/hashicorp/consul/api"
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
@ -90,7 +90,7 @@ func (c *Consul) createAPIClient() (*api.Client, error) {
|
||||||
return api.NewClient(config)
|
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 {
|
for _, check := range checks {
|
||||||
record := make(map[string]interface{})
|
record := make(map[string]interface{})
|
||||||
tags := make(map[string]string)
|
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 {
|
if c.client == nil {
|
||||||
newClient, err := c.createAPIClient()
|
newClient, err := c.createAPIClient()
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ func (c *Consul) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("consul", func() telegraf.Input {
|
inputs.Add("consul", func() plugins.Input {
|
||||||
return &Consul{}
|
return &Consul{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package couchbase
|
||||||
|
|
||||||
import (
|
import (
|
||||||
couchbase "github.com/couchbase/go-couchbase"
|
couchbase "github.com/couchbase/go-couchbase"
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
@ -34,7 +34,7 @@ func (r *Couchbase) Description() string {
|
||||||
|
|
||||||
// Reads stats from all configured clusters. Accumulates stats.
|
// Reads stats from all configured clusters. Accumulates stats.
|
||||||
// Returns one of the errors encountered while gathering stats (if any).
|
// 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 {
|
if len(r.Servers) == 0 {
|
||||||
r.gatherServer("http://localhost:8091/", acc, nil)
|
r.gatherServer("http://localhost:8091/", acc, nil)
|
||||||
return nil
|
return nil
|
||||||
|
@ -57,7 +57,7 @@ func (r *Couchbase) Gather(acc telegraf.Accumulator) error {
|
||||||
return outerr
|
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 {
|
if pool == nil {
|
||||||
client, err := couchbase.Connect(addr)
|
client, err := couchbase.Connect(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -98,7 +98,7 @@ func (r *Couchbase) gatherServer(addr string, acc telegraf.Accumulator, pool *co
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("couchbase", func() telegraf.Input {
|
inputs.Add("couchbase", func() plugins.Input {
|
||||||
return &Couchbase{}
|
return &Couchbase{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
"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))
|
errorChannel := make(chan error, len(c.HOSTs))
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for _, u := range c.HOSTs {
|
for _, u := range c.HOSTs {
|
||||||
|
@ -122,7 +122,7 @@ var client = &http.Client{
|
||||||
Timeout: time.Duration(4 * time.Second),
|
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)
|
response, error := client.Get(host)
|
||||||
if error != nil {
|
if error != nil {
|
||||||
|
@ -209,7 +209,7 @@ func (c *CouchDB) generateFields(prefix string, obj metaData) map[string]interfa
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("couchdb", func() telegraf.Input {
|
inputs.Add("couchdb", func() plugins.Input {
|
||||||
return &CouchDB{}
|
return &CouchDB{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"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.
|
// Reads stats from all configured servers accumulates stats.
|
||||||
// Returns one of the errors encountered while gather stats (if any).
|
// 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 {
|
if len(g.Servers) == 0 {
|
||||||
url := &url.URL{
|
url := &url.URL{
|
||||||
Host: ":7711",
|
Host: ":7711",
|
||||||
|
@ -101,7 +101,7 @@ func (g *Disque) Gather(acc telegraf.Accumulator) error {
|
||||||
|
|
||||||
const defaultPort = "7711"
|
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 {
|
if g.c == nil {
|
||||||
|
|
||||||
_, _, err := net.SplitHostPort(addr.Host)
|
_, _, err := net.SplitHostPort(addr.Host)
|
||||||
|
@ -204,7 +204,7 @@ func (g *Disque) gatherServer(addr *url.URL, acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("disque", func() telegraf.Input {
|
inputs.Add("disque", func() plugins.Input {
|
||||||
return &Disque{}
|
return &Disque{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal/errchan"
|
"github.com/influxdata/telegraf/internal/errchan"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
@ -55,7 +55,7 @@ func (d *DnsQuery) SampleConfig() string {
|
||||||
func (d *DnsQuery) Description() string {
|
func (d *DnsQuery) Description() string {
|
||||||
return "Query given DNS server and gives statistics"
|
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()
|
d.setDefaultValues()
|
||||||
|
|
||||||
errChan := errchan.New(len(d.Domains) * len(d.Servers))
|
errChan := errchan.New(len(d.Domains) * len(d.Servers))
|
||||||
|
@ -156,7 +156,7 @@ func (d *DnsQuery) parseRecordType() (uint16, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("dns_query", func() telegraf.Input {
|
inputs.Add("dns_query", func() plugins.Input {
|
||||||
return &DnsQuery{}
|
return &DnsQuery{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/engine-api/client"
|
"github.com/docker/engine-api/client"
|
||||||
"github.com/docker/engine-api/types"
|
"github.com/docker/engine-api/types"
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
@ -79,7 +79,7 @@ func (d *Docker) Description() string {
|
||||||
func (d *Docker) SampleConfig() string { return sampleConfig }
|
func (d *Docker) SampleConfig() string { return sampleConfig }
|
||||||
|
|
||||||
// Gather starts stats collection
|
// Gather starts stats collection
|
||||||
func (d *Docker) Gather(acc telegraf.Accumulator) error {
|
func (d *Docker) Gather(acc plugins.Accumulator) error {
|
||||||
if d.client == nil {
|
if d.client == nil {
|
||||||
var c *client.Client
|
var c *client.Client
|
||||||
var err error
|
var err error
|
||||||
|
@ -136,7 +136,7 @@ func (d *Docker) Gather(acc telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Docker) gatherInfo(acc telegraf.Accumulator) error {
|
func (d *Docker) gatherInfo(acc plugins.Accumulator) error {
|
||||||
// Init vars
|
// Init vars
|
||||||
dataFields := make(map[string]interface{})
|
dataFields := make(map[string]interface{})
|
||||||
metadataFields := 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(
|
func (d *Docker) gatherContainer(
|
||||||
container types.Container,
|
container types.Container,
|
||||||
acc telegraf.Accumulator,
|
acc plugins.Accumulator,
|
||||||
) error {
|
) error {
|
||||||
var v *types.StatsJSON
|
var v *types.StatsJSON
|
||||||
// Parse container name
|
// Parse container name
|
||||||
|
@ -272,7 +272,7 @@ func (d *Docker) gatherContainer(
|
||||||
|
|
||||||
func gatherContainerStats(
|
func gatherContainerStats(
|
||||||
stat *types.StatsJSON,
|
stat *types.StatsJSON,
|
||||||
acc telegraf.Accumulator,
|
acc plugins.Accumulator,
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
id string,
|
id string,
|
||||||
perDevice bool,
|
perDevice bool,
|
||||||
|
@ -422,7 +422,7 @@ func calculateCPUPercent(stat *types.StatsJSON) float64 {
|
||||||
|
|
||||||
func gatherBlockIOMetrics(
|
func gatherBlockIOMetrics(
|
||||||
stat *types.StatsJSON,
|
stat *types.StatsJSON,
|
||||||
acc telegraf.Accumulator,
|
acc plugins.Accumulator,
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
now time.Time,
|
now time.Time,
|
||||||
id string,
|
id string,
|
||||||
|
@ -569,7 +569,7 @@ func parseSize(sizeStr string) (int64, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("docker", func() telegraf.Input {
|
inputs.Add("docker", func() plugins.Input {
|
||||||
return &Docker{
|
return &Docker{
|
||||||
PerDevice: true,
|
PerDevice: true,
|
||||||
Timeout: internal.Duration{Duration: time.Second * 5},
|
Timeout: internal.Duration{Duration: time.Second * 5},
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal/errchan"
|
"github.com/influxdata/telegraf/internal/errchan"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
@ -51,7 +51,7 @@ func (d *Dovecot) SampleConfig() string { return sampleConfig }
|
||||||
const defaultPort = "24242"
|
const defaultPort = "24242"
|
||||||
|
|
||||||
// Reads stats from all configured servers.
|
// 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] {
|
if !validQuery[d.Type] {
|
||||||
return fmt.Errorf("Error: %s is not a valid query type\n",
|
return fmt.Errorf("Error: %s is not a valid query type\n",
|
||||||
d.Type)
|
d.Type)
|
||||||
|
@ -81,7 +81,7 @@ func (d *Dovecot) Gather(acc telegraf.Accumulator) error {
|
||||||
return errChan.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)
|
_, _, err := net.SplitHostPort(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error: %s on url %s\n", err, addr)
|
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)
|
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")
|
lines := strings.Split(buf.String(), "\n")
|
||||||
head := strings.Split(lines[0], "\t")
|
head := strings.Split(lines[0], "\t")
|
||||||
|
@ -183,7 +183,7 @@ func secParser(tm string) float64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("dovecot", func() telegraf.Input {
|
inputs.Add("dovecot", func() plugins.Input {
|
||||||
return &Dovecot{}
|
return &Dovecot{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/internal/errchan"
|
"github.com/influxdata/telegraf/internal/errchan"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"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
|
// Gather reads the stats from Elasticsearch and writes it to the
|
||||||
// Accumulator.
|
// Accumulator.
|
||||||
func (e *Elasticsearch) Gather(acc telegraf.Accumulator) error {
|
func (e *Elasticsearch) Gather(acc plugins.Accumulator) error {
|
||||||
if e.client == nil {
|
if e.client == nil {
|
||||||
client, err := e.createHttpClient()
|
client, err := e.createHttpClient()
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ func (e *Elasticsearch) Gather(acc telegraf.Accumulator) error {
|
||||||
wg.Add(len(e.Servers))
|
wg.Add(len(e.Servers))
|
||||||
|
|
||||||
for _, serv := range e.Servers {
|
for _, serv := range e.Servers {
|
||||||
go func(s string, acc telegraf.Accumulator) {
|
go func(s string, acc plugins.Accumulator) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
var url string
|
var url string
|
||||||
if e.Local {
|
if e.Local {
|
||||||
|
@ -221,7 +221,7 @@ func (e *Elasticsearch) createHttpClient() (*http.Client, error) {
|
||||||
return client, nil
|
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 {
|
nodeStats := &struct {
|
||||||
ClusterName string `json:"cluster_name"`
|
ClusterName string `json:"cluster_name"`
|
||||||
Nodes map[string]*nodeStat `json:"nodes"`
|
Nodes map[string]*nodeStat `json:"nodes"`
|
||||||
|
@ -273,7 +273,7 @@ func (e *Elasticsearch) gatherNodeStats(url string, acc telegraf.Accumulator) er
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Elasticsearch) gatherClusterHealth(url string, acc telegraf.Accumulator) error {
|
func (e *Elasticsearch) gatherClusterHealth(url string, acc plugins.Accumulator) error {
|
||||||
healthStats := &clusterHealth{}
|
healthStats := &clusterHealth{}
|
||||||
if err := e.gatherJsonData(url, healthStats); err != nil {
|
if err := e.gatherJsonData(url, healthStats); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -318,7 +318,7 @@ func (e *Elasticsearch) gatherClusterHealth(url string, acc telegraf.Accumulator
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Elasticsearch) gatherClusterStats(url string, acc telegraf.Accumulator) error {
|
func (e *Elasticsearch) gatherClusterStats(url string, acc plugins.Accumulator) error {
|
||||||
clusterStats := &clusterStats{}
|
clusterStats := &clusterStats{}
|
||||||
if err := e.gatherJsonData(url, clusterStats); err != nil {
|
if err := e.gatherJsonData(url, clusterStats); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -393,7 +393,7 @@ func (e *Elasticsearch) gatherJsonData(url string, v interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("elasticsearch", func() telegraf.Input {
|
inputs.Add("elasticsearch", func() plugins.Input {
|
||||||
return NewElasticsearch()
|
return NewElasticsearch()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
|
|
||||||
"github.com/kballard/go-shellquote"
|
"github.com/kballard/go-shellquote"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/internal/errchan"
|
"github.com/influxdata/telegraf/internal/errchan"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
|
@ -61,12 +61,12 @@ func NewExec() *Exec {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Runner interface {
|
type Runner interface {
|
||||||
Run(*Exec, string, telegraf.Accumulator) ([]byte, error)
|
Run(*Exec, string, plugins.Accumulator) ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommandRunner struct{}
|
type CommandRunner struct{}
|
||||||
|
|
||||||
func AddNagiosState(exitCode error, acc telegraf.Accumulator) error {
|
func AddNagiosState(exitCode error, acc plugins.Accumulator) error {
|
||||||
nagiosState := 0
|
nagiosState := 0
|
||||||
if exitCode != nil {
|
if exitCode != nil {
|
||||||
exiterr, ok := exitCode.(*exec.ExitError)
|
exiterr, ok := exitCode.(*exec.ExitError)
|
||||||
|
@ -89,7 +89,7 @@ func AddNagiosState(exitCode error, acc telegraf.Accumulator) error {
|
||||||
func (c CommandRunner) Run(
|
func (c CommandRunner) Run(
|
||||||
e *Exec,
|
e *Exec,
|
||||||
command string,
|
command string,
|
||||||
acc telegraf.Accumulator,
|
acc plugins.Accumulator,
|
||||||
) ([]byte, error) {
|
) ([]byte, error) {
|
||||||
split_cmd, err := shellquote.Split(command)
|
split_cmd, err := shellquote.Split(command)
|
||||||
if err != nil || len(split_cmd) == 0 {
|
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()
|
defer wg.Done()
|
||||||
|
|
||||||
out, err := e.runner.Run(e, command, acc)
|
out, err := e.runner.Run(e, command, acc)
|
||||||
|
@ -176,7 +176,7 @@ func (e *Exec) SetParser(parser parsers.Parser) {
|
||||||
e.parser = parser
|
e.parser = parser
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Exec) Gather(acc telegraf.Accumulator) error {
|
func (e *Exec) Gather(acc plugins.Accumulator) error {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
// Legacy single command support
|
// Legacy single command support
|
||||||
if e.Command != "" {
|
if e.Command != "" {
|
||||||
|
@ -226,7 +226,7 @@ func (e *Exec) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("exec", func() telegraf.Input {
|
inputs.Add("exec", func() plugins.Input {
|
||||||
return NewExec()
|
return NewExec()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers"
|
"github.com/influxdata/telegraf/plugins/parsers"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"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 {
|
if r.err != nil {
|
||||||
return nil, r.err
|
return nil, r.err
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal/globpath"
|
"github.com/influxdata/telegraf/internal/globpath"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
@ -47,7 +47,7 @@ func (_ *FileStat) Description() string {
|
||||||
|
|
||||||
func (_ *FileStat) SampleConfig() string { return sampleConfig }
|
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 errS string
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ func getMd5(file string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("filestat", func() telegraf.Input {
|
inputs.Add("filestat", func() plugins.Input {
|
||||||
return NewFileStat()
|
return NewFileStat()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
@ -129,7 +129,7 @@ func (h *GrayLog) Description() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gathers data for all servers.
|
// 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
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
if h.client.HTTPClient() == nil {
|
if h.client.HTTPClient() == nil {
|
||||||
|
@ -178,14 +178,14 @@ func (h *GrayLog) Gather(acc telegraf.Accumulator) error {
|
||||||
|
|
||||||
// Gathers data from a particular server
|
// Gathers data from a particular server
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// acc : The telegraf Accumulator to use
|
// acc : The plugins.Accumulator to use
|
||||||
// serverURL: endpoint to send request to
|
// serverURL: endpoint to send request to
|
||||||
// service : the service being queried
|
// service : the service being queried
|
||||||
//
|
//
|
||||||
// Returns:
|
// Returns:
|
||||||
// error: Any error that may have occurred
|
// error: Any error that may have occurred
|
||||||
func (h *GrayLog) gatherServer(
|
func (h *GrayLog) gatherServer(
|
||||||
acc telegraf.Accumulator,
|
acc plugins.Accumulator,
|
||||||
serverURL string,
|
serverURL string,
|
||||||
) error {
|
) error {
|
||||||
resp, _, err := h.sendRequest(serverURL)
|
resp, _, err := h.sendRequest(serverURL)
|
||||||
|
@ -304,7 +304,7 @@ func (h *GrayLog) sendRequest(serverURL string) (string, float64, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("graylog", func() telegraf.Input {
|
inputs.Add("graylog", func() plugins.Input {
|
||||||
return &GrayLog{
|
return &GrayLog{
|
||||||
client: &RealHTTPClient{},
|
client: &RealHTTPClient{},
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal/errchan"
|
"github.com/influxdata/telegraf/internal/errchan"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
@ -115,7 +115,7 @@ func (r *haproxy) Description() string {
|
||||||
|
|
||||||
// Reads stats from all configured servers accumulates stats.
|
// Reads stats from all configured servers accumulates stats.
|
||||||
// Returns one of the errors encountered while gather stats (if any).
|
// 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 {
|
if len(g.Servers) == 0 {
|
||||||
return g.gatherServer("http://127.0.0.1:1936/haproxy?stats", acc)
|
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()
|
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)
|
socketPath := getSocketAddr(addr)
|
||||||
|
|
||||||
c, err := net.Dial("unix", socketPath)
|
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)
|
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") {
|
if !strings.HasPrefix(addr, "http") {
|
||||||
return g.gatherServerSocket(addr, acc)
|
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)
|
csv := csv.NewReader(r)
|
||||||
result, err := csv.ReadAll()
|
result, err := csv.ReadAll()
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
@ -436,7 +436,7 @@ func importCsvResult(r io.Reader, acc telegraf.Accumulator, host string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("haproxy", func() telegraf.Input {
|
inputs.Add("haproxy", func() plugins.Input {
|
||||||
return &haproxy{}
|
return &haproxy{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
package hddtemp
|
package hddtemp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
gohddtemp "github.com/influxdata/telegraf/plugins/inputs/hddtemp/go-hddtemp"
|
gohddtemp "github.com/influxdata/telegraf/plugins/inputs/hddtemp/go-hddtemp"
|
||||||
)
|
)
|
||||||
|
@ -40,7 +40,7 @@ func (_ *HDDTemp) SampleConfig() string {
|
||||||
return hddtempSampleConfig
|
return hddtempSampleConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HDDTemp) Gather(acc telegraf.Accumulator) error {
|
func (h *HDDTemp) Gather(acc plugins.Accumulator) error {
|
||||||
if h.fetcher == nil {
|
if h.fetcher == nil {
|
||||||
h.fetcher = gohddtemp.New()
|
h.fetcher = gohddtemp.New()
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ func (h *HDDTemp) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("hddtemp", func() telegraf.Input {
|
inputs.Add("hddtemp", func() plugins.Input {
|
||||||
return &HDDTemp{
|
return &HDDTemp{
|
||||||
Address: defaultAddress,
|
Address: defaultAddress,
|
||||||
Devices: []string{"*"},
|
Devices: []string{"*"},
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
||||||
|
@ -42,7 +42,7 @@ type HTTPListener struct {
|
||||||
listener net.Listener
|
listener net.Listener
|
||||||
|
|
||||||
parser influx.InfluxParser
|
parser influx.InfluxParser
|
||||||
acc telegraf.Accumulator
|
acc plugins.Accumulator
|
||||||
pool *pool
|
pool *pool
|
||||||
|
|
||||||
BytesRecv selfstat.Stat
|
BytesRecv selfstat.Stat
|
||||||
|
@ -84,13 +84,13 @@ func (h *HTTPListener) Description() string {
|
||||||
return "Influx HTTP write listener"
|
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())
|
h.BuffersCreated.Set(h.pool.ncreated())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start starts the http listener service.
|
// 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()
|
h.mu.Lock()
|
||||||
defer h.mu.Unlock()
|
defer h.mu.Unlock()
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ func badRequest(res http.ResponseWriter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("http_listener", func() telegraf.Input {
|
inputs.Add("http_listener", func() plugins.Input {
|
||||||
return &HTTPListener{
|
return &HTTPListener{
|
||||||
ServiceAddress: ":8186",
|
ServiceAddress: ":8186",
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"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
|
// 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
|
// Set default values
|
||||||
if h.ResponseTimeout.Duration < time.Second {
|
if h.ResponseTimeout.Duration < time.Second {
|
||||||
h.ResponseTimeout.Duration = time.Second * 5
|
h.ResponseTimeout.Duration = time.Second * 5
|
||||||
|
@ -174,7 +174,7 @@ func (h *HTTPResponse) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("http_response", func() telegraf.Input {
|
inputs.Add("http_response", func() plugins.Input {
|
||||||
return &HTTPResponse{}
|
return &HTTPResponse{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers"
|
"github.com/influxdata/telegraf/plugins/parsers"
|
||||||
|
@ -120,7 +120,7 @@ func (h *HttpJson) Description() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gathers data for all servers.
|
// 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
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
if h.client.HTTPClient() == nil {
|
if h.client.HTTPClient() == nil {
|
||||||
|
@ -169,14 +169,14 @@ func (h *HttpJson) Gather(acc telegraf.Accumulator) error {
|
||||||
|
|
||||||
// Gathers data from a particular server
|
// Gathers data from a particular server
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// acc : The telegraf Accumulator to use
|
// acc : The plugins.Accumulator to use
|
||||||
// serverURL: endpoint to send request to
|
// serverURL: endpoint to send request to
|
||||||
// service : the service being queried
|
// service : the service being queried
|
||||||
//
|
//
|
||||||
// Returns:
|
// Returns:
|
||||||
// error: Any error that may have occurred
|
// error: Any error that may have occurred
|
||||||
func (h *HttpJson) gatherServer(
|
func (h *HttpJson) gatherServer(
|
||||||
acc telegraf.Accumulator,
|
acc plugins.Accumulator,
|
||||||
serverURL string,
|
serverURL string,
|
||||||
) error {
|
) error {
|
||||||
resp, responseTime, err := h.sendRequest(serverURL)
|
resp, responseTime, err := h.sendRequest(serverURL)
|
||||||
|
@ -292,7 +292,7 @@ func (h *HttpJson) sendRequest(serverURL string) (string, float64, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("httpjson", func() telegraf.Input {
|
inputs.Add("httpjson", func() plugins.Input {
|
||||||
return &HttpJson{
|
return &HttpJson{
|
||||||
client: &RealHTTPClient{},
|
client: &RealHTTPClient{},
|
||||||
ResponseTimeout: internal.Duration{
|
ResponseTimeout: internal.Duration{
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"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 {
|
if len(i.URLs) == 0 {
|
||||||
i.URLs = []string{"http://localhost:8086/debug/vars"}
|
i.URLs = []string{"http://localhost:8086/debug/vars"}
|
||||||
}
|
}
|
||||||
|
@ -125,13 +125,13 @@ type memstats struct {
|
||||||
|
|
||||||
// Gathers data from a particular URL
|
// Gathers data from a particular URL
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// acc : The telegraf Accumulator to use
|
// acc : The plugins.Accumulator to use
|
||||||
// url : endpoint to send request to
|
// url : endpoint to send request to
|
||||||
//
|
//
|
||||||
// Returns:
|
// Returns:
|
||||||
// error: Any error that may have occurred
|
// error: Any error that may have occurred
|
||||||
func (i *InfluxDB) gatherURL(
|
func (i *InfluxDB) gatherURL(
|
||||||
acc telegraf.Accumulator,
|
acc plugins.Accumulator,
|
||||||
url string,
|
url string,
|
||||||
) error {
|
) error {
|
||||||
shardCounter := 0
|
shardCounter := 0
|
||||||
|
@ -258,7 +258,7 @@ func (i *InfluxDB) gatherURL(
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("influxdb", func() telegraf.Input {
|
inputs.Add("influxdb", func() plugins.Input {
|
||||||
return &InfluxDB{
|
return &InfluxDB{
|
||||||
Timeout: internal.Duration{Duration: time.Second * 5},
|
Timeout: internal.Duration{Duration: time.Second * 5},
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package internal
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"github.com/influxdata/telegraf/selfstat"
|
"github.com/influxdata/telegraf/selfstat"
|
||||||
)
|
)
|
||||||
|
@ -12,7 +12,7 @@ type Self struct {
|
||||||
CollectMemstats bool
|
CollectMemstats bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSelf() telegraf.Input {
|
func NewSelf() plugins.Input {
|
||||||
return &Self{
|
return &Self{
|
||||||
CollectMemstats: true,
|
CollectMemstats: true,
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ func (s *Self) SampleConfig() string {
|
||||||
return sampleConfig
|
return sampleConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Self) Gather(acc telegraf.Accumulator) error {
|
func (s *Self) Gather(acc plugins.Accumulator) error {
|
||||||
if s.CollectMemstats {
|
if s.CollectMemstats {
|
||||||
m := &runtime.MemStats{}
|
m := &runtime.MemStats{}
|
||||||
runtime.ReadMemStats(m)
|
runtime.ReadMemStats(m)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"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"
|
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 {
|
if m.runner == nil {
|
||||||
m.runner = CommandRunner{}
|
m.runner = CommandRunner{}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ func (m *Ipmi) Gather(acc telegraf.Accumulator) error {
|
||||||
return nil
|
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)
|
conn := NewConnection(serv)
|
||||||
|
|
||||||
res, err := m.runner.Run(conn, "sdr")
|
res, err := m.runner.Run(conn, "sdr")
|
||||||
|
@ -123,7 +123,7 @@ func transform(s string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("ipmi_sensor", func() telegraf.Input {
|
inputs.Add("ipmi_sensor", func() plugins.Input {
|
||||||
return &Ipmi{}
|
return &Ipmi{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"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.
|
// 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 {
|
if ipt.Table == "" || len(ipt.Chains) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ var chainNameRe = regexp.MustCompile(`^Chain\s+(\S+)`)
|
||||||
var fieldsHeaderRe = regexp.MustCompile(`^\s*pkts\s+bytes\s+`)
|
var fieldsHeaderRe = regexp.MustCompile(`^\s*pkts\s+bytes\s+`)
|
||||||
var valuesRe = regexp.MustCompile(`^\s*([0-9]+)\s+([0-9]+)\s+.*?(/\*\s(.*)\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")
|
lines := strings.Split(data, "\n")
|
||||||
if len(lines) < 3 {
|
if len(lines) < 3 {
|
||||||
return nil
|
return nil
|
||||||
|
@ -120,7 +120,7 @@ func (ipt *Iptables) parseAndGather(data string, acc telegraf.Accumulator) error
|
||||||
type chainLister func(table, chain string) (string, error)
|
type chainLister func(table, chain string) (string, error)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("iptables", func() telegraf.Input {
|
inputs.Add("iptables", func() plugins.Input {
|
||||||
ipt := new(Iptables)
|
ipt := new(Iptables)
|
||||||
ipt.lister = ipt.chainList
|
ipt.lister = ipt.chainList
|
||||||
return ipt
|
return ipt
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"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 {
|
if j.jClient == nil {
|
||||||
tr := &http.Transport{ResponseHeaderTimeout: j.ResponseHeaderTimeout.Duration}
|
tr := &http.Transport{ResponseHeaderTimeout: j.ResponseHeaderTimeout.Duration}
|
||||||
|
@ -297,7 +297,7 @@ func (j *Jolokia) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("jolokia", func() telegraf.Input {
|
inputs.Add("jolokia", func() plugins.Input {
|
||||||
return &Jolokia{
|
return &Jolokia{
|
||||||
ResponseHeaderTimeout: DefaultResponseHeaderTimeout,
|
ResponseHeaderTimeout: DefaultResponseHeaderTimeout,
|
||||||
ClientTimeout: DefaultClientTimeout,
|
ClientTimeout: DefaultClientTimeout,
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers"
|
"github.com/influxdata/telegraf/plugins/parsers"
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ type Kafka struct {
|
||||||
done chan struct{}
|
done chan struct{}
|
||||||
|
|
||||||
// keep the accumulator internally:
|
// keep the accumulator internally:
|
||||||
acc telegraf.Accumulator
|
acc plugins.Accumulator
|
||||||
|
|
||||||
// doNotCommitMsgs tells the parser not to call CommitUpTo on the consumer
|
// 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.
|
// 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
|
k.parser = parser
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *Kafka) Start(acc telegraf.Accumulator) error {
|
func (k *Kafka) Start(acc plugins.Accumulator) error {
|
||||||
k.Lock()
|
k.Lock()
|
||||||
defer k.Unlock()
|
defer k.Unlock()
|
||||||
var consumerErr error
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("kafka_consumer", func() telegraf.Input {
|
inputs.Add("kafka_consumer", func() plugins.Input {
|
||||||
return &Kafka{}
|
return &Kafka{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/internal/errchan"
|
"github.com/influxdata/telegraf/internal/errchan"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
|
@ -54,7 +54,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("kubernetes", func() telegraf.Input {
|
inputs.Add("kubernetes", func() plugins.Input {
|
||||||
return &Kubernetes{}
|
return &Kubernetes{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ func (k *Kubernetes) Description() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Gather collects kubernetes metrics from a given URL
|
//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
|
var wg sync.WaitGroup
|
||||||
errChan := errchan.New(1)
|
errChan := errchan.New(1)
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
@ -91,7 +91,7 @@ func buildURL(endpoint string, base string) (*url.URL, error) {
|
||||||
return addr, nil
|
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)
|
url := fmt.Sprintf("%s/stats/summary", baseURL)
|
||||||
var req, err = http.NewRequest("GET", url, nil)
|
var req, err = http.NewRequest("GET", url, nil)
|
||||||
var token []byte
|
var token []byte
|
||||||
|
@ -139,7 +139,7 @@ func (k *Kubernetes) gatherSummary(baseURL string, acc telegraf.Accumulator) err
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildSystemContainerMetrics(summaryMetrics *SummaryMetrics, acc telegraf.Accumulator) {
|
func buildSystemContainerMetrics(summaryMetrics *SummaryMetrics, acc plugins.Accumulator) {
|
||||||
for _, container := range summaryMetrics.Node.SystemContainers {
|
for _, container := range summaryMetrics.Node.SystemContainers {
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"node_name": summaryMetrics.Node.NodeName,
|
"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{
|
tags := map[string]string{
|
||||||
"node_name": summaryMetrics.Node.NodeName,
|
"node_name": summaryMetrics.Node.NodeName,
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ func buildNodeMetrics(summaryMetrics *SummaryMetrics, acc telegraf.Accumulator)
|
||||||
acc.AddFields("kubernetes_node", fields, tags)
|
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 _, pod := range summaryMetrics.Pods {
|
||||||
for _, container := range pod.Containers {
|
for _, container := range pod.Containers {
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
@ -148,7 +148,7 @@ func (l *LeoFS) Description() string {
|
||||||
return "Read metrics from a LeoFS Server via SNMP"
|
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 {
|
if len(l.Servers) == 0 {
|
||||||
l.gatherServer(defaultEndpoint, ServerTypeManagerMaster, acc)
|
l.gatherServer(defaultEndpoint, ServerTypeManagerMaster, acc)
|
||||||
return nil
|
return nil
|
||||||
|
@ -181,7 +181,7 @@ func (l *LeoFS) Gather(acc telegraf.Accumulator) error {
|
||||||
func (l *LeoFS) gatherServer(
|
func (l *LeoFS) gatherServer(
|
||||||
endpoint string,
|
endpoint string,
|
||||||
serverType ServerType,
|
serverType ServerType,
|
||||||
acc telegraf.Accumulator,
|
acc plugins.Accumulator,
|
||||||
) error {
|
) error {
|
||||||
cmd := exec.Command("snmpwalk", "-v2c", "-cpublic", endpoint, oid)
|
cmd := exec.Command("snmpwalk", "-v2c", "-cpublic", endpoint, oid)
|
||||||
stdout, err := cmd.StdoutPipe()
|
stdout, err := cmd.StdoutPipe()
|
||||||
|
@ -231,7 +231,7 @@ func retrieveTokenAfterColon(line string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("leofs", func() telegraf.Input {
|
inputs.Add("leofs", func() plugins.Input {
|
||||||
return &LeoFS{}
|
return &LeoFS{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
|
|
||||||
"github.com/vjeantet/grok"
|
"github.com/vjeantet/grok"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ func (p *Parser) Compile() error {
|
||||||
return p.compileCustomPatterns()
|
return p.compileCustomPatterns()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Parser) ParseLine(line string) (telegraf.Metric, error) {
|
func (p *Parser) ParseLine(line string) (plugins.Metric, error) {
|
||||||
var err error
|
var err error
|
||||||
// values are the parsed fields from the log line
|
// values are the parsed fields from the log line
|
||||||
var values map[string]string
|
var values map[string]string
|
||||||
|
|
|
@ -4,13 +4,13 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
var benchM telegraf.Metric
|
var benchM plugins.Metric
|
||||||
|
|
||||||
func Benchmark_ParseLine_CommonLogFormat(b *testing.B) {
|
func Benchmark_ParseLine_CommonLogFormat(b *testing.B) {
|
||||||
p := &Parser{
|
p := &Parser{
|
||||||
|
@ -18,7 +18,7 @@ func Benchmark_ParseLine_CommonLogFormat(b *testing.B) {
|
||||||
}
|
}
|
||||||
p.Compile()
|
p.Compile()
|
||||||
|
|
||||||
var m telegraf.Metric
|
var m plugins.Metric
|
||||||
for n := 0; n < b.N; n++ {
|
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`)
|
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()
|
p.Compile()
|
||||||
|
|
||||||
var m telegraf.Metric
|
var m plugins.Metric
|
||||||
for n := 0; n < b.N; n++ {
|
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"`)
|
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()
|
p.Compile()
|
||||||
|
|
||||||
var m telegraf.Metric
|
var m plugins.Metric
|
||||||
for n := 0; n < b.N; n++ {
|
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`)
|
m, _ = p.ParseLine(`[04/Jun/2016:12:41:45 +0100] 1.25 200 192.168.1.1 5.432µs 101`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/hpcloud/tail"
|
"github.com/hpcloud/tail"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal/errchan"
|
"github.com/influxdata/telegraf/internal/errchan"
|
||||||
"github.com/influxdata/telegraf/internal/globpath"
|
"github.com/influxdata/telegraf/internal/globpath"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
|
@ -18,7 +18,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type LogParser interface {
|
type LogParser interface {
|
||||||
ParseLine(line string) (telegraf.Metric, error)
|
ParseLine(line string) (plugins.Metric, error)
|
||||||
Compile() error
|
Compile() error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ type LogParserPlugin struct {
|
||||||
lines chan string
|
lines chan string
|
||||||
done chan struct{}
|
done chan struct{}
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
acc telegraf.Accumulator
|
acc plugins.Accumulator
|
||||||
parsers []LogParser
|
parsers []LogParser
|
||||||
|
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
|
@ -76,11 +76,11 @@ func (l *LogParserPlugin) Description() string {
|
||||||
return "Stream and parse log file(s)."
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *LogParserPlugin) Start(acc telegraf.Accumulator) error {
|
func (l *LogParserPlugin) Start(acc plugins.Accumulator) error {
|
||||||
l.Lock()
|
l.Lock()
|
||||||
defer l.Unlock()
|
defer l.Unlock()
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ func (l *LogParserPlugin) receiver(tailer *tail.Tail) {
|
||||||
func (l *LogParserPlugin) parser() {
|
func (l *LogParserPlugin) parser() {
|
||||||
defer l.wg.Done()
|
defer l.wg.Done()
|
||||||
|
|
||||||
var m telegraf.Metric
|
var m plugins.Metric
|
||||||
var err error
|
var err error
|
||||||
var line string
|
var line string
|
||||||
for {
|
for {
|
||||||
|
@ -225,7 +225,7 @@ func (l *LogParserPlugin) Stop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("logparser", func() telegraf.Input {
|
inputs.Add("logparser", func() plugins.Input {
|
||||||
return &LogParserPlugin{}
|
return &LogParserPlugin{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"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)
|
files, err := filepath.Glob(fileglob)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -422,7 +422,7 @@ func (l *Lustre2) Description() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gather reads stats from all lustre targets
|
// 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{})
|
l.allFields = make(map[string]map[string]interface{})
|
||||||
|
|
||||||
if len(l.Ost_procfiles) == 0 {
|
if len(l.Ost_procfiles) == 0 {
|
||||||
|
@ -500,7 +500,7 @@ func (l *Lustre2) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("lustre2", func() telegraf.Input {
|
inputs.Add("lustre2", func() plugins.Input {
|
||||||
return &Lustre2{}
|
return &Lustre2{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"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"
|
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 {
|
if m.api == nil {
|
||||||
m.api = NewChimpAPI(m.ApiKey)
|
m.api = NewChimpAPI(m.ApiKey)
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ func (m *MailChimp) Gather(acc telegraf.Accumulator) error {
|
||||||
return nil
|
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 := make(map[string]string)
|
||||||
tags["id"] = report.ID
|
tags["id"] = report.ID
|
||||||
tags["campaign_title"] = report.CampaignTitle
|
tags["campaign_title"] = report.CampaignTitle
|
||||||
|
@ -111,7 +111,7 @@ func gatherReport(acc telegraf.Accumulator, report Report, now time.Time) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("mailchimp", func() telegraf.Input {
|
inputs.Add("mailchimp", func() plugins.Input {
|
||||||
return &MailChimp{}
|
return &MailChimp{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal/errchan"
|
"github.com/influxdata/telegraf/internal/errchan"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
@ -69,7 +69,7 @@ func (m *Memcached) Description() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gather reads stats from all configured servers accumulates stats
|
// 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 {
|
if len(m.Servers) == 0 && len(m.UnixSockets) == 0 {
|
||||||
return m.gatherServer(":11211", false, acc)
|
return m.gatherServer(":11211", false, acc)
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ func (m *Memcached) Gather(acc telegraf.Accumulator) error {
|
||||||
func (m *Memcached) gatherServer(
|
func (m *Memcached) gatherServer(
|
||||||
address string,
|
address string,
|
||||||
unix bool,
|
unix bool,
|
||||||
acc telegraf.Accumulator,
|
acc plugins.Accumulator,
|
||||||
) error {
|
) error {
|
||||||
var conn net.Conn
|
var conn net.Conn
|
||||||
var err error
|
var err error
|
||||||
|
@ -180,7 +180,7 @@ func parseResponse(r *bufio.Reader) (map[string]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("memcached", func() telegraf.Input {
|
inputs.Add("memcached", func() plugins.Input {
|
||||||
return &Memcached{}
|
return &Memcached{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
jsonparser "github.com/influxdata/telegraf/plugins/parsers/json"
|
jsonparser "github.com/influxdata/telegraf/plugins/parsers/json"
|
||||||
)
|
)
|
||||||
|
@ -94,7 +94,7 @@ func (m *Mesos) SetDefaults() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gather() metrics from given list of Mesos Masters
|
// 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 wg sync.WaitGroup
|
||||||
var errorChannel chan error
|
var errorChannel chan error
|
||||||
|
|
||||||
|
@ -425,7 +425,7 @@ type TaskStats struct {
|
||||||
Statistics map[string]interface{} `json:"statistics"`
|
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
|
var metrics []TaskStats
|
||||||
|
|
||||||
host, _, err := net.SplitHostPort(address)
|
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
|
// 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{}
|
var jsonOut map[string]interface{}
|
||||||
|
|
||||||
host, _, err := net.SplitHostPort(a)
|
host, _, err := net.SplitHostPort(a)
|
||||||
|
@ -532,7 +532,7 @@ func (m *Mesos) gatherMainMetrics(a string, defaultPort string, role Role, acc t
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("mesos", func() telegraf.Input {
|
inputs.Add("mesos", func() plugins.Input {
|
||||||
return &Mesos{}
|
return &Mesos{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package inputs
|
package inputs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
|
|
||||||
"github.com/stretchr/testify/mock"
|
"github.com/stretchr/testify/mock"
|
||||||
)
|
)
|
||||||
|
@ -22,7 +22,7 @@ func (m *MockPlugin) SampleConfig() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gather defines what data the plugin will gather.
|
// 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)
|
ret := m.Called(_a0)
|
||||||
|
|
||||||
r0 := ret.Error(0)
|
r0 := ret.Error(0)
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal/errchan"
|
"github.com/influxdata/telegraf/internal/errchan"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"gopkg.in/mgo.v2"
|
"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.
|
// Reads stats from all configured servers accumulates stats.
|
||||||
// Returns one of the errors encountered while gather stats (if any).
|
// 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 {
|
if len(m.Servers) == 0 {
|
||||||
m.gatherServer(m.getMongoServer(localhost), acc)
|
m.gatherServer(m.getMongoServer(localhost), acc)
|
||||||
return nil
|
return nil
|
||||||
|
@ -89,7 +89,7 @@ func (m *MongoDB) getMongoServer(url *url.URL) *Server {
|
||||||
return m.mongos[url.Host]
|
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 {
|
if server.Session == nil {
|
||||||
var dialAddrs []string
|
var dialAddrs []string
|
||||||
if server.Url.User != nil {
|
if server.Url.User != nil {
|
||||||
|
@ -139,7 +139,7 @@ func (m *MongoDB) gatherServer(server *Server, acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("mongodb", func() telegraf.Input {
|
inputs.Add("mongodb", func() plugins.Input {
|
||||||
return &MongoDB{
|
return &MongoDB{
|
||||||
mongos: make(map[string]*Server),
|
mongos: make(map[string]*Server),
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MongodbData struct {
|
type MongodbData struct {
|
||||||
|
@ -138,7 +138,7 @@ func (d *MongodbData) add(key string, val interface{}) {
|
||||||
d.Fields[key] = val
|
d.Fields[key] = val
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *MongodbData) flush(acc telegraf.Accumulator) {
|
func (d *MongodbData) flush(acc plugins.Accumulator) {
|
||||||
acc.AddFields(
|
acc.AddFields(
|
||||||
"mongodb",
|
"mongodb",
|
||||||
d.Fields,
|
d.Fields,
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"gopkg.in/mgo.v2"
|
"gopkg.in/mgo.v2"
|
||||||
"gopkg.in/mgo.v2/bson"
|
"gopkg.in/mgo.v2/bson"
|
||||||
)
|
)
|
||||||
|
@ -22,7 +22,7 @@ func (s *Server) getDefaultTags() map[string]string {
|
||||||
return tags
|
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.SetMode(mgo.Eventual, true)
|
||||||
s.Session.SetSocketTimeout(0)
|
s.Session.SetSocketTimeout(0)
|
||||||
result_server := &ServerStatus{}
|
result_server := &ServerStatus{}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers"
|
"github.com/influxdata/telegraf/plugins/parsers"
|
||||||
|
@ -46,7 +46,7 @@ type MQTTConsumer struct {
|
||||||
done chan struct{}
|
done chan struct{}
|
||||||
|
|
||||||
// keep the accumulator internally:
|
// keep the accumulator internally:
|
||||||
acc telegraf.Accumulator
|
acc plugins.Accumulator
|
||||||
|
|
||||||
started bool
|
started bool
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ func (m *MQTTConsumer) SetParser(parser parsers.Parser) {
|
||||||
m.parser = parser
|
m.parser = parser
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MQTTConsumer) Start(acc telegraf.Accumulator) error {
|
func (m *MQTTConsumer) Start(acc plugins.Accumulator) error {
|
||||||
m.Lock()
|
m.Lock()
|
||||||
defer m.Unlock()
|
defer m.Unlock()
|
||||||
m.started = false
|
m.started = false
|
||||||
|
@ -191,7 +191,7 @@ func (m *MQTTConsumer) Stop() {
|
||||||
m.started = false
|
m.started = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MQTTConsumer) Gather(acc telegraf.Accumulator) error {
|
func (m *MQTTConsumer) Gather(acc plugins.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ func (m *MQTTConsumer) createOpts() (*mqtt.ClientOptions, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("mqtt_consumer", func() telegraf.Input {
|
inputs.Add("mqtt_consumer", func() plugins.Input {
|
||||||
return &MQTTConsumer{}
|
return &MQTTConsumer{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal/errchan"
|
"github.com/influxdata/telegraf/internal/errchan"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ func (m *Mysql) InitMysql() {
|
||||||
initDone = true
|
initDone = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mysql) Gather(acc telegraf.Accumulator) error {
|
func (m *Mysql) Gather(acc plugins.Accumulator) error {
|
||||||
if len(m.Servers) == 0 {
|
if len(m.Servers) == 0 {
|
||||||
// default to localhost if nothing specified.
|
// default to localhost if nothing specified.
|
||||||
return m.gatherServer(localhost, acc)
|
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)
|
serv, err := dsnAddTimeout(serv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
// gatherGlobalVariables can be used to fetch all global variables from
|
||||||
// MySQL environment.
|
// 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
|
// run query
|
||||||
rows, err := db.Query(globalVariablesQuery)
|
rows, err := db.Query(globalVariablesQuery)
|
||||||
if err != nil {
|
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.
|
// When the server is slave, then it returns only one row.
|
||||||
// If the multi-source replication is set, then everything works differently
|
// If the multi-source replication is set, then everything works differently
|
||||||
// This code does not work with multi-source replication.
|
// 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
|
// run query
|
||||||
rows, err := db.Query(slaveStatusQuery)
|
rows, err := db.Query(slaveStatusQuery)
|
||||||
if err != nil {
|
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
|
// 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
|
// 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
|
// run query
|
||||||
rows, err := db.Query(binaryLogsQuery)
|
rows, err := db.Query(binaryLogsQuery)
|
||||||
if err != nil {
|
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
|
// gatherGlobalStatuses can be used to get MySQL status metrics
|
||||||
// the mappings of actual names and names of each status to be exported
|
// the mappings of actual names and names of each status to be exported
|
||||||
// to output is provided on mappings variable
|
// 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 user forgot the '/', add it
|
||||||
if strings.HasSuffix(serv, ")") {
|
if strings.HasSuffix(serv, ")") {
|
||||||
serv = 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
|
// GatherProcessList can be used to collect metrics on each running command
|
||||||
// and its state with its running count
|
// 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
|
// run query
|
||||||
rows, err := db.Query(infoSchemaProcessListQuery)
|
rows, err := db.Query(infoSchemaProcessListQuery)
|
||||||
if err != nil {
|
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
|
// gatherPerfTableIOWaits can be used to get total count and time
|
||||||
// of I/O wait event for each table and process
|
// 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)
|
rows, err := db.Query(perfTableIOWaitsQuery)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
// gatherPerfIndexIOWaits can be used to get total count and time
|
||||||
// of I/O wait event for each index and process
|
// 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)
|
rows, err := db.Query(perfIndexIOWaitsQuery)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
// 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)
|
rows, err := db.Query(infoSchemaAutoIncQuery)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
// the total number and time for SQL and external lock wait events
|
||||||
// for each table and operation
|
// for each table and operation
|
||||||
// requires the MySQL server to be enabled to save this metric
|
// 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,
|
// check if table exists,
|
||||||
// if performance_schema is not enabled, tables do not exist
|
// if performance_schema is not enabled, tables do not exist
|
||||||
// then there is no need to scan them
|
// 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
|
// 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)
|
rows, err := db.Query(perfEventWaitsQuery)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
// 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)
|
rows, err := db.Query(perfFileEventsQuery)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
// 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(
|
query := fmt.Sprintf(
|
||||||
perfEventsStatementsQuery,
|
perfEventsStatementsQuery,
|
||||||
m.PerfEventsStatementsDigestTextLimit,
|
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
|
// 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
|
var dbList []string
|
||||||
servtag := getDSNTag(serv)
|
servtag := getDSNTag(serv)
|
||||||
|
|
||||||
|
@ -1539,7 +1539,7 @@ func getDSNTag(dsn string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("mysql", func() telegraf.Input {
|
inputs.Add("mysql", func() plugins.Input {
|
||||||
return &Mysql{}
|
return &Mysql{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers"
|
"github.com/influxdata/telegraf/plugins/parsers"
|
||||||
"github.com/nats-io/nats"
|
"github.com/nats-io/nats"
|
||||||
|
@ -47,7 +47,7 @@ type natsConsumer struct {
|
||||||
// channel for all NATS read errors
|
// channel for all NATS read errors
|
||||||
errs chan error
|
errs chan error
|
||||||
done chan struct{}
|
done chan struct{}
|
||||||
acc telegraf.Accumulator
|
acc plugins.Accumulator
|
||||||
}
|
}
|
||||||
|
|
||||||
var sampleConfig = `
|
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.
|
// 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()
|
n.Lock()
|
||||||
defer n.Unlock()
|
defer n.Unlock()
|
||||||
|
|
||||||
|
@ -197,12 +197,12 @@ func (n *natsConsumer) Stop() {
|
||||||
n.Unlock()
|
n.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *natsConsumer) Gather(acc telegraf.Accumulator) error {
|
func (n *natsConsumer) Gather(acc plugins.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("nats_consumer", func() telegraf.Input {
|
inputs.Add("nats_consumer", func() plugins.Input {
|
||||||
return &natsConsumer{
|
return &natsConsumer{
|
||||||
Servers: []string{"nats://localhost:4222"},
|
Servers: []string{"nats://localhost:4222"},
|
||||||
Secure: false,
|
Secure: false,
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
@ -147,7 +147,7 @@ func (n *NetResponse) UdpGather() (map[string]interface{}, error) {
|
||||||
return fields, nil
|
return fields, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NetResponse) Gather(acc telegraf.Accumulator) error {
|
func (n *NetResponse) Gather(acc plugins.Accumulator) error {
|
||||||
// Set default values
|
// Set default values
|
||||||
if n.Timeout.Duration == 0 {
|
if n.Timeout.Duration == 0 {
|
||||||
n.Timeout.Duration = time.Second
|
n.Timeout.Duration = time.Second
|
||||||
|
@ -195,7 +195,7 @@ func (n *NetResponse) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("net_response", func() telegraf.Input {
|
inputs.Add("net_response", func() plugins.Input {
|
||||||
return &NetResponse{}
|
return &NetResponse{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal/errchan"
|
"github.com/influxdata/telegraf/internal/errchan"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"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)"
|
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
|
var wg sync.WaitGroup
|
||||||
errChan := errchan.New(len(n.Urls))
|
errChan := errchan.New(len(n.Urls))
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ var client = &http.Client{
|
||||||
Timeout: time.Duration(4 * time.Second),
|
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())
|
resp, err := client.Get(addr.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error making HTTP request to %s: %s", addr.String(), err)
|
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() {
|
func init() {
|
||||||
inputs.Add("nginx", func() telegraf.Input {
|
inputs.Add("nginx", func() plugins.Input {
|
||||||
return &Nginx{}
|
return &Nginx{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal/errchan"
|
"github.com/influxdata/telegraf/internal/errchan"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
@ -51,7 +51,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("nsq", func() telegraf.Input {
|
inputs.Add("nsq", func() plugins.Input {
|
||||||
return &NSQ{}
|
return &NSQ{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ func (n *NSQ) Description() string {
|
||||||
return "Read NSQ topic and channel statistics."
|
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
|
var wg sync.WaitGroup
|
||||||
errChan := errchan.New(len(n.Endpoints))
|
errChan := errchan.New(len(n.Endpoints))
|
||||||
for _, e := range n.Endpoints {
|
for _, e := range n.Endpoints {
|
||||||
|
@ -88,7 +88,7 @@ var client = &http.Client{
|
||||||
Timeout: time.Duration(4 * time.Second),
|
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)
|
u, err := buildURL(e)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -139,7 +139,7 @@ func buildURL(e string) (*url.URL, error) {
|
||||||
return addr, nil
|
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)
|
// per topic overall (tag: name, paused, channel count)
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"server_host": host,
|
"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{
|
tags := map[string]string{
|
||||||
"server_host": host,
|
"server_host": host,
|
||||||
"server_version": version,
|
"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{
|
tags := map[string]string{
|
||||||
"server_host": host,
|
"server_host": host,
|
||||||
"server_version": version,
|
"server_version": version,
|
||||||
|
|
|
@ -3,7 +3,7 @@ package nsq_consumer
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers"
|
"github.com/influxdata/telegraf/plugins/parsers"
|
||||||
"github.com/nsqio/go-nsq"
|
"github.com/nsqio/go-nsq"
|
||||||
|
@ -17,7 +17,7 @@ type NSQConsumer struct {
|
||||||
MaxInFlight int
|
MaxInFlight int
|
||||||
parser parsers.Parser
|
parser parsers.Parser
|
||||||
consumer *nsq.Consumer
|
consumer *nsq.Consumer
|
||||||
acc telegraf.Accumulator
|
acc plugins.Accumulator
|
||||||
}
|
}
|
||||||
|
|
||||||
var sampleConfig = `
|
var sampleConfig = `
|
||||||
|
@ -35,7 +35,7 @@ var sampleConfig = `
|
||||||
`
|
`
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("nsq_consumer", func() telegraf.Input {
|
inputs.Add("nsq_consumer", func() plugins.Input {
|
||||||
return &NSQConsumer{}
|
return &NSQConsumer{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ func (n *NSQConsumer) Description() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start pulls data from nsq
|
// 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.acc = acc
|
||||||
n.connect()
|
n.connect()
|
||||||
n.consumer.AddConcurrentHandlers(nsq.HandlerFunc(func(message *nsq.Message) error {
|
n.consumer.AddConcurrentHandlers(nsq.HandlerFunc(func(message *nsq.Message) error {
|
||||||
|
@ -81,7 +81,7 @@ func (n *NSQConsumer) Stop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gather is a noop
|
// Gather is a noop
|
||||||
func (n *NSQConsumer) Gather(acc telegraf.Accumulator) error {
|
func (n *NSQConsumer) Gather(acc plugins.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ func (ns *Nstat) SampleConfig() string {
|
||||||
return sampleConfig
|
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
|
// load paths, get from env if config values are empty
|
||||||
ns.loadPaths()
|
ns.loadPaths()
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ func (ns *Nstat) Gather(acc telegraf.Accumulator) error {
|
||||||
return nil
|
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)
|
metrics, err := loadUglyTable(data, ns.DumpZeros)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -107,7 +107,7 @@ func (ns *Nstat) gatherNetstat(data []byte, acc telegraf.Accumulator) error {
|
||||||
return nil
|
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)
|
metrics, err := loadUglyTable(data, ns.DumpZeros)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -119,7 +119,7 @@ func (ns *Nstat) gatherSNMP(data []byte, acc telegraf.Accumulator) error {
|
||||||
return nil
|
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)
|
metrics, err := loadGoodTable(data, ns.DumpZeros)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -227,7 +227,7 @@ func proc(env, path string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("nstat", func() telegraf.Input {
|
inputs.Add("nstat", func() plugins.Input {
|
||||||
return &Nstat{}
|
return &Nstat{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"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()
|
out, err := n.runQ()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -209,7 +209,7 @@ func (n *NTPQ) runq() ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("ntpq", func() telegraf.Input {
|
inputs.Add("ntpq", func() plugins.Input {
|
||||||
n := &NTPQ{}
|
n := &NTPQ{}
|
||||||
n.runQ = n.runq
|
n.runQ = n.runq
|
||||||
return n
|
return n
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"golang.org/x/net/html/charset"
|
"golang.org/x/net/html/charset"
|
||||||
)
|
)
|
||||||
|
@ -145,7 +145,7 @@ func (r *passenger) Description() string {
|
||||||
return "Read metrics of passenger using passenger-status"
|
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 == "" {
|
if g.Command == "" {
|
||||||
g.Command = "passenger-status -v --show=xml"
|
g.Command = "passenger-status -v --show=xml"
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ func (g *passenger) Gather(acc telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func importMetric(stat []byte, acc telegraf.Accumulator) error {
|
func importMetric(stat []byte, acc plugins.Accumulator) error {
|
||||||
var p info
|
var p info
|
||||||
|
|
||||||
decoder := xml.NewDecoder(bytes.NewReader(stat))
|
decoder := xml.NewDecoder(bytes.NewReader(stat))
|
||||||
|
@ -244,7 +244,7 @@ func importMetric(stat []byte, acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("passenger", func() telegraf.Input {
|
inputs.Add("passenger", func() plugins.Input {
|
||||||
return &passenger{}
|
return &passenger{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ func (r *phpfpm) Description() string {
|
||||||
|
|
||||||
// Reads stats from all configured servers accumulates stats.
|
// Reads stats from all configured servers accumulates stats.
|
||||||
// Returns one of the errors encountered while gather stats (if any).
|
// 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 {
|
if len(g.Urls) == 0 {
|
||||||
return g.gatherServer("http://127.0.0.1/status", acc)
|
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
|
// 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 {
|
if g.client == nil {
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
g.client = client
|
g.client = client
|
||||||
|
@ -154,7 +154,7 @@ func (g *phpfpm) gatherServer(addr string, acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gather stat using fcgi protocol
|
// 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{
|
fpmOutput, fpmErr, err := fcgi.Request(map[string]string{
|
||||||
"SCRIPT_NAME": "/" + statusPath,
|
"SCRIPT_NAME": "/" + statusPath,
|
||||||
"SCRIPT_FILENAME": statusPath,
|
"SCRIPT_FILENAME": statusPath,
|
||||||
|
@ -174,7 +174,7 @@ func (g *phpfpm) gatherFcgi(fcgi *conn, statusPath string, acc telegraf.Accumula
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gather stat using http protocol
|
// 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)
|
u, err := url.Parse(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Unable parse server address '%s': %s", addr, err)
|
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
|
// 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)
|
stats := make(poolStat)
|
||||||
var currentPool string
|
var currentPool string
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ func importMetric(r io.Reader, acc telegraf.Accumulator) (poolStat, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("phpfpm", func() telegraf.Input {
|
inputs.Add("phpfpm", func() plugins.Input {
|
||||||
return &phpfpm{}
|
return &phpfpm{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
@ -65,7 +65,7 @@ func (_ *Ping) SampleConfig() string {
|
||||||
return sampleConfig
|
return sampleConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Ping) Gather(acc telegraf.Accumulator) error {
|
func (p *Ping) Gather(acc plugins.Accumulator) error {
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
errorChannel := make(chan error, len(p.Urls)*2)
|
errorChannel := make(chan error, len(p.Urls)*2)
|
||||||
|
@ -203,7 +203,7 @@ func processPingOutput(out string) (int, int, float64, float64, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("ping", func() telegraf.Input {
|
inputs.Add("ping", func() plugins.Input {
|
||||||
return &Ping{
|
return &Ping{
|
||||||
pingHost: hostPinger,
|
pingHost: hostPinger,
|
||||||
PingInterval: 1.0,
|
PingInterval: 1.0,
|
||||||
|
|
|
@ -3,7 +3,7 @@ package ping
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -144,7 +144,7 @@ func (p *Ping) args(url string) []string {
|
||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Ping) Gather(acc telegraf.Accumulator) error {
|
func (p *Ping) Gather(acc plugins.Accumulator) error {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
errorChannel := make(chan error, len(p.Urls)*2)
|
errorChannel := make(chan error, len(p.Urls)*2)
|
||||||
var pendingError error = nil
|
var pendingError error = nil
|
||||||
|
@ -217,7 +217,7 @@ func (p *Ping) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("ping", func() telegraf.Input {
|
inputs.Add("ping", func() plugins.Input {
|
||||||
return &Ping{pingHost: hostPinger}
|
return &Ping{pingHost: hostPinger}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
|
|
||||||
"github.com/lib/pq"
|
"github.com/lib/pq"
|
||||||
|
@ -64,7 +64,7 @@ func (p *Postgresql) IgnoredColumns() map[string]bool {
|
||||||
|
|
||||||
var localhost = "host=localhost sslmode=disable"
|
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
|
var query string
|
||||||
|
|
||||||
if p.Address == "" || p.Address == "localhost" {
|
if p.Address == "" || p.Address == "localhost" {
|
||||||
|
@ -161,7 +161,7 @@ func (p *Postgresql) SanitizedAddress() (_ string, err error) {
|
||||||
return p.sanitizedAddress, err
|
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 columnVars []interface{}
|
||||||
var dbname bytes.Buffer
|
var dbname bytes.Buffer
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ func (p *Postgresql) accRow(row scanner, acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("postgresql", func() telegraf.Input {
|
inputs.Add("postgresql", func() plugins.Input {
|
||||||
return &Postgresql{}
|
return &Postgresql{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
|
|
||||||
"github.com/lib/pq"
|
"github.com/lib/pq"
|
||||||
|
@ -113,7 +113,7 @@ func (p *Postgresql) IgnoredColumns() map[string]bool {
|
||||||
|
|
||||||
var localhost = "host=localhost sslmode=disable"
|
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 sql_query string
|
||||||
var query_addon string
|
var query_addon string
|
||||||
|
@ -224,7 +224,7 @@ func (p *Postgresql) SanitizedAddress() (_ string, err error) {
|
||||||
return p.sanitizedAddress, err
|
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 columnVars []interface{}
|
||||||
var dbname bytes.Buffer
|
var dbname bytes.Buffer
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ COLUMN:
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("postgresql_extensible", func() telegraf.Input {
|
inputs.Add("postgresql_extensible", func() plugins.Input {
|
||||||
return &Postgresql{}
|
return &Postgresql{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ func (p *Powerdns) Description() string {
|
||||||
return "Read metrics from one or many PowerDNS servers"
|
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 {
|
if len(p.UnixSockets) == 0 {
|
||||||
return p.gatherServer("/var/run/pdns.controlsocket", acc)
|
return p.gatherServer("/var/run/pdns.controlsocket", acc)
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ func (p *Powerdns) Gather(acc telegraf.Accumulator) error {
|
||||||
return nil
|
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)
|
conn, err := net.DialTimeout("unix", address, defaultTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -121,7 +121,7 @@ func parseResponse(metrics string) map[string]interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("powerdns", func() telegraf.Input {
|
inputs.Add("powerdns", func() plugins.Input {
|
||||||
return &Powerdns{}
|
return &Powerdns{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/process"
|
"github.com/shirou/gopsutil/process"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ func (_ *Procstat) Description() string {
|
||||||
return "Monitor process cpu and memory usage"
|
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()
|
err := p.createProcesses()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("E! Error: procstat getting process, exe: [%s] pidfile: [%s] pattern: [%s] user: [%s] %s",
|
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() {
|
func init() {
|
||||||
inputs.Add("procstat", func() telegraf.Input {
|
inputs.Add("procstat", func() plugins.Input {
|
||||||
return NewProcstat()
|
return NewProcstat()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/process"
|
"github.com/shirou/gopsutil/process"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SpecProcessor struct {
|
type SpecProcessor struct {
|
||||||
|
@ -13,7 +13,7 @@ type SpecProcessor struct {
|
||||||
pid int32
|
pid int32
|
||||||
tags map[string]string
|
tags map[string]string
|
||||||
fields map[string]interface{}
|
fields map[string]interface{}
|
||||||
acc telegraf.Accumulator
|
acc plugins.Accumulator
|
||||||
proc *process.Process
|
proc *process.Process
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ func NewSpecProcessor(
|
||||||
processName string,
|
processName string,
|
||||||
prefix string,
|
prefix string,
|
||||||
pid int32,
|
pid int32,
|
||||||
acc telegraf.Accumulator,
|
acc plugins.Accumulator,
|
||||||
p *process.Process,
|
p *process.Process,
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
) *SpecProcessor {
|
) *SpecProcessor {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
|
|
||||||
"github.com/matttproud/golang_protobuf_extensions/pbutil"
|
"github.com/matttproud/golang_protobuf_extensions/pbutil"
|
||||||
|
@ -23,8 +23,8 @@ import (
|
||||||
|
|
||||||
// Parse returns a slice of Metrics from a text representation of a
|
// Parse returns a slice of Metrics from a text representation of a
|
||||||
// metrics
|
// metrics
|
||||||
func Parse(buf []byte, header http.Header) ([]telegraf.Metric, error) {
|
func Parse(buf []byte, header http.Header) ([]plugins.Metric, error) {
|
||||||
var metrics []telegraf.Metric
|
var metrics []plugins.Metric
|
||||||
var parser expfmt.TextParser
|
var parser expfmt.TextParser
|
||||||
// parse even if the buffer begins with a newline
|
// parse even if the buffer begins with a newline
|
||||||
buf = bytes.TrimPrefix(buf, []byte("\n"))
|
buf = bytes.TrimPrefix(buf, []byte("\n"))
|
||||||
|
|
|
@ -3,7 +3,7 @@ package prometheus
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -63,7 +63,7 @@ var ErrProtocolError = errors.New("prometheus protocol error")
|
||||||
|
|
||||||
// Reads stats from all configured servers accumulates stats.
|
// Reads stats from all configured servers accumulates stats.
|
||||||
// Returns one of the errors encountered while gather stats (if any).
|
// 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 wg sync.WaitGroup
|
||||||
|
|
||||||
var outerr error
|
var outerr error
|
||||||
|
@ -90,7 +90,7 @@ var client = &http.Client{
|
||||||
Timeout: time.Duration(4 * time.Second),
|
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()
|
collectDate := time.Now()
|
||||||
var req, err = http.NewRequest("GET", url, nil)
|
var req, err = http.NewRequest("GET", url, nil)
|
||||||
req.Header.Add("Accept", acceptHeader)
|
req.Header.Add("Accept", acceptHeader)
|
||||||
|
@ -152,7 +152,7 @@ func (p *Prometheus) gatherURL(url string, acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("prometheus", func() telegraf.Input {
|
inputs.Add("prometheus", func() plugins.Input {
|
||||||
return &Prometheus{ResponseTimeout: internal.Duration{Duration: time.Second * 3}}
|
return &Prometheus{ResponseTimeout: internal.Duration{Duration: time.Second * 3}}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ func (pa *PuppetAgent) Description() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gather reads stats from all configured servers accumulates stats
|
// 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 {
|
if len(pa.Location) == 0 {
|
||||||
pa.Location = "/var/lib/puppet/state/last_run_summary.yaml"
|
pa.Location = "/var/lib/puppet/state/last_run_summary.yaml"
|
||||||
|
@ -111,7 +111,7 @@ func (pa *PuppetAgent) Gather(acc telegraf.Accumulator) error {
|
||||||
return nil
|
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()
|
e := reflect.ValueOf(s).Elem()
|
||||||
|
|
||||||
fields := make(map[string]interface{})
|
fields := make(map[string]interface{})
|
||||||
|
@ -132,7 +132,7 @@ func structPrinter(s *State, acc telegraf.Accumulator, tags map[string]string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("puppetagent", func() telegraf.Input {
|
inputs.Add("puppetagent", func() plugins.Input {
|
||||||
return &PuppetAgent{}
|
return &PuppetAgent{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/internal/errchan"
|
"github.com/influxdata/telegraf/internal/errchan"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
|
@ -136,7 +136,7 @@ type Node struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// gatherFunc ...
|
// 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}
|
var gatherFunctions = []gatherFunc{gatherOverview, gatherNodes, gatherQueues}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ func (r *RabbitMQ) Description() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gather ...
|
// Gather ...
|
||||||
func (r *RabbitMQ) Gather(acc telegraf.Accumulator) error {
|
func (r *RabbitMQ) Gather(acc plugins.Accumulator) error {
|
||||||
if r.Client == nil {
|
if r.Client == nil {
|
||||||
tlsCfg, err := internal.GetTLSConfig(
|
tlsCfg, err := internal.GetTLSConfig(
|
||||||
r.SSLCert, r.SSLKey, r.SSLCA, r.InsecureSkipVerify)
|
r.SSLCert, r.SSLKey, r.SSLCA, r.InsecureSkipVerify)
|
||||||
|
@ -245,7 +245,7 @@ func (r *RabbitMQ) requestJSON(u string, target interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func gatherOverview(r *RabbitMQ, acc telegraf.Accumulator, errChan chan error) {
|
func gatherOverview(r *RabbitMQ, acc plugins.Accumulator, errChan chan error) {
|
||||||
overview := &OverviewResponse{}
|
overview := &OverviewResponse{}
|
||||||
|
|
||||||
err := r.requestJSON("/api/overview", &overview)
|
err := r.requestJSON("/api/overview", &overview)
|
||||||
|
@ -281,7 +281,7 @@ func gatherOverview(r *RabbitMQ, acc telegraf.Accumulator, errChan chan error) {
|
||||||
errChan <- nil
|
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)
|
nodes := make([]Node, 0)
|
||||||
// Gather information about nodes
|
// Gather information about nodes
|
||||||
err := r.requestJSON("/api/nodes", &nodes)
|
err := r.requestJSON("/api/nodes", &nodes)
|
||||||
|
@ -318,7 +318,7 @@ func gatherNodes(r *RabbitMQ, acc telegraf.Accumulator, errChan chan error) {
|
||||||
errChan <- nil
|
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
|
// Gather information about queues
|
||||||
queues := make([]Queue, 0)
|
queues := make([]Queue, 0)
|
||||||
err := r.requestJSON("/api/queues", &queues)
|
err := r.requestJSON("/api/queues", &queues)
|
||||||
|
@ -404,7 +404,7 @@ func (r *RabbitMQ) shouldGatherQueue(queue Queue) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("rabbitmq", func() telegraf.Input {
|
inputs.Add("rabbitmq", func() plugins.Input {
|
||||||
return &RabbitMQ{
|
return &RabbitMQ{
|
||||||
ResponseHeaderTimeout: internal.Duration{Duration: DefaultResponseHeaderTimeout * time.Second},
|
ResponseHeaderTimeout: internal.Duration{Duration: DefaultResponseHeaderTimeout * time.Second},
|
||||||
ClientTimeout: internal.Duration{Duration: DefaultClientTimeout * time.Second},
|
ClientTimeout: internal.Duration{Duration: DefaultClientTimeout * time.Second},
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"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)"
|
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 wg sync.WaitGroup
|
||||||
var outerr error
|
var outerr error
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ func (r *Raindrops) Gather(acc telegraf.Accumulator) error {
|
||||||
return outerr
|
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())
|
resp, err := r.http_client.Get(addr.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error making HTTP request to %s: %s", addr.String(), err)
|
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() {
|
func init() {
|
||||||
inputs.Add("raindrops", func() telegraf.Input {
|
inputs.Add("raindrops", func() plugins.Input {
|
||||||
return &Raindrops{http_client: &http.Client{
|
return &Raindrops{http_client: &http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
ResponseHeaderTimeout: time.Duration(3 * time.Second),
|
ResponseHeaderTimeout: time.Duration(3 * time.Second),
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/internal/errchan"
|
"github.com/influxdata/telegraf/internal/errchan"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
@ -55,7 +55,7 @@ const defaultPort = "6379"
|
||||||
|
|
||||||
// Reads stats from all configured servers accumulates stats.
|
// Reads stats from all configured servers accumulates stats.
|
||||||
// Returns one of the errors encountered while gather stats (if any).
|
// 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 {
|
if len(r.Servers) == 0 {
|
||||||
url := &url.URL{
|
url := &url.URL{
|
||||||
Scheme: "tcp",
|
Scheme: "tcp",
|
||||||
|
@ -99,7 +99,7 @@ func (r *Redis) Gather(acc telegraf.Accumulator) error {
|
||||||
return errChan.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
|
var address string
|
||||||
|
|
||||||
if addr.Scheme == "unix" {
|
if addr.Scheme == "unix" {
|
||||||
|
@ -154,7 +154,7 @@ func (r *Redis) gatherServer(addr *url.URL, acc telegraf.Accumulator) error {
|
||||||
// gatherInfoOutput gathers
|
// gatherInfoOutput gathers
|
||||||
func gatherInfoOutput(
|
func gatherInfoOutput(
|
||||||
rdr *bufio.Reader,
|
rdr *bufio.Reader,
|
||||||
acc telegraf.Accumulator,
|
acc plugins.Accumulator,
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
) error {
|
) error {
|
||||||
var section string
|
var section string
|
||||||
|
@ -256,7 +256,7 @@ func gatherInfoOutput(
|
||||||
func gatherKeyspaceLine(
|
func gatherKeyspaceLine(
|
||||||
name string,
|
name string,
|
||||||
line string,
|
line string,
|
||||||
acc telegraf.Accumulator,
|
acc plugins.Accumulator,
|
||||||
global_tags map[string]string,
|
global_tags map[string]string,
|
||||||
) {
|
) {
|
||||||
if strings.Contains(line, "keys=") {
|
if strings.Contains(line, "keys=") {
|
||||||
|
@ -279,7 +279,7 @@ func gatherKeyspaceLine(
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("redis", func() telegraf.Input {
|
inputs.Add("redis", func() plugins.Input {
|
||||||
return &Redis{}
|
return &Redis{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package inputs
|
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{}
|
var Inputs = map[string]Creator{}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
|
|
||||||
"gopkg.in/dancannon/gorethink.v1"
|
"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.
|
// Reads stats from all configured servers accumulates stats.
|
||||||
// Returns one of the errors encountered while gather stats (if any).
|
// 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 {
|
if len(r.Servers) == 0 {
|
||||||
r.gatherServer(localhost, acc)
|
r.gatherServer(localhost, acc)
|
||||||
return nil
|
return nil
|
||||||
|
@ -66,7 +66,7 @@ func (r *RethinkDB) Gather(acc telegraf.Accumulator) error {
|
||||||
return outerr
|
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
|
var err error
|
||||||
connectOpts := gorethink.ConnectOpts{
|
connectOpts := gorethink.ConnectOpts{
|
||||||
Address: server.Url.Host,
|
Address: server.Url.Host,
|
||||||
|
@ -88,7 +88,7 @@ func (r *RethinkDB) gatherServer(server *Server, acc telegraf.Accumulator) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("rethinkdb", func() telegraf.Input {
|
inputs.Add("rethinkdb", func() plugins.Input {
|
||||||
return &RethinkDB{}
|
return &RethinkDB{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
type serverStatus struct {
|
type serverStatus struct {
|
||||||
|
@ -88,7 +88,7 @@ var engineStats = map[string]string{
|
||||||
|
|
||||||
func (e *Engine) AddEngineStats(
|
func (e *Engine) AddEngineStats(
|
||||||
keys []string,
|
keys []string,
|
||||||
acc telegraf.Accumulator,
|
acc plugins.Accumulator,
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
) {
|
) {
|
||||||
engine := reflect.ValueOf(e).Elem()
|
engine := reflect.ValueOf(e).Elem()
|
||||||
|
@ -99,7 +99,7 @@ func (e *Engine) AddEngineStats(
|
||||||
acc.AddFields("rethinkdb_engine", fields, tags)
|
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{}{
|
fields := map[string]interface{}{
|
||||||
"cache_bytes_in_use": s.Cache.BytesInUse,
|
"cache_bytes_in_use": s.Cache.BytesInUse,
|
||||||
"disk_read_bytes_per_sec": s.Disk.ReadBytesPerSec,
|
"disk_read_bytes_per_sec": s.Disk.ReadBytesPerSec,
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf/plugins"
|
||||||
|
|
||||||
"gopkg.in/dancannon/gorethink.v1"
|
"gopkg.in/dancannon/gorethink.v1"
|
||||||
)
|
)
|
||||||
|
@ -20,7 +20,7 @@ type Server struct {
|
||||||
serverStatus serverStatus
|
serverStatus serverStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) gatherData(acc telegraf.Accumulator) error {
|
func (s *Server) gatherData(acc plugins.Accumulator) error {
|
||||||
if err := s.getServerStatus(); err != nil {
|
if err := s.getServerStatus(); err != nil {
|
||||||
return fmt.Errorf("Failed to get server_status, %s\n", err)
|
return fmt.Errorf("Failed to get server_status, %s\n", err)
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ var ClusterTracking = []string{
|
||||||
"written_docs_per_sec",
|
"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)
|
cursor, err := gorethink.DB("rethinkdb").Table("stats").Get([]string{"cluster"}).Run(s.session)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cluster stats query error, %s\n", err.Error())
|
return fmt.Errorf("cluster stats query error, %s\n", err.Error())
|
||||||
|
@ -138,7 +138,7 @@ var MemberTracking = []string{
|
||||||
"total_writes",
|
"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)
|
cursor, err := gorethink.DB("rethinkdb").Table("stats").Get([]string{"server", s.serverStatus.Id}).Run(s.session)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("member stats query error, %s\n", err.Error())
|
return fmt.Errorf("member stats query error, %s\n", err.Error())
|
||||||
|
@ -162,7 +162,7 @@ var TableTracking = []string{
|
||||||
"total_writes",
|
"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)
|
tablesCursor, err := gorethink.DB("rethinkdb").Table("table_status").Run(s.session)
|
||||||
defer tablesCursor.Close()
|
defer tablesCursor.Close()
|
||||||
var tables []tableStatus
|
var tables []tableStatus
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue