Rewrite the logger in Rust; add install targets
vitals-log replaces the bash sampler and writes the same CSV layout. The crate is now a library plus two binaries. dist/ holds the systemd unit and desktop entry templates, installed by make install. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -1,17 +1,52 @@
|
||||
# vitals
|
||||
|
||||
Viewer for the CSV logs written by `vitals-log` (`~/.local/bin/vitals-log`, run
|
||||
every minute by the `vitals-log.timer` systemd user unit). Shows the latest
|
||||
reading and time-series plots of temperatures, battery, memory, memory pressure
|
||||
and load. Built with egui and egui_plot.
|
||||
Logs system temperatures, power status and memory load once a minute, and plots
|
||||
the history.
|
||||
|
||||
- `vitals-log` takes one sample and appends it to `vitals-YYYY-MM.csv`. A
|
||||
systemd user timer runs it every minute.
|
||||
- `vitals` is the viewer: the latest reading plus time-series plots, built with
|
||||
egui and egui_plot.
|
||||
|
||||
## Install
|
||||
|
||||
make install
|
||||
|
||||
This builds both binaries into `~/.local/bin`, installs and starts
|
||||
`vitals-log.timer` (systemd user unit), and installs the `Vitals` desktop entry
|
||||
so the viewer shows up in the launcher. `PREFIX=/somewhere make install` changes
|
||||
where the binaries go; the unit and desktop entry are generated from the
|
||||
templates in `dist/` to point at them. The pieces can be installed separately
|
||||
with `make install-bin`, `install-units` and `install-desktop`.
|
||||
|
||||
`make uninstall` removes all of it and leaves the logs alone. For logging to
|
||||
continue while logged out, enable lingering once: `loginctl enable-linger`.
|
||||
|
||||
## Logger
|
||||
|
||||
vitals-log [--dir PATH] [--print]
|
||||
|
||||
Logs go to `$XDG_STATE_HOME/vitals` (`~/.local/state/vitals`), one file per
|
||||
month, about 5 MB each. `--print` writes the header and a sample to stdout
|
||||
without touching the log, which is the quick way to check what a machine
|
||||
exposes.
|
||||
|
||||
The columns are fixed and defined in `src/sample.rs`: temperatures come from
|
||||
hwmon chips looked up by name (the `hwmonN` numbering changes between boots),
|
||||
power from `/sys/class/power_supply` and `powerprofilesctl`, memory from
|
||||
`/proc/meminfo` and `/proc/pressure/memory`. The sensor table is specific to
|
||||
this laptop (Framework, Intel); on other hardware, edit `TEMPERATURES`. A source
|
||||
that can't be read leaves an empty cell. If the column set changes mid-month,
|
||||
the old file is renamed `vitals-YYYY-MM.until-<timestamp>.csv` so layouts never
|
||||
mix in one file.
|
||||
|
||||
## Viewer
|
||||
|
||||
cargo install --path .
|
||||
vitals [--dir PATH] [--interval SECONDS] [--range 1h|6h|24h|7d|all]
|
||||
|
||||
The log directory defaults to `$XDG_STATE_HOME/vitals` (`~/.local/state/vitals`).
|
||||
Every `vitals-YYYY-MM.csv` there is loaded at startup; after that only bytes
|
||||
appended since the last check are read (every 10 s by default). Columns are
|
||||
matched by header name, so a changed log layout shows gaps rather than breaking.
|
||||
Every `vitals-YYYY-MM.csv` is loaded at startup; after that only bytes appended
|
||||
since the last check are read (every 10 s by default). Columns are matched by
|
||||
header name, so a changed log layout shows gaps rather than breaking.
|
||||
|
||||
Drag to pan and ctrl-scroll or pinch to zoom the time axis; all plots move
|
||||
together. Picking a range preset returns to following the clock. Lines break
|
||||
@@ -19,6 +54,11 @@ where the logger was not running, and on-battery periods are shaded in the
|
||||
battery plot. Wide ranges are reduced to per-bucket min/max, so spikes stay
|
||||
visible.
|
||||
|
||||
## Source
|
||||
|
||||
- `src/sample.rs` — reading sensors, appending to the log
|
||||
- `src/data.rs` — parsed series, windowing, gap splitting, downsampling
|
||||
- `src/tail.rs` — incremental file reader, month rollover, replaced-file reload
|
||||
- `src/main.rs` — the UI; the `PANELS` table defines the plots
|
||||
- `src/bin/vitals-log.rs` — the logger's command line
|
||||
- `src/bin/vitals.rs` — the viewer; the `PANELS` table defines the plots
|
||||
- `dist/` — systemd unit and desktop entry templates
|
||||
|
||||
Reference in New Issue
Block a user