Repository navigation
system: read uptime/load/memory/swap from /proc for container correctness - #52
Open
YTjungle666 wants to merge 1 commit into
Open
YTjungle666 wants to merge 1 commit into
YTjungle666 wants to merge 1 commit into
Conversation
…ness sysinfo(2) reports host-wide uptime, load, memory and swap even inside a container, while /proc is virtualized to the container view (e.g. LXC with LXCFS). Read /proc/uptime, /proc/loadavg, /proc/meminfo and /proc/swaps first and fall back to sysinfo(2) per field when a source is unavailable. The ubus "system info" JSON schema, field names, units and the 1<<16 load scaling are unchanged, so consumers such as LuCI keep working unmodified on bare metal, VMs and containers.
YTjungle666
added a commit
to YTjungle666/procd-lxcfs-fix
that referenced
this pull request
Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
system_info()reads uptime, load, memory and swap viasysinfo(2), which always reports host-wide values — even inside a container. With LXC (with or without LXCFS),/procis virtualized to the container's view, butsysinfo(2)is not, soubus call system info(and consumers such as the LuCI status page) showed the host's memory, uptime and swap inside containers.This makes
system.cread the standard/procinterfaces first and fall back tosysinfo(2)per field when a source is unavailable:/proc/uptime/proc/loadavg(1<<16 fixed-point scaling kept)/proc/meminfo(MemTotal, MemFree, Shmem, Buffers, MemAvailable, Cached)/proc/meminfo→/proc/swaps→sysinfo(2)No container detection is performed: bare metal, VMs and containers all simply read their own
/proc— on bare metal the values are identical to before (the same interfacesuptime/freeread). The ubus JSON schema, field names, units and load scaling are unchanged, so no consumer needs modification.Tested on x86_64 (OpenWrt 25.12, musl) inside an LXC with LXCFS:
ubus call system infonow reports the container's own uptime/load/memory/swap, and all services (netifd, dnsmasq, dropbear, LuCI) operate normally.The change touches
system.conly (base commit58eb263d, openwrt-25.12; rebased onto currentmain).