From c0f67db4258024f90a2d5292f82124acf45a40c4 Mon Sep 17 00:00:00 2001 From: shizhx Date: Wed, 30 Aug 2023 21:54:22 +0800 Subject: [PATCH] fix(inputs.sysstat): Remove tmpfile to avoid file-descriptor leak (#13833) --- plugins/inputs/sysstat/sysstat.go | 1 + 1 file changed, 1 insertion(+) 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 {