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

Use psutil instead of top output. #20

Open
dsluo opened this issue Aug 31, 2019 · 7 comments
Open

Use psutil instead of top output. #20

dsluo opened this issue Aug 31, 2019 · 7 comments
Labels
compatibility Issue is related to compatibility. enhancement New feature or request

Comments

@dsluo
Copy link
Contributor

dsluo commented Aug 31, 2019

This will ensure better compatibility as psutil takes care of all that for us and a better API as top wasn't really meant to be machine readable anyway.

@dsluo dsluo added enhancement New feature or request compatibility Issue is related to compatibility. labels Aug 31, 2019
@anirudhajith
Copy link
Owner

@dsluo I compared the output of psutil on macOS and on Ubuntu Linux a couple of days ago. Sadly, they're not consistent either...

@anirudhajith anirudhajith pinned this issue Sep 1, 2019
@dsluo
Copy link
Contributor Author

dsluo commented Sep 3, 2019

@anirudhajith What do you mean? Can you provide an example?

@anirudhajith
Copy link
Owner

@dsluo I stand corrected. I checked psutil's output on my friend's MacBook. It's consistent for the most part. WE ARE GO FOR PSUTIL!

@anirudhajith
Copy link
Owner

@dsluo
I've attempted a port to psutil on a new branch: d753165
This should work on all platforms since we're not relying on the precise format of the output of top.

@dsluo
Copy link
Contributor Author

dsluo commented Sep 6, 2019

@anirudhajith alright, I'm gonna pull the branch and make some changes.

@dsluo
Copy link
Contributor Author

dsluo commented Sep 6, 2019

@anirudhajith according to psutil's docs, the first time that cpu_percent is retrieved, it will always return 0% CPU usage. As such all processes from when you iterate through psutil.process_iter will have 0% CPU.

@dsluo
Copy link
Contributor Author

dsluo commented Sep 6, 2019

@anirudhajith I've pushed some changes to the psutil branch that should address this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Issue is related to compatibility. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants