-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buddyinfo: Add support for /proc/buddyinfo for linux free memory fragmentation. #454
Conversation
This may be a good subsystem to add to: https://github.com/prometheus/procfs. That way, the core parsing, tests, and logic can remain there, while node_exporter can simply use the appropriate functions from That said, this is just my suggestion, and I'll review this under the assumption that the code will remain here. Can always move it around later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll also want to run the node_exporter and add your new metrics to the e2e-output.txt to verify that all the metrics expected are received.
collector/buddyinfo.go
Outdated
@@ -0,0 +1,114 @@ | |||
// Copyright 2015 The Prometheus Authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collector/buddyinfo_test.go
Outdated
@@ -0,0 +1,40 @@ | |||
// Copyright 2015 The Prometheus Authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collector/buddyinfo.go
Outdated
var err error | ||
line := scanner.Text() | ||
parts := strings.Fields(string(line)) | ||
node := strings.TrimRight(parts[1], ",") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need a bounds-check on parts
to avoid panics here in case of malformed file. I know it's quite unlikely but better to add a couple safeguards (and tests to ensure they work) than to have node_exporter start panicking later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed this when I moved it over to the procfs library.
Oh! This should also be documented in the README under "disabled by default". |
Thanks for the feedback, I'll look into it and resubmit. |
Cool, I'll review this again once the new version of procfs is vendored and build is green. |
/prod/buddyinfo returns data on the free blocks fragments available for use from the kernel. This data is useful when diagnosing possible memory fragmentation. More info can be found in: * https://lwn.net/Articles/7868/ * https://andorian.blogspot.com/2014/03/making-sense-of-procbuddyinfo.html
Done, should I update any other files, like AUTHORS.md or CHAGELOG.md? |
If this is your first contribution, just go ahead and update AUTHORS. The maintainers will take care of the rest! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Update minimum supported version to 1.17. * Update Go modules. * Enable dependabot. Signed-off-by: SuperQ <superq@gmail.com>
/proc/buddyinfo returns data on the free blocks fragments available
for use from the kernel. This data is useful when diagnosing
possible memory fragmentation.
More info can be found in: