Skip to content

Commit

Permalink
Twemproxy go fmt and bug fixups, CHANGELOG, README
Browse files Browse the repository at this point in the history
  • Loading branch information
codeb2cc authored and Jeffrey Allen committed Nov 18, 2015
1 parent 6467fcd commit 934aaf8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ Telegraf currently has support for collecting metrics from:
* rabbitmq
* redis
* rethinkdb
* twemproxy
* zfs
* zookeeper
* system
Expand Down
20 changes: 9 additions & 11 deletions plugins/twemproxy/twemproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions plugins/twemproxy/twemproxy_test.go
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
}
Expand All @@ -87,8 +87,8 @@ func TestGather(t *testing.T) {
twemproxy := &Twemproxy{
Instances: []TwemproxyInstance{
TwemproxyInstance{
StatsAddr: sampleStatsAddr,
Pools: []string{"demo"},
Addr: sampleAddr,
Pools: []string{"demo"},
},
},
}
Expand All @@ -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 {
Expand Down

0 comments on commit 934aaf8

Please sign in to comment.