Skip to content
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

Correctly cast Darwin memory info #1060

Merged
merged 2 commits into from Sep 7, 2018
Merged

Correctly cast Darwin memory info #1060

merged 2 commits into from Sep 7, 2018

Conversation

SuperQ
Copy link
Member

@SuperQ SuperQ commented Sep 5, 2018

  • Cast stats to float64 before doing math on them to avoid integer
    wrapping.
  • Remove invalid _total suffix from gauge values.

Fixes: #855

Signed-off-by: Ben Kochie superq@gmail.com

@SuperQ
Copy link
Member Author

SuperQ commented Sep 5, 2018

This also fixes the following promtool check metrics errors:

$ curl -s http://localhost:9100/metrics | promtool check metrics
node_memory_active_bytes_total non-counter metrics should not have "_total" suffix
node_memory_bytes_total non-counter metrics should not have "_total" suffix
node_memory_free_bytes_total non-counter metrics should not have "_total" suffix
node_memory_inactive_bytes_total non-counter metrics should not have "_total" suffix
node_memory_swapped_in_pages_total non-counter metrics should not have "_total" suffix
node_memory_swapped_out_pages_total non-counter metrics should not have "_total" suffix
node_memory_wired_bytes_total non-counter metrics should not have "_total" suffix

"inactive_bytes": ps * float64(vmstat.inactive_count),
"wired_bytes": ps * float64(vmstat.wire_count),
"free_bytes": ps * float64(vmstat.free_count),
"swapped_in_pages": ps * float64(vmstat.pageins),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these two are counters

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I came to the same conclusion.

* Cast stats to float64 before doing math on them to avoid integer
wrapping.
* Remove invalid `_total` suffix from gauge values.
* Handle counters in `meminfo.go`.

Signed-off-by: Ben Kochie <superq@gmail.com>
@SuperQ
Copy link
Member Author

SuperQ commented Sep 5, 2018

Fixed up the metric type handling.

Signed-off-by: Ben Kochie <superq@gmail.com>
@SuperQ SuperQ merged commit ebdd524 into master Sep 7, 2018
@SuperQ SuperQ deleted the superq/darwin_meminfo branch September 7, 2018 20:27
oblitorum pushed a commit to shatteredsilicon/node_exporter that referenced this pull request Apr 9, 2024
* Correctly cast Darwin memory info

* Cast stats to float64 before doing math on them to avoid integer
wrapping.
* Remove invalid `_total` suffix from gauge values.
* Handle counters in `meminfo.go`.

Signed-off-by: Ben Kochie <superq@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weird Memory Readings on macOS
3 participants