How much monthly bandwidth is your Linux server using?
To answer this question, we’ll use the “vnstat” utility.
Installing and using vnstat
Install vnstat:
apt-get install vnstat
Configure the network interface you want to monitor (in our example we used the “eth0” interface):
vnstat -u -i eth0
From now on, just wait a few minutes for vnstat to count enough data to display the usage reports.
To display the monthly usage report:
vnstat -m
Output of the above command:
root@ns524364:~# vnstat -m eth0 / monthly month rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- Jan '18 10.72 MiB | 11.25 MiB | 21.97 MiB | 0.07 kbit/s ------------------------+-------------+-------------+--------------- estimated 11 MiB | 12 MiB | 23 MiB |
Other vnstat options:
root@ns524364:~# vnstat --help vnStat 1.15 by Teemu Toivola <tst at iki dot fi> -q, --query query database -h, --hours show hours -d, --days show days -m, --months show months -w, --weeks show weeks -t, --top10 show top 10 days -s, --short use short output -u, --update update database -i, --iface select interface (default: eth0) -?, --help short help -v, --version show version -tr, --traffic calculate traffic -ru, --rateunit swap configured rate unit -l, --live show transfer rate in real time