parent
e167b72b16
commit
20fbfc7006
|
@ -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!
|
- [#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!
|
- [#337](https://github.com/influxdb/telegraf/pull/337): Jolokia plugin, thanks @saiello!
|
||||||
- [#350](https://github.com/influxdb/telegraf/pull/350): Amon output.
|
- [#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!
|
- [#317](https://github.com/influxdb/telegraf/issues/317): ZFS plugin, thanks @cornerot!
|
||||||
- [#364](https://github.com/influxdb/telegraf/pull/364): Support InfluxDB UDP output.
|
- [#364](https://github.com/influxdb/telegraf/pull/364): Support InfluxDB UDP output.
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,7 @@ Telegraf currently has support for collecting metrics from:
|
||||||
* rabbitmq
|
* rabbitmq
|
||||||
* redis
|
* redis
|
||||||
* rethinkdb
|
* rethinkdb
|
||||||
|
* twemproxy
|
||||||
* zfs
|
* zfs
|
||||||
* zookeeper
|
* zookeeper
|
||||||
* system
|
* system
|
||||||
|
|
|
@ -17,18 +17,16 @@ type Twemproxy struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type TwemproxyInstance struct {
|
type TwemproxyInstance struct {
|
||||||
StatsAddr string
|
Addr string
|
||||||
Pools []string
|
Pools []string
|
||||||
}
|
}
|
||||||
|
|
||||||
var sampleConfig = `
|
var sampleConfig = `
|
||||||
# Twemproxy plugin config
|
[[twemproxy.instances]]
|
||||||
[twemproxy]
|
# Twemproxy stats address and port (no scheme)
|
||||||
[[twemproxy.instances]]
|
addr = "localhost:22222"
|
||||||
# Twemproxy stats address and port(NO scheme!)
|
# Monitor pool name
|
||||||
statsAddr = "10.16.29.1:22222"
|
pools = ["redis_pool", "mc_pool"]
|
||||||
# Monitor pool name
|
|
||||||
pools = ["redis_pool", "mc_pool"]
|
|
||||||
`
|
`
|
||||||
|
|
||||||
func (t *Twemproxy) SampleConfig() string {
|
func (t *Twemproxy) SampleConfig() string {
|
||||||
|
@ -69,7 +67,7 @@ func (t *Twemproxy) Gather(acc plugins.Accumulator) error {
|
||||||
func (ti *TwemproxyInstance) Gather(
|
func (ti *TwemproxyInstance) Gather(
|
||||||
acc plugins.Accumulator,
|
acc plugins.Accumulator,
|
||||||
) error {
|
) error {
|
||||||
conn, err := net.DialTimeout("tcp", ti.StatsAddr, 1*time.Second)
|
conn, err := net.DialTimeout("tcp", ti.Addr, 1*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -84,7 +82,7 @@ func (ti *TwemproxyInstance) Gather(
|
||||||
}
|
}
|
||||||
|
|
||||||
tags := make(map[string]string)
|
tags := make(map[string]string)
|
||||||
tags["twemproxy"] = ti.StatsAddr
|
tags["twemproxy"] = ti.Addr
|
||||||
ti.processStat(acc, tags, stats)
|
ti.processStat(acc, tags, stats)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
package twemproxy
|
package twemproxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
"github.com/influxdb/telegraf/testutil"
|
"github.com/influxdb/telegraf/testutil"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
const sampleStatsAddr = "127.0.0.1:22222"
|
const sampleAddr = "127.0.0.1:22222"
|
||||||
|
|
||||||
const sampleStats = `{
|
const sampleStats = `{
|
||||||
"total_connections": 276448,
|
"total_connections": 276448,
|
||||||
|
@ -61,7 +61,7 @@ const sampleStats = `{
|
||||||
}`
|
}`
|
||||||
|
|
||||||
func mockTwemproxyServer() (net.Listener, error) {
|
func mockTwemproxyServer() (net.Listener, error) {
|
||||||
listener, err := net.Listen("tcp", sampleStatsAddr)
|
listener, err := net.Listen("tcp", sampleAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -87,8 +87,8 @@ func TestGather(t *testing.T) {
|
||||||
twemproxy := &Twemproxy{
|
twemproxy := &Twemproxy{
|
||||||
Instances: []TwemproxyInstance{
|
Instances: []TwemproxyInstance{
|
||||||
TwemproxyInstance{
|
TwemproxyInstance{
|
||||||
StatsAddr: sampleStatsAddr,
|
Addr: sampleAddr,
|
||||||
Pools: []string{"demo"},
|
Pools: []string{"demo"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ func TestGather(t *testing.T) {
|
||||||
|
|
||||||
metrics := []string{"total_connections", "curr_connections", "timestamp"}
|
metrics := []string{"total_connections", "curr_connections", "timestamp"}
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"twemproxy": sampleStatsAddr,
|
"twemproxy": sampleAddr,
|
||||||
"source": sourceData["source"].(string),
|
"source": sourceData["source"].(string),
|
||||||
}
|
}
|
||||||
for _, m := range metrics {
|
for _, m := range metrics {
|
||||||
|
|
Loading…
Reference in New Issue