[Feature]: CPU/load fallback for unrooted Android
Welcome!
- I have searched open and closed feature requests to make sure this or similar feature request does not already exist.
- This is a feature request, not a bug report or support question.
Component
Agent
Description
Let the agent report CPU and load on unrooted Android (Termux), where
/proc/stat and /proc/loadavg are SELinux-denied.
Two fallbacks that work from the app sandbox today:
- CPU from per-core
/sys/devices/system/cpu/cpu*/cpufreq/stats/time_in_state(sample twice,%of max capacity). - Load from the
sysinfo()syscall instead of/proc/loadavg.
Motivation / Use Case
I run beszel-agent 0.19.0 on two unrooted phones (Galaxy S23 SM-S911B
Android 16, Huawei DBY-W09) under Termux. Everything works except CPU
(stuck 0%) and load (bogus), because the app UID gets permission denied on /proc/stat and /proc/loadavg. HOST_PROC can't help,
there is no other proc to point at.
I worked around it externally: a tiny helper sampling time_in_state
reads 32.7% idle, 94.3% loaded on the Samsung, and toybox uptime
gives live load there. Would be nice if the agent just did this itself
when cpu.Times() comes back empty.
Describe how you would like to see this feature implemented
If cpu.Times() errors or returns all zeros, fall back to
time_in_state deltas using the existing lastCpuTimes cache, and try
unix.Sysinfo for load when /proc/loadavg is unreadable.
Note: time_in_state % means "% of max capacity", not classic CPU%,
so it probably wants a label note in the UI.
Alternative if you prefer it: both phones have Shizuku, and
rish -c 'cat /proc/stat' returns real counters from Termux. Happy to
test whatever direction you pick on both devices.
Screenshots
No response
Category
Metrics
Affected Metrics
CPU, Load Average
Source: henrygd/beszel