Fix possible panic if stat is nil

closes #612
This commit is contained in:
Cameron Sparr 2016-01-29 10:11:28 -07:00
parent 40d859354f
commit 93bb679f9d
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.
- [#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]

View File

@ -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