Skip to content
InvictusNavarchusPublic

About

Battery health monitor & high-frequency hardware flight recorder for Linux laptops.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

340 Commits

Folders and files

Repository files navigation

batmon

Battery health monitor & hardware flight recorder for Linux laptops.

batmon is a zero-dependency, low-overhead background daemon that continuously records power, thermal, and system telemetry to local SQLite databases.

It operates as a high-frequency flight recorder, capturing hardware metrics every second to preserve the exact state of the machine in the event of a crash or kernel panic, while simultaneously maintaining a permanent, downsampled historical log for tracking long-term component wear and battery degradation.


⚑ Quick Install

curl -fsSL https://raw.githubusercontent.com/InvictusNavarchus/batmon/master/install.sh | bash

The installer automatically detects your architecture (x86_64 or aarch64), downloads the pre-compiled static binary to ~/.local/bin/batmon, installs the systemd user service, and verifies the executable without recording a sample. On a fresh install it then enables and starts the service, so recording begins immediately.

To install without activating, pass --no-enable (bash -s -- --no-enable when piping the installer) and start it later with systemctl --user enable --now batmon.service. Lingering is never changed; see Recording at boot and after logout. No root privileges are needed.

Releases also include the optional batmon-plot helper, installed beside the binary. Plotting requires uv; the daemon itself needs no Python or plotting dependencies.

Downloads require curl, tar, and sha256sum. The installer resolves one release tag and verifies its archive against that release's checksum before changing an existing installation. Missing or invalid checksums stop the update.

Updating

Run the same installation command again to update to the latest stable release. Your databases are preserved; the installer verifies the artifact, atomically replaces the executable, and restarts an already-active service. Updates never re-enable a service you disabled: inactive services stay inactive, enabled/disabled state is unchanged, and masks and drop-ins are preserved. Pass --enable to enable and start it again (it refuses a masked service). No checkout or Rust compiler is needed. From a checkout, ./install.sh also downloads a release; only ./install.sh --build compiles local source.

batmon --version reports the package version and the build's Git commit, for example batmon 0.9.0 (abc1234). Local builds append , dirty when tracked files have staged or unstaged changes. Untracked files are excluded. Builds without Git or checkout metadata report batmon 0.9.0 (unknown). This information is embedded at compile time; Git is not required to run the installed binary.

Set BIN_DIR on the installer command to choose another binary directory. That location is recorded for future updates, the service, and uninstalling; subsequent updates can use the normal installation command without repeating BIN_DIR.


🎯 Architecture: Dual-Tier Monitoring

batmon captures telemetry using two distinct tiers:

                      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                      β”‚            batmon Daemon (Rust)               β”‚
                      β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚ (Every 1 sec)                 β”‚ (Every 60 sec)
                              β–Ό                               β–Ό
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
               β”‚    debug.db (Flight Log)     β”‚ β”‚  battery.db (Historical DB)  β”‚
               β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
               β”‚ β€’ 1s sample resolution       β”‚ β”‚ β€’ 60s sample resolution      β”‚
               β”‚ β€’ SQLite WAL + sync=NORMAL   β”‚ β”‚ β€’ SQLite WAL + sync=NORMAL   β”‚
               β”‚ β€’ Keeps last 6h of recording β”‚ β”‚ β€’ Permanent wear records     β”‚
               β”‚ β€’ Crash & panic forensics    β”‚ β”‚ β€’ Cycle count & degradation  β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  1. High-Frequency Flight Recorder (debug.db):
    Records every 1 second directly to SQLite using WAL mode (PRAGMA synchronous = NORMAL). Commits are written to the Linux kernel page cache via write() without invoking an fsync() on each tick, consuming negligible disk I/O and power (<15 mW). Data is immediately queryable across processes. Disk durability operates on a best-effort basis via SQLite's automatic WAL checkpoints (wal_autocheckpoint = 100 pages) and standard Linux dirty page writebackβ€”preventing database corruption during crashes while trading immediate per-second fsync persistence for drive longevity. Keeps the most recent 6 hours of recording (21,600 rows at 1 Hz), pruning by row count rather than wall-clock age: time spent powered off or suspended does not count against the window, so the run-up to a crash is still there however long the machine stays off afterwards.

  2. Long-Term Historical Telemetry (battery.db):
    Records downsampled samples every 60 seconds. Tracks long-term battery degradation, design wear capacity, and software-integrated cycle count over months and years.


πŸ“Š What It Logs

Category Metric Source Description
Electrical & Power power_state sysfs / state machine Rail power status (charging, discharging, ac_idle, unknown)
ac_online sysfs (external supplies) External power connection, independent of charging; nullable
voltage_v sysfs (battery) Instantaneous battery rail voltage (V)
power_w sysfs (battery) Discharge / charge rate (Watts)
charge_pct sysfs (battery) Current state of charge (%)
energy_wh sysfs (battery) Remaining energy (Wh)
energy_full_wh sysfs (battery) Current full charge capacity (Wh)
energy_design_wh sysfs (battery) Factory nominal design capacity (Wh)
voltage_design_v sysfs (battery) Factory design voltage (V)
is_charging sysfs (battery) Charge state boolean
Thermal Environment cpu_temp_c sysfs (hwmon) CPU package / core temperature (e.g. AMD Tctl / Intel Package id) (Β°C)
gpu_temp_c sysfs (hwmon) GPU temperature (e.g. AMD edge / Intel package) (Β°C)
nvme_temp_c sysfs (hwmon) NVMe composite temperature (Β°C)
battery_temp_c sysfs (battery / hwmon) Battery sensor temperature (if present)
Clock & SoC Power cpu_freq_mhz sysfs (cpufreq) / /proc Instantaneous CPU clock frequency (MHz)
gpu_power_w sysfs (hwmon) AMD APU / GPU package power (PPT via amdgpu) (Watts)
gpu_pct sysfs (DRM) GPU compute / shader utilization (%)
System Load & Host cpu_pct /proc/stat Global CPU utilization (%)
iowait_pct /proc/stat CPU I/O wait utilization (%)
mem_pct /proc/meminfo Global Memory utilization (%)
dirty_kb /proc/meminfo Uncommitted dirty writeback memory (kB)
load1 /proc/loadavg 1-minute system load average
procs_blocked /proc/stat Count of processes currently waiting for I/O (nr_iowait)
psi_io_some /proc/pressure/io Linux PSI I/O pressure some (10s rolling avg %)
psi_io_full /proc/pressure/io Linux PSI I/O pressure full (10s rolling avg %)
psi_mem_some /proc/pressure/memory Linux PSI memory pressure some (10s rolling avg %)
psi_mem_full /proc/pressure/memory Linux PSI memory pressure full (10s rolling avg %)
boot_id /proc/sys/kernel/random/boot_id Linux kernel boot session UUID
uptime_s /proc/uptime Monotonic system uptime (seconds)
top_processes /proc/[pid]/stat Top 5 aggregated process groups by 1s CPU delta (JSON)
Health & Wear health_pct sysfs Full charge capacity vs design capacity (%)
battery_health sysfs (battery) Raw driver fault status; nullable
battery_id sysfs (battery) Manufacturer/model/serial identity as JSON; nullable
cycle_count sysfs Hardware cycle count (if reported by BMS)
estimated_cycle_count Integrator Calculated cycle count via energy throughput ($\Delta\text{Wh} / \text{Design}$)
Runtime Estimates time_to_empty_s UPower D-Bus Smoothed discharge runtime estimate (seconds)
time_to_full_s UPower D-Bus Smoothed charge completion estimate (seconds)
  • Auto-detects energy_* (Β΅Wh) vs charge_* (Β΅Ah) battery drivers.
  • Low-Overhead Native Reads: All CPU, memory, clock, GPU, thermal, and process metrics are gathered directly via Linux kernel VFS interfaces (/proc and /sys) and standard POSIX process accounting (~12 ms per sample cycle) with zero child processes. UPower and desktop notifications are spoken to over D-Bus directly rather than by spawning busctl and notify-send. Resident memory is ~6.6 MB (median over a 12-hour dual-daemon run spanning a reboot). See empirical evaluations on Kernel VFS vs. Glances, Sysfs Hwmon vs. lm-sensors, and TypeScript vs. Rust parity for detailed benchmark results.
  • Automatic Migrations: Database schema updates and column additions are handled seamlessly and automatically on startup using SQLite's native user_version tracking with zero manual migration steps required. Each step applies atomically, and both databases are backed up before any migration (see Pre-migration backups).

Battery read failures do not interrupt system recording. Unavailable battery measurements are stored as SQL NULL; alerts preserve their latches on missing readings, and estimated cycles do not integrate across missing energy readings. Historical-store read/write failures are logged without interrupting a healthy flight recorder; its cycle baseline still advances after each persisted sample. Historical cycle totals snapshot the per-second integral, so minute-sampled rows cannot bridge read failures. One-shot recording also uses the flight recorder's latest sample for cycle integration, falling back to history only when the flight recorder has no samples. Older stored zeros and health defaults cannot be retroactively distinguished from measurements.

ac_online records external power independently of battery charging status; missing adapter attributes remain NULL. A plugged-in battery may discharge.

battery_health preserves the kernel battery fault status (for example Good or Overheat). It is distinct from capacity-based health_pct; unsupported attributes remain NULL. Recording this status does not introduce new alerts.

battery_id is a JSON array of manufacturer, model and serial number. Missing, empty, zero-only and common placeholder serials, or unreadable manufacturer/model attributes, leave identity unknown; capacity changes never imply replacement. Each identifiable pack keeps its own observed cycle total in battery_cycles, including after debug rows are pruned. These are observed cycles since monitoring began, not lifetime BMS cycles. Unknown packs cannot be distinguished reliably; identity transitions break integration. The first identifiable pack starts a separate total from legacy unidentified data. During a known pack’s identity read failure, battery_id and estimated_cycle_count are NULL; the durable pack total remains intact. Continuous legacy unidentified histories still estimate observed discharge. On upgrade to the identity schema, legacy missing cycle baselines start at zero; subsequent uncertain totals remain NULL across restarts.


πŸ“ˆ Plot Recorded Telemetry

With uv installed, use the helper included with the release; no repository checkout is needed:

# Past seven days from the permanent, minute-sampled history
batmon-plot --since 7d --output report.png

# Recent second-resolution detail from the flight recorder
batmon-plot --source debug --since 2h --output recent.png

# Explicit path, useful for a disposable database backup
batmon-plot --database /path/to/battery.db --since 12h --output backup.png

# Override the default system-local display timezone
batmon-plot --since 7d --timezone UTC --output utc.png
batmon-plot --since 7d --timezone Asia/Jakarta --output jakarta.png

If the binary directory is not on your PATH, run uv run --script ~/.local/bin/batmon-plot --since 7d --output report.png. For a custom installation directory, substitute its path. From a checkout, use uv run --script scripts/batmon-plot.py --since 7d --output report.png.

The script declares Python β‰₯3.11, Seaborn, Matplotlib, and python-dateutil dependencies inline (Matplotlib also requires python-dateutil). uv manages an isolated environment and downloads Python if a suitable version is unavailable. The first run needs network access; later runs reuse cached dependencies. The installer does not install uv, Python, or plotting packages. Pinned releases predating this helper install only the daemon.

Each report has temperature (CPU, GPU, NVMe, battery), power (battery, GPU), and utilization (CPU, GPU, memory) panels. Missing sensors are omitted from the legend; panels without readings are labeled. The defaults are --since 24h, --source history, and --output report.png. Durations accept positive hours or days, including 1.5h. Output is PNG and replaces an existing output file. --show also opens a plot window when a graphical Matplotlib backend is available; saving a report works without a desktop session.

Windows end at the current time and use wall-clock time. Charts default to --timezone local, detecting the system timezone and respecting a TZ environment override. Use --timezone UTC or an IANA name such as Asia/Jakarta to choose another display zone. Labels use that zone's daylight-saving rules; each endpoint in the report header includes its UTC offset. Stored timestamps, query boundaries, elapsed durations, and gap detection stay in UTC, so a clock change does not change the selected samples.

The helper opens SQLite in read-only mode, closes its query before rendering, and does not migrate databases or control the service. It plots recorded values without smoothing or averaging, preserving zeros and missing readings. Lines break on boot changes, non-increasing timestamps, clock discontinuities detected from uptime, or gaps longer than three expected sample intervals (3 seconds for debug, 3 minutes for history). Such breaks indicate discontinuities, not a diagnosis of their cause. When overriding --database, also set --source debug for a flight-recorder database so gap detection uses its expected cadence.

Historical rows are periodic snapshots, not minute averages or maxima; short spikes between samples cannot be recovered. Flight-recorder retention keeps 21,600 rows by default, so a requested window may be only partially covered. The full requested time range remains on the x-axis, leaving uncovered time blank. If the window contains no samples or none of the plotted measurements, the helper exits with an error without producing a report.


πŸ” Post-Mortem Forensics & SQL Recipes

1. Inspect the last 30 seconds before a crash

Run after rebooting from the crash. By then the daemon is already recording the new boot, so the newest rows are not the crash; this finds the boot before the current one and shows how it ended. A boot that died within seconds yields fewer than 30 rows rather than borrowing from an older boot.

sqlite3 ~/.local/share/batmon/debug.db "
WITH previous_boot AS (
  SELECT boot_id FROM samples
  WHERE boot_id IS NOT '$(cat /proc/sys/kernel/random/boot_id)'
  ORDER BY id DESC
  LIMIT 1
)
SELECT ts, power_w, voltage_v, cpu_freq_mhz, cpu_temp_c, gpu_power_w, cpu_pct, iowait_pct, procs_blocked, psi_io_full, psi_mem_full, top_processes
FROM samples
JOIN previous_boot USING (boot_id)
ORDER BY id DESC
LIMIT 30;"

2. Check long-term battery degradation & wear

sqlite3 ~/.local/share/batmon/battery.db "
SELECT ts, charge_pct, health_pct, cycle_count, estimated_cycle_count, energy_full_wh, energy_design_wh
FROM samples
ORDER BY id DESC
LIMIT 10;"

3. Identify top power-hog process groups

sqlite3 ~/.local/share/batmon/debug.db "
SELECT ts, power_w, cpu_temp_c, top_processes
FROM samples
WHERE power_w > 30.0
ORDER BY id DESC
LIMIT 5;"

πŸ”” Desktop Notifications & Alerts

batmon features a stateful alerting engine with deadband hysteresis, debouncing, and priority escalation to prevent notification storms from flapping sensors:

  • High Battery Temp Warning: Alert when battery temp $\ge 45^\circ\text{C}$ (Critical at $50^\circ\text{C}$ with contextual cooling advice; re-arms below $42^\circ\text{C}$ / $47^\circ\text{C}$).
  • Charging While Hot (Heat-Soak): Alert when charging while CPU $\ge 85^\circ\text{C}$ (re-arms below $80^\circ\text{C}$).
  • Thermal Anomaly: Warning when the CPU stays hot during low workload. The pop-up uses the desktop's normal timeout, and the alert is also logged to the journal.
  • Charge Limits: Reminders to unplug at $\ge 80%$ (re-arms below $75%$) and plug in at $\le 20%$ (Critical at $\le 10%$ suppresses normal low alert; re-arms above $25%$).
  • Over-Voltage Charging: Alert when charging voltage exceeds 15% above design voltage (re-arms at or below 10% above design voltage).
  • Battery Health Degradation: Warning when full capacity drops below $80%$ of factory design (re-arms above $82%$).

Re-fired alerts replace their previous notification rather than stacking beside it, so a flapping sensor cannot bury the desktop even if it defeats the deadband.

Critical low-battery and battery-overheating pop-ups use the desktop's critical urgency. While monitoring, Batmon closes its active critical pop-up after the corresponding condition clears, such as when you connect the charger or the battery cools below the critical recovery threshold. You can also dismiss either pop-up manually.

Note: The current alert rules focus on battery protection, because by the time the voltage or power really drops, the system will be shutting down anyway. The idea is to prevent these issues from happening in the first place, not to detect them after the fact. The flight recorder is there to capture the data in case something does happen.


πŸ› οΈ Requirements

  • Linux with systemd (Fedora, Ubuntu, Debian, Arch, etc.)
  • Rust toolchain ($\ge 1.87$) (optional) β€” only required if building from source. The pre-compiled release binary is fully static with SQLite compiled in, linking nothing beyond standard system interfaces.
  • UPower (optional) β€” supplies smoothed runtime estimates. Without it, batmon falls back to dividing remaining energy by present draw.
  • A notification server (optional) β€” any desktop provides one. Without it, alerts are still written to the journal.
  • sqlite3 CLI (optional, for querying databases): sudo dnf install sqlite
  • uv (optional, for batmon-plot) β€” manages the helper's Python and plotting dependencies.

πŸš€ Installation Options

Build from Source

If you prefer compiling locally rather than downloading pre-compiled binaries:

git clone https://github.com/InvictusNavarchus/batmon.git
cd batmon
./install.sh --build

Upgrading from a Bun-based installation removes superseded TypeScript sources and keeps your existing databases. Retire a legacy timer explicitly using the steps below before installing the daemon service.

Recording at boot and after logout

Batmon remains a user service because ordinary user permissions are sufficient for its telemetry. To record before login and after logout, explicitly enable lingering for the account that runs Batmon:

loginctl enable-linger "$USER"
loginctl show-user "$USER" -p Linger
systemctl --user enable --now batmon.service

Local authorization policy may require administrator approval for the lingering change. Lingering keeps the entire user manager available: other enabled user services and timers can also run while logged out. It does not create a desktop; notifications are delivered when the notification server is available, and alerts remain in the journal otherwise. Recording starts once the user manager, required storage, and sources are ready; it does not cover the earliest boot stages or suspend. The installer and uninstaller never change lingering.

Use systemctl --user edit batmon.service for persistent customizations. The installer regenerates the base unit but retains drop-ins. Never run the old timer and daemon scheduling paths together.

For a legacy Bun-era batmon.timer, inspect and retire its schedule before installing the daemon service. The installer stops before replacement if the old timer is known to the user manager or its local unit file is present. Check systemctl --user show -p FragmentPath batmon.timer for its actual location; the commands below assume the usual configuration directory. Preserve the old unit outside systemd's search path, then explicitly activate the daemon when ready:

systemctl --user cat batmon.timer
systemctl --user disable --now batmon.timer
mkdir -p ~/.local/share/batmon
mv -i ~/.config/systemd/user/batmon.timer ~/.local/share/batmon/legacy-batmon.timer
bash install.sh --enable

If the unit came from a different location, inspect its FragmentPath and retire that owned installation explicitly. Preserve intentional disabled/masked choices instead of enabling the replacement automatically.

Managing the Service

# Check service status
systemctl --user status batmon.service

# View live logs
journalctl --user -u batmon.service -f

# A one-off sample writes databases and evaluates alerts; use an isolated
# development environment when testing. The installer does not run this command.
# It records beside a running service, but refuses if its databases need a
# schema migration (restart the service so the daemon migrates them first) or
# do not exist yet (the starting daemon is creating them; retry in a moment).
batmon --oneshot

# Raise log verbosity (standard tracing filter syntax)
BATMON_LOG=batmon=debug batmon

Pre-migration backups

When an upgrade brings a schema migration, batmon copies both databases before changing either:

~/.local/share/batmon/backups/pre-migration/
  20261121T190400Z-battery-v11-debug-v9/
    battery.db
    debug.db

The name records the UTC time and each database's schema version at the time of the copy. Copies are taken through SQLite, include recently committed data, and pass an integrity check before they are published. Both databases are copied together because each keeps its own cycle ledger; restore them as a pair.

  • Nothing to migrate: no copy is taken.
  • Backup fails (for example, the disk is full): batmon stops before migrating and logs the reason; the service retries every few seconds. Recording pauses until the cause is fixed.
  • Migration fails and is retried: the existing copy of the same versions is checked and kept rather than replaced, as long as nothing has been recorded since. If rows were recorded in between, for example after rolling back to a previous release, a new copy is taken. If the existing copy is damaged, batmon stops and asks you to move it aside.
  • Retention: the newest three snapshots are kept, always including the one just taken. Only timestamped directories inside pre-migration/ are pruned, so manual backups elsewhere, including directly in backups/, are never touched.

These copies sit on the same disk as the databases. They protect against a faulty migration, not against losing the drive.

To restore a snapshot, stop the service first. Restarting the same batmon version would simply migrate the restored copy again, so either install the previous release first or restore only once a fixed release is available.

Run this in bash, replacing the snapshot name. In the snapshot database-copy step, a battery-none or debug-none label leaves that database absent until the release you start creates it. A failed copy of an expected database leaves the service stopped. mkdir fails if rollback/ already exists, so an earlier rollback is never overwritten; move it aside first.

SNAPSHOT=20261121T190400Z-battery-v11-debug-v9   # replace with the snapshot to restore
systemctl --user stop batmon.service &&
cd ~/.local/share/batmon &&
mkdir rollback &&
(
    shopt -s nullglob
    files=(battery.db* debug.db*)   # keep the current databases, WAL files included
    (( ${#files[@]} == 0 )) || mv -- "${files[@]}" rollback/
) &&
(
    # Copy the databases from the selected snapshot.
    snapshot_dir="backups/pre-migration/$SNAPSHOT"
    case "$SNAPSHOT" in
        *-battery-none-debug-*) ;;
        *) cp -- "$snapshot_dir/battery.db" . || exit 1 ;;
    esac
    case "$SNAPSHOT" in
        *-debug-none) ;;
        *) cp -- "$snapshot_dir/debug.db" . || exit 1 ;;
    esac
) &&
systemctl --user start batmon.service

To inspect a snapshot without migrating it, read it with batmon-plot --database or sqlite3; running batmon against it would migrate it.


πŸ§ͺ Development & Testing

# Complete release validation, shared with GitHub Actions and cargo-release
# Requires rustup/Cargo and uv 0.13.1; provisions Python 3.11 and locked test packages
sh scripts/validate.sh

# Run the full test suite (unit, property, and end-to-end binary tests)
cargo test

# Installer tests with temporary paths and mocked network/systemd
python3 tests/install.py

# Plotting tests with temporary databases and headless rendering
uv run --with 'matplotlib>=3.10,<4' --with 'seaborn>=0.13.2,<0.14' python -B tests/plot.py

# Lints, denied in the pre-commit hook
cargo clippy --all-targets -- -D warnings

# Formatting
cargo fmt --all

Where tests live

Tests are unit tests in the same crate, because most of them exercise private items β€” a sibling module cannot see them, so the test module has to stay a descendant of the module it tests.

A test module of 100 lines or more moves into its own file, declared as a child module:

// src/telemetry/thermal.rs
#[cfg(test)]
mod tests;          // -> src/telemetry/thermal/tests.rs

super still resolves to the parent module, so imports are unaffected and test paths are unchanged. Below 100 lines the tests stay inline at the bottom of the file, where colocation is still worth more than the indirection; four modules are in that category today, and all four are under 200 lines total.

When adding a test file, check that the mod declaration exists. A test file that is never declared compiles, runs nothing, and leaves the suite green at a lower count β€” the one failure mode here that no assertion catches.

Blaming through the extraction

The test modules were extracted in refactor/extract-test-modules, which moved 4,884 lines without changing any test logic. Plain git blame on those files reports only the move. To see who actually wrote a line:

git blame -w -C -C -C src/telemetry/thermal/tests.rs

-w is the part that matters: extraction dedented every line by one level, and without it the copy detection in -C finds nothing. A .git-blame-ignore-revs file does not help here β€” the content landed in new files, so ignoring the extraction commit leaves blame with nothing earlier to attribute to.


πŸ—‘οΈ Uninstallation

batmon-uninstall

No checkout is needed. If the binary directory is not on your PATH, run bash ~/.local/share/batmon/uninstall.sh. Existing databases are preserved. Removal stops/disables the user service and removes the owned commands and base unit. Drop-ins and account-wide lingering are retained. A service-stop failure leaves installed files in place and exits unsuccessfully. For older installations without a stored uninstaller, run ./uninstall.sh from a source checkout; supply BIN_DIR if it used a custom location.

Limitations

  • Battery cell-level data (individual cell voltages, internal impedance, BMS balancing status) is not available through the Linux power_supply sysfs interface and cannot be collected.
  • VRM rail voltages and transient events below ~1 s are not exposed by the kernel on most laptop hardware. The 1-second flight recorder can catch sustained voltage sag but not microsecond-scale transients.
  • The battery_temp_c sensor is absent on many laptops. When unavailable, battery thermal protection relies on ambient correlation with CPU/GPU temperatures.
  • mem_pct and load1 are recorded for forensic completeness but are rarely primary indicators of hardware failure.

About

Battery health monitor & high-frequency hardware flight recorder for Linux laptops.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages