From d80c04faec5239acbcde64c0cbdf556a269c2f1b Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Fri, 29 Jan 2016 10:11:28 -0700 Subject: [PATCH] Fix possible panic if stat is nil closes #612 --- CHANGELOG.md | 1 + plugins/inputs/docker/docker.go | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a651282c..ceea98ed3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - [#599](https://github.com/influxdata/telegraf/issues/599): datadog plugin tags not working. - [#600](https://github.com/influxdata/telegraf/issues/600): datadog measurement/field name parsing is wrong. - [#602](https://github.com/influxdata/telegraf/issues/602): Fix statsd field name templating. +- [#612](https://github.com/influxdata/telegraf/pull/612): Docker input panic fix if stats received are nil. ## v0.10.1 [2016-01-27] diff --git a/plugins/inputs/docker/docker.go b/plugins/inputs/docker/docker.go index 1b95d9dae..6814c190a 100644 --- a/plugins/inputs/docker/docker.go +++ b/plugins/inputs/docker/docker.go @@ -2,6 +2,7 @@ package system import ( "fmt" + "log" "strings" "sync" "time" @@ -112,12 +113,19 @@ func (d *Docker) gatherContainer( } go func() { - d.client.Stats(statOpts) + err := d.client.Stats(statOpts) + if err != nil { + log.Printf("Error getting docker stats: %s\n", err.Error()) + } }() stat := <-statChan close(done) + if stat == nil { + return nil + } + // Add labels to tags for k, v := range container.Labels { tags[k] = v