Bat Stat is a small Linux battery logger and report generator. It records battery samples to a CSV file, then turns that CSV into a standalone HTML report with charts, summaries, daily stats, heatmaps, sessions, and recent samples.
Dual-battery laptops are supported with seperate logs for each battery. the report lets you switch between batteries with a dropdown.
It is designed to run from source with Python and systemd. No Python packages are required.
More screenshots: health and daily summaries, heatmap and sessions.
- Linux with battery data exposed in
/sys/class/power_supply - Python 3.10 or newer
git, for the one-line installer- systemd, if you want automatic scheduled logging
One-line install:
curl -fsSL https://raw.githubusercontent.com/riothedev/bat-stat/main/install.sh | sudo bashFrom the project directory:
sudo ./install.shThe installer:
- copies the app to
/opt/bat-stat - creates the command
/usr/local/bin/bat-stat - creates
/var/log/battery-stat/battery_log.csv - installs
bat-stat-log.service - installs and starts
bat-stat-log.timer - records one sample immediately unless disabled
By default, the timer logs one sample every 5 minutes.
After installing:
bat-statThis reads:
/var/log/battery-stat/battery_log.csvand writes battery_report.html in your current directory, then opens it in your browser.
Choose an output path:
bat-stat report --output ~/battery_report.htmlUse a different CSV:
bat-stat report --input /path/to/battery_log.csv --output ~/battery_report.htmlSkip opening the browser:
bat-stat --no-openAppend one sample manually:
bat-stat logAppend one sample to a custom CSV:
bat-stat log --output /tmp/battery_log.csvRun a foreground logger every 5 minutes:
bat-stat log --watchThe installed systemd timer is usually the better option for normal use.
Check the timer:
systemctl status bat-stat-log.timer
systemctl list-timers bat-stat-log.timerCheck the latest service run:
systemctl status bat-stat-log.serviceView logs:
journalctl -u bat-stat-log.serviceRun one sample through systemd:
sudo systemctl start bat-stat-log.serviceStop scheduled logging:
sudo systemctl disable --now bat-stat-log.timerStart it again:
sudo systemctl enable --now bat-stat-log.timerChange the logging interval:
sudo INTERVAL_SECONDS=60 ./install.shUse a different CSV path:
sudo LOG_FILE=/var/log/battery-stat/custom.csv ./install.shInstall somewhere else:
sudo INSTALL_DIR=/opt/my-bat-stat BIN_PATH=/usr/local/bin/my-bat-stat ./install.shInstall the timer but do not start it:
sudo START_TIMER=0 ./install.shDo not record an immediate sample during install:
sudo RUN_ON_INSTALL=0 ./install.shRemove the installed app, command, service, and timer:
sudo ./uninstall.shThe CSV log is kept by default. Remove it too:
sudo REMOVE_LOG=1 ./uninstall.shRun from the repo without installing:
python3 bat_stat.py --input /path/to/battery_log.csv --output report.html --no-openGenerate a synthetic CSV:
python3 bat_stat.py exampleGenerate a synthetic CSV and report together:
python3 bat_stat.py demoProject layout:
bat_stat.py
install.sh
src/
cli.py
constants.py
csv_log.py
example.py
formatting.py
logger.py
models.py
report.py
report_template.html
templates.py
The report template is src/report_template.html.

