brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: sar reads back your monitoring data from earlier today or yesterday

Monitoring
~/tips/tip-monitoring-sar-history

sudo apt install sysstat

Check load and memory at the time a problem happened, after the fact.

The server was slow at three in the morning, and by breakfast everything looks fine. With sysstat collecting, you can still see what it looked like.

Install it and switch collection on:

sudo apt install sysstat
sudo dpkg-reconfigure sysstat

Answer yes to the question. From then on samples are stored regularly. Yesterday’s load, limited to a window:

sar -q -1 -s 02:00:00 -e 04:00:00

-q reports load and run queue figures, -1 picks the file from one day ago, and -s and -e set the start and end. Leave out -1 for today. For memory over the same period:

sar -r -1 -s 02:00:00 -e 04:00:00

An older file can be named directly with -f, for instance sar -q -f /var/log/sysstat/sa28 on Debian and Ubuntu. The number is the day of the month.

I think this is worth setting up before you need it, since it cannot collect the past.

Samples are taken at intervals, ten minutes by default on many setups, so a spike of half a minute can vanish in the average. It also records system totals and will not tell you which program caused the load. Other distributions keep the files under /var/log/sa.

Further reading: sar man page, sysstat project

Going deeper: Keep a domain pointed at your home with Cloudflare DDNS on Unraid

More Monitoring tips sudo apt install vnstat sudo apt install nethogs glances -w All Monitoring tips (4) All topics

Link