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: vnstat keeps a traffic history for monitoring your monthly usage

Monitoring
~/tips/tip-monitoring-vnstat-traffic

sudo apt install vnstat

See how much data a network interface moved per day or month.

If your internet plan has a limit, or a server’s provider bills traffic, you want totals over weeks. Live tools forget everything when you close them.

vnstat has a small daemon that records the counters in the background:

sudo apt install vnstat
vnstat -i eth0

Then ask for the period you care about:

vnstat -i eth0 -h
vnstat -i eth0 -d
vnstat -i eth0 -m

Those are hourly, daily and monthly tables, each with received, sent and total. For the current rate, there is a live mode:

vnstat -i eth0 -l

Replace eth0 with your interface name from ip -br link.

The daemon only reads counters the kernel already keeps, so it costs next to nothing, which is why I would leave it running on any box with a data cap.

History starts at installation, so right after setup the tables are nearly empty. Give it a day. It counts everything on that interface, including traffic that stays on your local network, so the total can be much higher than what your provider counts. On a machine with Docker or a VPN there are several interfaces, and the same bytes can show up on more than one of them.

Further reading: vnstat man page

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

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

Link