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
Add swapdevices method #1120
Add swapdevices method #1120
Conversation
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.
Thank you for your great contribution. LGTM, but I want to ask some of changes. Thanks!
} | ||
|
||
func SwapDevicesWithContext(ctx context.Context) ([]*SwapDevice, error) { | ||
output, err := exec.Command(swapCommand, "-lk").Output() |
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.
Could you use exec.LookPath
like here?
} | ||
|
||
func SwapDevicesWithContext(ctx context.Context) ([]*SwapDevice, error) { | ||
f, err := os.Open(swapsFilePath) |
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.
Could you change to common.HostProc("swaps")
like here? It can enable to run on container environment.
} | ||
|
||
func SwapDevicesWithContext(ctx context.Context) ([]*SwapDevice, error) { | ||
output, err := exec.Command(swapsCommand, "-l").Output() |
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.
same here, please use exec.LookPath
.
Hi @shirou. I work with @tbarker25 and am continuing his work in #1131 (because he will be away from work for the next several weeks). I've incorporated your feedback in that PR, please let me know if you're okay with merging it. |
Add swapdevices method (continued from #1120)
Add a mem.SwapDevices() method to get swap stats per device. See #1115.
Unfortunately I could not find a way to implement this in Darwin, so I have left that as unimplemented.
Note that I have run these tests on the following OSs and verified that they passed: Linux, MacOS, FreeBSD, OpenBSD and Solaris.