Skip to content

Commit

Permalink
Fix system process metricset for kernel processes (elastic#6224)
Browse files Browse the repository at this point in the history
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 elastic#5700

(cherry picked from commit ee38051)
  • Loading branch information
andrewkroh committed Mar 29, 2018
1 parent a5e0b52 commit 232c082
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
2 changes: 1 addition & 1 deletion libbeat/metric/system/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 232c082

Please sign in to comment.