diff --git a/plugins/inputs/sysstat/sysstat.go b/plugins/inputs/sysstat/sysstat.go index af3f6daad..177e632c0 100644 --- a/plugins/inputs/sysstat/sysstat.go +++ b/plugins/inputs/sysstat/sysstat.go @@ -117,6 +117,7 @@ func (s *Sysstat) Gather(acc telegraf.Accumulator) error { return fmt.Errorf("failed to create tmp file: %w", err) } defer os.Remove(tmpfile.Name()) + defer tmpfile.Close() ts := time.Now().Add(time.Duration(s.interval) * time.Second) if err := s.collect(tmpfile.Name()); err != nil {