memcached: fix when a value contains a space

Fixes #137
This commit is contained in:
Bruno Bigras 2015-08-25 14:17:15 -04:00
parent bd85a36cb1
commit 6bc5ab82b4
2 changed files with 4 additions and 4 deletions

View File

@ -3,6 +3,7 @@
### Features ### Features
- [#133](https://github.com/influxdb/telegraf/pull/133): Add plugin.Gather error logging. Thanks @nickscript0! - [#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. - [#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 ### Bugfixes
- [#128](https://github.com/influxdb/telegraf/issues/128): system_load measurement missing. - [#128](https://github.com/influxdb/telegraf/issues/128): system_load measurement missing.

View File

@ -100,14 +100,13 @@ func (m *Memcached) gatherServer(address string, acc plugins.Accumulator) error
break break
} }
// Read values // Read values
var name, value string s := bytes.SplitN(line, []byte(" "), 3)
n, errScan := fmt.Sscanf(string(line), "STAT %s %s\r\n", &name, &value) if len(s) != 3 || !bytes.Equal(s[0], []byte("STAT")) {
if errScan != nil || n != 2 {
return fmt.Errorf("unexpected line in stats response: %q", line) return fmt.Errorf("unexpected line in stats response: %q", line)
} }
// Save values // Save values
values[name] = value values[string(s[1])] = string(s[2])
} }
// //