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

Expose Swap/Paging usage per device #1115

Closed
tbarker25 opened this issue Aug 6, 2021 · 4 comments
Closed

Expose Swap/Paging usage per device #1115

tbarker25 opened this issue Aug 6, 2021 · 4 comments

Comments

@tbarker25
Copy link
Contributor

tbarker25 commented Aug 6, 2021

Is your feature request related to a problem? Please describe.
As part of OpenTelemetry collection, we would like to expose the swap usage per device. for more specifics on our use-case see: https://github.com/open-telemetry/opentelemetry-collector/issues/3447

Describe the solution you'd like
mem.VirtualMemory() (or another method) to expose swap usage on a per device basis.

Describe alternatives you've considered
Implementing this in the otel-collector instead. This is certainly possible, but we would prefer the logic be in gopsutil.

Additional context
Here is an example of collecting this in Linux: https://github.com/tbarker25/opentelemetry-collector/blob/swap-devices/receiver/hostmetricsreceiver/internal/scraper/pagingscraper/pagefile_linux.go

@tbarker25
Copy link
Contributor Author

if this is a change you are amenable to then we're willing to write a PR (at least for the OSs we care about)

@shirou
Copy link
Owner

shirou commented Aug 7, 2021

gopsutil is a port from psutil. psutil does not have such a device level swap usage. so, basically "No".
However, from my personal interest, I think that this feature can be added.

To add, we should discuss about those.

  1. Implements or survey how to implements at least Linux, Windows, Darwin, FreeBSD.
  2. Define the function as completely independent of the psutil function

For example, from my quick survey, FreeBSD can get device level swap usage by using swapctl like this

[freebsdhost]%swapctl -l
Device:       1024-blocks     Used:
/dev/vtbd0p2    1048576    531276

We need more information on Darwin to proceed discussion.

For 2, create for example, mem.SwapDevices() (needs more good name!) function and implements those. then, this does not affects current API.

@tbarker25
Copy link
Contributor Author

I had a look around for a way to do this on Darwin and couldn't find one. It might not be possible.

Are we able to proceed leaving Darwin as unimplemented, or this a showstopper?

@tbarker25
Copy link
Contributor Author

I've put together a PR for this. I did not manage to find a way to implement this for Darwin, but did find a way for Linux, FreeBSD, OpenBSD, Windows and Solaris.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants