From 8a6665c03f4a119a79fe11dade903b7bb5fc5642 Mon Sep 17 00:00:00 2001 From: Bruno Bigras Date: Tue, 25 Aug 2015 14:17:15 -0400 Subject: [PATCH] memcached: fix when a value contains a space Fixes #137 Closes #139 --- CHANGELOG.md | 1 + plugins/memcached/memcached.go | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 931798b4b..a26ed0ce0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Features - [#133](https://github.com/influxdb/telegraf/pull/133): Add plugin.Gather error logging. Thanks @nickscript0! - [#136](https://github.com/influxdb/telegraf/issues/136): Add a -usage flag for printing usage of a single plugin. +- [#137](https://github.com/influxdb/telegraf/issues/137): Memcached: fix when a value contains a space ### Bugfixes - [#128](https://github.com/influxdb/telegraf/issues/128): system_load measurement missing. diff --git a/plugins/memcached/memcached.go b/plugins/memcached/memcached.go index 802fae35d..7035bde04 100644 --- a/plugins/memcached/memcached.go +++ b/plugins/memcached/memcached.go @@ -100,14 +100,13 @@ func (m *Memcached) gatherServer(address string, acc plugins.Accumulator) error break } // Read values - var name, value string - n, errScan := fmt.Sscanf(string(line), "STAT %s %s\r\n", &name, &value) - if errScan != nil || n != 2 { + s := bytes.SplitN(line, []byte(" "), 3) + if len(s) != 3 || !bytes.Equal(s[0], []byte("STAT")) { return fmt.Errorf("unexpected line in stats response: %q", line) } // Save values - values[name] = value + values[string(s[1])] = string(s[2]) } //