fix(environment): CPU usage from two reads a second apart

get_environment promised two samples one second apart but read
/proc/stat once, so the figure was the average since boot: a box at
100 % for the last minute showed its lifetime average. It now reads the
cpu line twice, a second apart, and uses the difference.

Closes #10
This commit is contained in:
Christian Manivong committed 2026-11-01 21:45:24 +01:00
1 parent c211ba0d9e
commit 097d9b9581
3 files changed
+96 -11

No files matched your search

+3
View File
@@ -24,6 +24,9 @@ recorded here; their history is the git log.
as a success (#3).
- `apply_updates()` reports a failed upgrade as failed, with the package manager's
exit status in `error`; it used to report every upgrade as done (#11).
- `get_environment()` reports the CPU usage of the last second, from two reads of
`/proc/stat` one second apart; it used to report the average since boot, so a box
busy for the last minute could show a low figure (#10).
## [0.7.0] - 2026-10-23