From c7061e95b69476e46234a35c4ad8a88d8bd23d6c Mon Sep 17 00:00:00 2001 From: Greg Date: Fri, 12 Oct 2018 15:43:06 -0600 Subject: [PATCH] Prevent panic if fileinfo is nil (#4850) --- plugins/inputs/filecount/filecount.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/inputs/filecount/filecount.go b/plugins/inputs/filecount/filecount.go index a0dcd2cb43671..66d5a33fe9b2c 100644 --- a/plugins/inputs/filecount/filecount.go +++ b/plugins/inputs/filecount/filecount.go @@ -139,6 +139,12 @@ func absDuration(x time.Duration) time.Duration { func (fc *FileCount) count(acc telegraf.Accumulator, basedir string, recursive bool) { numFiles := int64(0) walkFn := func(path string, file os.FileInfo, err error) error { + if err != nil { + if os.IsNotExist(err) { + return nil + } + return err + } if path == basedir { return nil }