Monitor Bandwidth Usage with vnStat
Productivity Sauce
In these days of bandwidth caps and pay-per-kilobyte rates, keeping an eye on your bandwidth usage makes a lot of sense. While there is no lack of bandwidth monitoring utilities, vnStat stands out from the crowd thanks to its ability to store monitoring data in a database and resume monitoring automatically on reboot. This means that once installed and configured, vnStat quietly monitors a specified network interface and saves the collected data. You can then use vnStat's command parameters to view detailed reports of your bandwidth usage.
vnStat is available in the software repositories of many mainstream Linux distributions, so you can easily install it using your distro's package manager. On an Ubuntu-based system, vnStat can be installed using the sudo apt-get install vnstat command. Before you can start using the utility, you must specify the network interface you want vnStat to monitor. First, run the ifconfig command to view a list of all available network interfaces. You can then use the -u and -i parameters to create a database for the specified network interface, for example:
sudo vnstat -u -i wlan0
Once vnstat is configured, it needs some time to collect data. After that you can view the bandwidth usage statistics using the vnstat command. The utility sports a few rather useful parameters, too. The -d ( or --days) parameter displays the daily bandwidth usage, while the -w ( --weeks) and -m ( --months) parameters break down the statistics by week and month. You can view a full list of available parameters using either the vnstat --help or vnstat --longhelp command.
The packaged version of vnStat that is available in your distro's software repositories may not include vnStati -- a nifty utility which can turn dry text-only statistics into nice-looking graphs. In this case, if you want to analyze monitoring data visually, you have to compile vnStat from source. Fortunately, this is a rather straightforward procedure. First of all, make sure that you have all the tools necessary for building software from source. On Ubuntu, you can install them using the sudo apt-get install build-essential command. Next, install the libgd2-noxpm and libgd2-noxpm-dev libraries, using the sudo apt-get install libgd2-noxpm libgd2-noxpm-dev command. Download the latest .tar.gz version of vnStat from the project's Web site and unpack it. Switch to the resulting directory in the terminal and execute the make all command. Finally, run the sudo make install command to install the software. To generate a graph in the PNG format using VnStati, you have to specify at least three parameters: a graph type, a network interface, and the output file. For example, the command below produces a vnstat.png graphics file containing a traffic summary including hourly data using a horizontal layout:
vnstati -vs -i wlan0 -o ~/vnstat.png
Of course, you can use the vstati --help command to view a list of the available parameters.
Comments
comments powered by DisqusSubscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
Additional Tools
If anyone has additional network monitoring needs, let me suggest this website: http://www.activitymonitori...network_server_monitoring1.php
great tip
was easy to install through ubuntu's apt
I am trying to configure vnstat php fontend (http://www.sqweek.com/sqweek/index.php?p=1) must have for a server