Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

ubuntu-sensor-scan

Runs sensors on Ubuntu periodically to keep trends available

Install the script and take one reading:

sudo install -m 755 sensorlog.py /usr/local/bin/sensorlog
sensorlog sample

Default database: ~/.local/share/sensorlog/sensors.db (override with --db).

Sampling every minute

/etc/systemd/system/sensorlog.service

[Unit]
Description=Sample lm-sensors into sensorlog
After=local-fs.target

[Service]
Type=oneshot
User=sean
ExecStart=/usr/local/bin/sensorlog --db /var/lib/sensorlog/sensors.db sample --quiet
Nice=10
IOSchedulingClass=idle

/etc/systemd/system/sensorlog.timer

[Unit]
Description=Sample sensors every minute

[Timer]
OnBootSec=2min
OnUnitActiveSec=1min
AccuracySec=5s
Persistent=false

[Install]
WantedBy=timers.target

Then:

sudo mkdir -p /var/lib/sensorlog && sudo chown sean /var/lib/sensorlog
sudo systemctl daemon-reload

Cron equivalent if you'd rather:

* * * * * /usr/local/bin/sensorlog --db /var/lib/sensorlog/sensors.db sample --quiet

Reading it back

sensorlog --db /var/lib/sensorlog/sensors.db report --window 120
sensorlog --db /var/lib/sensorlog/sensors.db report --window 1440 --chip coretemp
sensorlog --db /var/lib/sensorlog/sensors.db export --since 2026-07-01 > sensors.csv

Storage cost

35 rows per sample on kate's chip set, ~60 bytes/row in the WITHOUT ROWID table plus two indexes. At one sample per minute that's roughly 150 MB/year before vacuum. Prune with:

DELETE FROM readings WHERE ts < '2026-01-01';
VACUUM;

Useful queries

sqlite3 /var/lib/sensorlog/sensors.db

Use these commands to make the output readable

.mode box
.headers on
.schema readings

Package 1 core mean, hourly:

SELECT substr(ts,1,13) AS hour,
       AVG(value)      AS mean_of_means,
       MAX(value)      AS peak
FROM readings
WHERE chip='coretemp-isa-0001' AND feature='cores' AND metric='mean'
GROUP BY hour ORDER BY hour;

Spatial spread vs. time — is one core running away from the package?

SELECT ts, value AS core_spread
FROM readings
WHERE chip='coretemp-isa-0001' AND feature='cores' AND metric='stddev'
  AND value > 6
ORDER BY ts DESC LIMIT 20;

Fan response against package temp:

SELECT t.ts, t.value AS pkg1_core_mean, f.value AS fan4_rpm
FROM readings t
JOIN readings f ON f.ts=t.ts AND f.chip='dell_smm-isa-0000' AND f.feature='fan4'
WHERE t.chip='coretemp-isa-0001' AND t.feature='cores' AND t.metric='mean'
ORDER BY t.ts DESC LIMIT 60;

About

Runs `sensors` on Ubuntu periodically to keep trends available

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages