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

Is there a way to use this to get overall system usage over all processes? #3

Open
replaysMike opened this issue May 19, 2023 · 4 comments
Labels
question Further information is requested

Comments

@replaysMike
Copy link

I'm not sure if you've already got something for this, but it doesn't look possible unless GetByProcess() could take in a process, and not just assume the current process.

@replaysMike
Copy link
Author

still digesting most of the code, but looks to be a limitation of getrusage that doesn't expose a way to do it by process id.

@devizer
Copy link
Owner

devizer commented May 28, 2023

I'm not sure if you've already got something for this, but it doesn't look possible unless GetByProcess() could take in a process, and not just assume the current process.

Why not System.Diagnostics.Process' properties:
https://learn.microsoft.com/ru-ru/dotnet/api/system.diagnostics.process.userprocessortime
https://learn.microsoft.com/ru-ru/dotnet/api/system.diagnostics.process.totalprocessortime

@devizer
Copy link
Owner

devizer commented May 28, 2023

still digesting most of the code, but looks to be a limitation of getrusage that doesn't expose a way to do it by process id.

getrusage is Linux implementation.
For Linux please take a look at https://github.com/devizer/Universe.NativeLinux.Interop, https://www.nuget.org/packages/Universe.LinuxTaskStats
The metrics include CPU Usage, counters and delays caused by IO, swap-in, memory reclaim, and memory trashing.

@devizer devizer added the question Further information is requested label May 28, 2023
@replaysMike
Copy link
Author

I ended up getting everything working surprisingly well using GetSystemTimes (Win32) for the Windows side, and System.Diagnostics.Process on Linux side. They both ended up mimicking the same output as Task manager (or very, very close). Your code helped me get through figuring it out - I haven't tested MacOS yet though. Nice repo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants