From 85dee02a3b997aea24e2613173d897bb0aaa73e5 Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Tue, 10 May 2016 13:27:18 -0700 Subject: [PATCH] snmp plugin: change host -> snmp_host closes #1156 --- CHANGELOG.md | 10 +++- etc/telegraf.conf | 4 +- plugins/inputs/snmp/snmp.go | 2 +- plugins/inputs/snmp/snmp_test.go | 86 ++++++++++++++++---------------- 4 files changed, 55 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8338386d..0e50a1c7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,7 +48,15 @@ based on _prefix_ in addition to globs. This means that a filter like - disque: `host -> disque_host` - rethinkdb: `host -> rethinkdb_host` -- **Breaking Change**: The `win_perf_counters` input has been changed to sanitize field names, replacing `/Sec` and `/sec` with `_persec`, as well as spaces with underscores. This is needed because Graphite doesn't like slashes and spaces, and was failing to accept metrics that had them. The `/[sS]ec` -> `_persec` is just to make things clearer and uniform. +- **Breaking Change**: The `win_perf_counters` input has been changed to +sanitize field names, replacing `/Sec` and `/sec` with `_persec`, as well as +spaces with underscores. This is needed because Graphite doesn't like slashes +and spaces, and was failing to accept metrics that had them. +The `/[sS]ec` -> `_persec` is just to make things clearer and uniform. + +- **Breaking Change**: snmp plugin. The `host` tag of the snmp plugin has been +changed to the `snmp_host` tag. + - The `disk` input plugin can now be configured with the `HOST_MOUNT_PREFIX` environment variable. This value is prepended to any mountpaths discovered before retrieving stats. It is not included on the report path. This is necessary for reporting host disk stats when running from within a container. diff --git a/etc/telegraf.conf b/etc/telegraf.conf index ee6b69aa0..64eace970 100644 --- a/etc/telegraf.conf +++ b/etc/telegraf.conf @@ -638,8 +638,8 @@ # # ## If no servers are specified, then default to 127.0.0.1:1936 # servers = ["http://myhaproxy.com:1936", "http://anotherhaproxy.com:1936"] -# ## Or you can also use local socket(not work yet) -# ## servers = ["socket://run/haproxy/admin.sock"] +# ## Or you can also use local socket +# ## servers = ["socket:/run/haproxy/admin.sock"] # # HTTP/HTTPS request given an address a method and a timeout diff --git a/plugins/inputs/snmp/snmp.go b/plugins/inputs/snmp/snmp.go index 784abd9fb..c7ceb83d8 100644 --- a/plugins/inputs/snmp/snmp.go +++ b/plugins/inputs/snmp/snmp.go @@ -792,7 +792,7 @@ func (h *Host) HandleResponse( // Because the result oid is equal to inputs.snmp.get section field_name = oid.Name } - tags["host"], _, _ = net.SplitHostPort(h.Address) + tags["snmp_host"], _, _ = net.SplitHostPort(h.Address) fields := make(map[string]interface{}) fields[string(field_name)] = variable.Value diff --git a/plugins/inputs/snmp/snmp_test.go b/plugins/inputs/snmp/snmp_test.go index 5822926dd..2faaa1408 100644 --- a/plugins/inputs/snmp/snmp_test.go +++ b/plugins/inputs/snmp/snmp_test.go @@ -102,8 +102,8 @@ func TestSNMPGet1(t *testing.T) { "oid1": uint(543846), }, map[string]string{ - "unit": "octets", - "host": testutil.GetLocalHost(), + "unit": "octets", + "snmp_host": testutil.GetLocalHost(), }, ) } @@ -140,8 +140,8 @@ func TestSNMPGet2(t *testing.T) { "ifNumber": int(4), }, map[string]string{ - "instance": "0", - "host": testutil.GetLocalHost(), + "instance": "0", + "snmp_host": testutil.GetLocalHost(), }, ) } @@ -180,9 +180,9 @@ func TestSNMPGet3(t *testing.T) { "ifSpeed": uint(10000000), }, map[string]string{ - "unit": "octets", - "instance": "1", - "host": testutil.GetLocalHost(), + "unit": "octets", + "instance": "1", + "snmp_host": testutil.GetLocalHost(), }, ) } @@ -222,9 +222,9 @@ func TestSNMPEasyGet4(t *testing.T) { "ifSpeed": uint(10000000), }, map[string]string{ - "unit": "octets", - "instance": "1", - "host": testutil.GetLocalHost(), + "unit": "octets", + "instance": "1", + "snmp_host": testutil.GetLocalHost(), }, ) @@ -234,8 +234,8 @@ func TestSNMPEasyGet4(t *testing.T) { "ifNumber": int(4), }, map[string]string{ - "instance": "0", - "host": testutil.GetLocalHost(), + "instance": "0", + "snmp_host": testutil.GetLocalHost(), }, ) } @@ -275,9 +275,9 @@ func TestSNMPEasyGet5(t *testing.T) { "ifSpeed": uint(10000000), }, map[string]string{ - "unit": "octets", - "instance": "1", - "host": testutil.GetLocalHost(), + "unit": "octets", + "instance": "1", + "snmp_host": testutil.GetLocalHost(), }, ) @@ -287,8 +287,8 @@ func TestSNMPEasyGet5(t *testing.T) { "ifNumber": int(4), }, map[string]string{ - "instance": "0", - "host": testutil.GetLocalHost(), + "instance": "0", + "snmp_host": testutil.GetLocalHost(), }, ) } @@ -320,8 +320,8 @@ func TestSNMPEasyGet6(t *testing.T) { "ifNumber": int(4), }, map[string]string{ - "instance": "0", - "host": testutil.GetLocalHost(), + "instance": "0", + "snmp_host": testutil.GetLocalHost(), }, ) } @@ -360,9 +360,9 @@ func TestSNMPBulk1(t *testing.T) { "ifOutOctets": uint(543846), }, map[string]string{ - "unit": "octets", - "instance": "1", - "host": testutil.GetLocalHost(), + "unit": "octets", + "instance": "1", + "snmp_host": testutil.GetLocalHost(), }, ) @@ -372,9 +372,9 @@ func TestSNMPBulk1(t *testing.T) { "ifOutOctets": uint(26475179), }, map[string]string{ - "unit": "octets", - "instance": "2", - "host": testutil.GetLocalHost(), + "unit": "octets", + "instance": "2", + "snmp_host": testutil.GetLocalHost(), }, ) @@ -384,9 +384,9 @@ func TestSNMPBulk1(t *testing.T) { "ifOutOctets": uint(108963968), }, map[string]string{ - "unit": "octets", - "instance": "3", - "host": testutil.GetLocalHost(), + "unit": "octets", + "instance": "3", + "snmp_host": testutil.GetLocalHost(), }, ) @@ -396,9 +396,9 @@ func TestSNMPBulk1(t *testing.T) { "ifOutOctets": uint(12991453), }, map[string]string{ - "unit": "octets", - "instance": "36", - "host": testutil.GetLocalHost(), + "unit": "octets", + "instance": "36", + "snmp_host": testutil.GetLocalHost(), }, ) } @@ -438,9 +438,9 @@ func dTestSNMPBulk2(t *testing.T) { "ifOutOctets": uint(543846), }, map[string]string{ - "unit": "octets", - "instance": "1", - "host": testutil.GetLocalHost(), + "unit": "octets", + "instance": "1", + "snmp_host": testutil.GetLocalHost(), }, ) @@ -450,9 +450,9 @@ func dTestSNMPBulk2(t *testing.T) { "ifOutOctets": uint(26475179), }, map[string]string{ - "unit": "octets", - "instance": "2", - "host": testutil.GetLocalHost(), + "unit": "octets", + "instance": "2", + "snmp_host": testutil.GetLocalHost(), }, ) @@ -462,9 +462,9 @@ func dTestSNMPBulk2(t *testing.T) { "ifOutOctets": uint(108963968), }, map[string]string{ - "unit": "octets", - "instance": "3", - "host": testutil.GetLocalHost(), + "unit": "octets", + "instance": "3", + "snmp_host": testutil.GetLocalHost(), }, ) @@ -474,9 +474,9 @@ func dTestSNMPBulk2(t *testing.T) { "ifOutOctets": uint(12991453), }, map[string]string{ - "unit": "octets", - "instance": "36", - "host": testutil.GetLocalHost(), + "unit": "octets", + "instance": "36", + "snmp_host": testutil.GetLocalHost(), }, ) }