From 232c0828837552255085841a652d1e2713ff3b22 Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Tue, 30 Jan 2018 17:55:12 -0500 Subject: [PATCH] Fix system process metricset for kernel processes (#6224) On Linux, kernel processes don't have an exe on disk so the `/proc/[PID]/exe` symlink is broken. When Metricbeat tries to read the symlink it gets an error and it skips the whole process. This adds a check for ENOENT and ignores the error which allows kernel processes to be reported by Metricbeat. This is the error that it fixes. 2018-01-30T20:31:02.512Z DEBUG [processes] process/process.go:443 Skip process pid=12113: error getting process exe for pid=12113: readlink /proc/12113/exe: no such file or directory Fixes #5700 (cherry picked from commit ee38051196a6e288ea9f9c5fcd181add84fff7b3) --- CHANGELOG.asciidoc | 1 + libbeat/metric/system/process/process.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 6a7d5c06c51..56c984d6295 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -297,6 +297,7 @@ https://github.com/elastic/beats/compare/v6.0.1...v6.1.0[View commits] - Fix `ProcState` on Linux and FreeBSD when process names contain parentheses. {pull}5775[5775] - Fix incorrect `Mem.Used` calculation under linux. {pull}5775[5775] - Fix `open_file_descriptor_count` and `max_file_descriptor_count` lost in zookeeper module {pull}5902[5902] +- Fix system process metricset for kernel processes. {issue}5700[5700] *Packetbeat* diff --git a/libbeat/metric/system/process/process.go b/libbeat/metric/system/process/process.go index b5e87d4770b..7d89125b942 100644 --- a/libbeat/metric/system/process/process.go +++ b/libbeat/metric/system/process/process.go @@ -76,7 +76,7 @@ func newProcess(pid int, cmdline string, env common.MapStr) (*Process, error) { } exe := sigar.ProcExe{} - if err := exe.Get(pid); err != nil && !sigar.IsNotImplemented(err) && !os.IsPermission(err) { + if err := exe.Get(pid); err != nil && !sigar.IsNotImplemented(err) && !os.IsPermission(err) && !os.IsNotExist(err) { return nil, fmt.Errorf("error getting process exe for pid=%d: %v", pid, err) }