Allow Linux process command names longer than 15 chars#2062
Open
lewisdoesstuff wants to merge 1 commit intonewrelic:masterfrom
Open
Allow Linux process command names longer than 15 chars#2062lewisdoesstuff wants to merge 1 commit intonewrelic:masterfrom
lewisdoesstuff wants to merge 1 commit intonewrelic:masterfrom
Conversation
- snapshot_linux.go - `Command()` now checks the length of the processes `command` value - If less than 15 chars, or the agent is not running as root, returns the value read from `/proc/<pid>/stat` - If > 15, and we're running as root, returns the base name of the executable linked to `/proc/<pid>/exe`
Contributor
|
Hi @lewisdoesstuff |
Contributor
|
Hi @lewisdoesstuff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently,
ProcessSampledata on Linux hosts has a 15 character limit on thecommandNamevalue.This is a limitation of the kernel - the
commvalue read from/proc/<pid>/statis limited toTASK_COMM_LEN(16, including null byte).This isn't the end of the world when collecting all processes, but causes issues when trying to limit the collected samples via
include_matching_metrics. You can't currently matchsome-long-process-name-1without using a wildcard to cover everything after the 15th character. Ifsome-long-process-name-2is also running, both of these will be sampled.I've updated the
pw.Command()method (snapshot_linux.go) to handle this.If the process name (from
/proc/<pid>/stat) is less than 15 chars, then we return that.If it's 15, it could be truncated, so we use
pw.process.Exe()to read the link at/proc/<pid>/exe, returning the base name.This requires read permissions on the linked executable, so if the agent isn't running as root, the (possibly truncated) value is returned.
Comparison in events in

ProcessSample- Top: patched, bottom: 1.30.0