From cb4387df3f9328e4ff38b8299fe5fbb169576235 Mon Sep 17 00:00:00 2001 From: Ferdi Date: Tue, 30 Apr 2019 00:32:10 +0200 Subject: [PATCH] Verify a process passed by pid_file exists (#5768) --- plugins/inputs/procstat/procstat.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/inputs/procstat/procstat.go b/plugins/inputs/procstat/procstat.go index 2eab899c9..c36970421 100644 --- a/plugins/inputs/procstat/procstat.go +++ b/plugins/inputs/procstat/procstat.go @@ -295,6 +295,10 @@ func (p *Procstat) updateProcesses(pids []PID, tags map[string]string, prevInfo for _, pid := range pids { info, ok := prevInfo[pid] if ok { + // Assumption: if a process has no name, it probably does not exist + if name, _ := info.Name(); name == "" { + continue + } procs[pid] = info } else { proc, err := p.createProcess(pid) @@ -302,6 +306,10 @@ func (p *Procstat) updateProcesses(pids []PID, tags map[string]string, prevInfo // No problem; process may have ended after we found it continue } + // Assumption: if a process has no name, it probably does not exist + if name, _ := proc.Name(); name == "" { + continue + } procs[pid] = proc // Add initial tags