diff --git a/CHANGELOG.md b/CHANGELOG.md index 68262c98d..8cb3e6196 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - [#2146](https://github.com/influxdata/telegraf/issues/2146): Fix potential panic in aggregator plugin metric maker. - [#1843](https://github.com/influxdata/telegraf/pull/1843) & [#1668](https://github.com/influxdata/telegraf/issues/1668): Add optional ability to define PID as a tag. - [#1730](https://github.com/influxdata/telegraf/issues/1730): Fix win_perf_counters not gathering non-English counters. +- [#2061](https://github.com/influxdata/telegraf/issues/2061): Fix panic when file stat info cannot be collected due to permissions or other issue(s). ## v1.1.2 [2016-12-12] diff --git a/plugins/inputs/filestat/filestat.go b/plugins/inputs/filestat/filestat.go index 938c12e34..83f511a84 100644 --- a/plugins/inputs/filestat/filestat.go +++ b/plugins/inputs/filestat/filestat.go @@ -4,6 +4,7 @@ import ( "crypto/md5" "fmt" "io" + "log" "os" "github.com/influxdata/telegraf" @@ -78,8 +79,14 @@ func (f *FileStat) Gather(acc telegraf.Accumulator) error { "file": fileName, } fields := map[string]interface{}{ - "exists": int64(1), - "size_bytes": fileInfo.Size(), + "exists": int64(1), + } + + if fileInfo == nil { + log.Printf("E! Unable to get info for file [%s], possible permissions issue", + fileName) + } else { + fields["size_bytes"] = fileInfo.Size() } if f.Md5 {