As a server owner, it's important to keep track of your network usage over time. Many hosting providers will charge for bandwidth, so you'll want to keep on monitoring your month-to-month usage.
There are plenty of bandwidth monitoring tools out there---most real-time monitoring tools like
htop
and
glances
will show Rx (received) and Tx (transmitted) out. However, it's much more useful to look at daily and monthly averages and to do that, you'll need a tool that can keep logs over time.
Install vnstat
As for a generic Linux solution, though, you'll want to install vnstat.
The vnstat monitors all network interfaces and keeps logs on how much traffic your servers are handling, which can be used to present monthly, daily, and hourly averages of traffic. It also has the option of outputting to a PNG for a better-looking graph.
The vnstat is available from most main package managers. For Debian-based systems like Ubuntu, that would be:
sudo apt install vnstat
You'll also want to install vnstati for image output:
sudo apt install vnstati
If it isn't available on your package manager, you can download it from source https://humdi.net/vnstat/, and use make to build it for your system.
The vnstat will immediately start collecting data, but it will take a while for enough data to be collected actually to present anything. Come back to it in a few hours once it's collected some data, and run vnstat to view its output:
vnstat
This shows received GiB (RX), and transmitted GiB (TX), as well as a total and an estimate based on prior usage if the logs are incomplete. Keep in mind that this is in Gibibytes, not Gigabytes, though the difference isn't as much as the much smaller Gigabits.
If you want more detailed output, you can output hourly:
vnstat -h
To output an image summary, you can use the following command (-s for summary), replacing eth0 with whatever network device you want to view:
vnstati -s -i eth0 -o ~/network-log.png
You can also view hourly output in the same fashion.
vnstati -h -i eth0 -o ~/network-log.png
If you'd like to do a more in-depth analysis or send these logs off somewhere else, you can output all of vnstat's logs with the --json flag.