docker: check type when totalling blkio & net metrics

closes #2027
This commit is contained in:
Cameron Sparr 2016-12-21 10:51:07 +00:00
parent 1cc763e514
commit b77dc90741
2 changed files with 27 additions and 4 deletions

View File

@ -64,6 +64,7 @@ plugins, not just statsd.
- [#1825](https://github.com/influxdata/telegraf/issues/1825): Consul plugin: add check_id as a tag in metrics to avoid overwrites. - [#1825](https://github.com/influxdata/telegraf/issues/1825): Consul plugin: add check_id as a tag in metrics to avoid overwrites.
- [#1973](https://github.com/influxdata/telegraf/issues/1973): Partial fix: logparser CLF pattern with IPv6 addresses. - [#1973](https://github.com/influxdata/telegraf/issues/1973): Partial fix: logparser CLF pattern with IPv6 addresses.
- [#1975](https://github.com/influxdata/telegraf/issues/1975) & [#2102](https://github.com/influxdata/telegraf/issues/2102): Fix thread-safety when using multiple instances of the statsd input plugin. - [#1975](https://github.com/influxdata/telegraf/issues/1975) & [#2102](https://github.com/influxdata/telegraf/issues/2102): Fix thread-safety when using multiple instances of the statsd input plugin.
- [#2027](https://github.com/influxdata/telegraf/issues/2027): docker input: interface conversion panic fix.
## v1.1.2 [2016-12-12] ## v1.1.2 [2016-12-12]

View File

@ -368,11 +368,22 @@ func gatherContainerStats(
if field == "container_id" { if field == "container_id" {
continue continue
} }
var uintV uint64
switch v := value.(type) {
case uint64:
uintV = v
case int64:
uintV = uint64(v)
default:
continue
}
_, ok := totalNetworkStatMap[field] _, ok := totalNetworkStatMap[field]
if ok { if ok {
totalNetworkStatMap[field] = totalNetworkStatMap[field].(uint64) + value.(uint64) totalNetworkStatMap[field] = totalNetworkStatMap[field].(uint64) + uintV
} else { } else {
totalNetworkStatMap[field] = value totalNetworkStatMap[field] = uintV
} }
} }
} }
@ -491,11 +502,22 @@ func gatherBlockIOMetrics(
if field == "container_id" { if field == "container_id" {
continue continue
} }
var uintV uint64
switch v := value.(type) {
case uint64:
uintV = v
case int64:
uintV = uint64(v)
default:
continue
}
_, ok := totalStatMap[field] _, ok := totalStatMap[field]
if ok { if ok {
totalStatMap[field] = totalStatMap[field].(uint64) + value.(uint64) totalStatMap[field] = totalStatMap[field].(uint64) + uintV
} else { } else {
totalStatMap[field] = value totalStatMap[field] = uintV
} }
} }
} }