influxdb input: Use non-panicking type assertion

closes #1268
This commit is contained in:
Cameron Sparr 2016-05-25 13:31:09 +01:00
parent 58f2ba1247
commit 5fe7e6e40e
2 changed files with 39 additions and 36 deletions

View File

@ -27,6 +27,7 @@ time before a new metric is included by the plugin.
- [#1252](https://github.com/influxdata/telegraf/pull/1252): Fix systemd service. Thanks @zbindenren! - [#1252](https://github.com/influxdata/telegraf/pull/1252): Fix systemd service. Thanks @zbindenren!
- [#1221](https://github.com/influxdata/telegraf/pull/1221): Fix influxdb n_shards counter. - [#1221](https://github.com/influxdata/telegraf/pull/1221): Fix influxdb n_shards counter.
- [#1258](https://github.com/influxdata/telegraf/pull/1258): Fix potential kernel plugin integer parse error. - [#1258](https://github.com/influxdata/telegraf/pull/1258): Fix potential kernel plugin integer parse error.
- [#1268](https://github.com/influxdata/telegraf/pull/1268): Fix potential influxdb input type assertion panic.
## v0.13.1 [2016-05-24] ## v0.13.1 [2016-05-24]

View File

@ -157,7 +157,8 @@ func (i *InfluxDB) gatherURL(
return err return err
} }
if key.(string) == "memstats" { if keyStr, ok := key.(string); ok {
if keyStr == "memstats" {
var m memstats var m memstats
if err := dec.Decode(&m); err != nil { if err := dec.Decode(&m); err != nil {
continue continue
@ -195,6 +196,7 @@ func (i *InfluxDB) gatherURL(
"url": url, "url": url,
}) })
} }
}
// Attempt to parse a whole object into a point. // Attempt to parse a whole object into a point.
// It might be a non-object, like a string or array. // It might be a non-object, like a string or array.