Big Picture with vnStat
A co-located box on fat pipes can put pounds on you.
import Image from 'next/image'
If you manage servers and need to provide some degree of reporting on network usage by those servers in a high level way (how many gigabytes of traffic passed through interface foo? last month?), then you should check out vnStat (opens in a new tab).
For a Debian Linux system, you might do something like this to install it:
sudo apt update && sudo apt install -y vnstat
This installs vnStat and enables a vnstat.service
systemd service to run the vnstatd
daemon that periodically gathers network interface usage metrics.
After vnStat has had some time to collect some metrics, you can access them at the command line. Here are a some examples from the server that manages my collection of news trends on a multitude of topics:
Show usage for today and yesterday on all interfaces
vnstat
rx / tx / total / estimated
eth0:
yesterday 9.46 MB / 205.37 MB / 214.83 MB
today 1.69 MB / 62.77 MB / 64.46 MB / 1.12 GB
eth1:
yesterday 53.30 MB / 459.31 MB / 512.61 MB
today 2.59 MB / 37.22 MB / 39.80 MB / 710 MB
Show usage for all months on the primary interface
vnstat -m
eth0 / monthly
month rx | tx | total
------------------------+--------------+------------------------------------
Jun '10 358.13 MB | 8.61 GB | 8.96 GB %::::::::::::::::
Jul '10 294.29 MB | 5.27 GB | 5.56 GB %:::::::::
Aug '10 289.47 MB | 6.31 GB | 6.59 GB %:::::::::::
Sep '10 308.96 MB | 6.25 GB | 6.55 GB %:::::::::::
Oct '10 25.25 MB | 697.73 MB | 722.98 MB :
------------------------+--------------+------------------------------------
estimated 379 MB | 10.33 GB | 10.71 GB
Show weekly usage on the primary interface
vnstat -w
eth0 / weekly
rx | tx | total
----------------------------+---------------+--------------
last 7 days 64.96 MB | 1.49 GB | 1.55 GB
last week 69.49 MB | 1.43 GB | 1.50 GB
current week 64.96 MB | 1.49 GB | 1.55 GB
----------------------------+---------------+--------------
estimated 74 MB | 1.72 GB | 1.79 GB
Note here considerably more traffic generated from people consuming the processed news trends from the front end web interface (tx) than there is coming in from user uploads (rx). This is an expected pattern for the example web app.
You can use other command options to get top 10 days in a range, do PNG graphic outputs, and more.
As always, read the fancy manual (RTFM) page with man vnstat
for more possibilities.