Fix possible panic if stat is nil

closes #612
This commit is contained in:
Cameron Sparr 2016-01-29 10:11:28 -07:00 committed by Ryan Merrick
parent 374e124864
commit d80c04faec
2 changed files with 10 additions and 1 deletions

View File

@ -14,6 +14,7 @@
- [#599](https://github.com/influxdata/telegraf/issues/599): datadog plugin tags not working. - [#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. - [#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. - [#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] ## v0.10.1 [2016-01-27]

View File

@ -2,6 +2,7 @@ package system
import ( import (
"fmt" "fmt"
"log"
"strings" "strings"
"sync" "sync"
"time" "time"
@ -112,12 +113,19 @@ func (d *Docker) gatherContainer(
} }
go func() { 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 stat := <-statChan
close(done) close(done)
if stat == nil {
return nil
}
// Add labels to tags // Add labels to tags
for k, v := range container.Labels { for k, v := range container.Labels {
tags[k] = v tags[k] = v