diff --git a/CHANGELOG.md b/CHANGELOG.md index fda444876..ca87a0529 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ changed to just run docker commands in the Makefile. See `make docker-run` and - [#338](https://github.com/influxdb/telegraf/pull/338): Restart Telegraf on package upgrade. Thanks @linsomniac! - [#337](https://github.com/influxdb/telegraf/pull/337): Jolokia plugin, thanks @saiello! - [#350](https://github.com/influxdb/telegraf/pull/350): Amon output. +- [#365](https://github.com/influxdb/telegraf/pull/365): Twemproxy plugin by @codeb2cc - [#317](https://github.com/influxdb/telegraf/issues/317): ZFS plugin, thanks @cornerot! - [#364](https://github.com/influxdb/telegraf/pull/364): Support InfluxDB UDP output. diff --git a/README.md b/README.md index 69378adbb..e25542de8 100644 --- a/README.md +++ b/README.md @@ -190,6 +190,7 @@ Telegraf currently has support for collecting metrics from: * rabbitmq * redis * rethinkdb +* twemproxy * zfs * zookeeper * system diff --git a/plugins/twemproxy/twemproxy.go b/plugins/twemproxy/twemproxy.go index ee794de73..520347280 100644 --- a/plugins/twemproxy/twemproxy.go +++ b/plugins/twemproxy/twemproxy.go @@ -17,18 +17,16 @@ type Twemproxy struct { } type TwemproxyInstance struct { - StatsAddr string - Pools []string + Addr string + Pools []string } var sampleConfig = ` - # Twemproxy plugin config - [twemproxy] - [[twemproxy.instances]] - # Twemproxy stats address and port(NO scheme!) - statsAddr = "10.16.29.1:22222" - # Monitor pool name - pools = ["redis_pool", "mc_pool"] + [[twemproxy.instances]] + # Twemproxy stats address and port (no scheme) + addr = "localhost:22222" + # Monitor pool name + pools = ["redis_pool", "mc_pool"] ` func (t *Twemproxy) SampleConfig() string { @@ -69,7 +67,7 @@ func (t *Twemproxy) Gather(acc plugins.Accumulator) error { func (ti *TwemproxyInstance) Gather( acc plugins.Accumulator, ) error { - conn, err := net.DialTimeout("tcp", ti.StatsAddr, 1*time.Second) + conn, err := net.DialTimeout("tcp", ti.Addr, 1*time.Second) if err != nil { return err } @@ -84,7 +82,7 @@ func (ti *TwemproxyInstance) Gather( } tags := make(map[string]string) - tags["twemproxy"] = ti.StatsAddr + tags["twemproxy"] = ti.Addr ti.processStat(acc, tags, stats) return nil diff --git a/plugins/twemproxy/twemproxy_test.go b/plugins/twemproxy/twemproxy_test.go index 887a770e4..c941cc197 100644 --- a/plugins/twemproxy/twemproxy_test.go +++ b/plugins/twemproxy/twemproxy_test.go @@ -1,16 +1,16 @@ package twemproxy import ( + "encoding/json" "net" "testing" - "encoding/json" "github.com/influxdb/telegraf/testutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -const sampleStatsAddr = "127.0.0.1:22222" +const sampleAddr = "127.0.0.1:22222" const sampleStats = `{ "total_connections": 276448, @@ -61,7 +61,7 @@ const sampleStats = `{ }` func mockTwemproxyServer() (net.Listener, error) { - listener, err := net.Listen("tcp", sampleStatsAddr) + listener, err := net.Listen("tcp", sampleAddr) if err != nil { return nil, err } @@ -87,8 +87,8 @@ func TestGather(t *testing.T) { twemproxy := &Twemproxy{ Instances: []TwemproxyInstance{ TwemproxyInstance{ - StatsAddr: sampleStatsAddr, - Pools: []string{"demo"}, + Addr: sampleAddr, + Pools: []string{"demo"}, }, }, } @@ -104,7 +104,7 @@ func TestGather(t *testing.T) { metrics := []string{"total_connections", "curr_connections", "timestamp"} tags := map[string]string{ - "twemproxy": sampleStatsAddr, + "twemproxy": sampleAddr, "source": sourceData["source"].(string), } for _, m := range metrics {