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
Implement linux load average #384
Comments
From g.rodola on May 22, 2013 14:19:26
Status: WontFix |
@giampaolo hmm what if stdlib/libc doesn't have getloadavg? For example some libc on Android doesn't implement this. You can easily reproduce this using Termux app (available on Google Play). Edit: if SELinux is enforced, you need root to read /proc/loadavg |
In that case if hasattr(os, "getloadavg") or hasattr(_psplatform, "getloadavg"):
# Perform this hasattr check once on import time to either use the
# platform based code or proxy straight from the os module.
if hasattr(os, "getloadavg"):
getloadavg = os.getloadavg
else:
getloadavg = _psplatform.getloadavg
__all__.append("getloadavg") |
And yeah that's error I got... 😅 But there's some alternative without root, that you can get load average from |
Does psutil work on Android? |
Hmm how to test it all? I just do
(This is expected from psutil code you mentioned before) |
|
Ok I run it on my 2 devices (both non-root and root shell), but the errors seems incosistent across devices. Both of this two devices are custom ROM too. psutil_tab.txt |
Considering psutil was never developed on Android I'd say that's not bad at all. |
Does androind have |
it could be worse if it's on OEM/non-custom ROM 😉
It looks like android have? I don't know in non custom ROM because of SELinux being enforced 😅 But 2 of my devices which is custom ROM does have that |
I could do PR for this though. But I will get the loadavg by getting output of |
Whats the output of |
huh? no. Android doesn't use glibc, but Bionic. It's a different implementation, that's why sometimes there's libc function that's missing on Android. 😥 Even though you can read /proc/loadavg on Android, it still needs root access (or SELinux permissive/disabled). But using uptime works without root. 🤔 edit: the content of |
I don't think parsing uptime is worth it. I prefer to keep things simple. You can easily do it in your own code though. |
that's fine. Thanks for the response 😉 hmm.... is there possibility that uptime have output variation/inconsistent output across devices and operating system? 🤔 |
I don't know. It's the main reason why I don't think it's worth it to put it in psutil. =) |
From skolpat...@gmail.com on May 22, 2013 22:56:57
Original issue: http://code.google.com/p/psutil/issues/detail?id=384
The text was updated successfully, but these errors were encountered: