vnStat is an open-source tool (GPL license) used to monitor network traffic on Linux and Unix systems. It provides real-time network traffic statistics for the network interfaces available on the system, including bandwidth usage and the total transmitted and received traffic.
It uses the network interface statistics provided by the kernel as its source of information. This means that vnStat doesn’t actually sniff any traffic, ensuring lightweight system resource usage regardless of network traffic rates.
It was developed by Teemu Toivola, a Finnish programmer who began working on the tool in 2004 as a personal project. He developed vnStat because he couldn’t find a simple network traffic monitoring tool that could run on Linux and Unix systems.
Installation and Usage Examples
To install vnStat on a Linux distribution, you can use the package manager of your distribution to install it directly from the repositories, or you can download and install it from the source code:
# apt install vnstat
# yum install vnstat
# pkg install vnstat
# wget https://humdi.net/vnstat/vnstat-2.10.tar.gz && tar -xzvf vnstat-*.tar.gz && cd vnstat-*/ && ./configure && make && make install && service vnstat restart
*Dependencies: build-essential libsqlite3-dev libncurses5-dev (Debian) or gcc ncurses-devel sqlite-devel (RHEL).
Once installed, vnStat is automatically configured to start collecting network traffic statistics on the default network interface. To view the traffic statistics, you can use the following commands:
- vnstat: shows a summary of the network traffic statistics for the default interface.
- vnstat -i <interface>: shows a summary of the network traffic statistics for the specified interface.
- vnstat -d: shows daily network traffic statistics.
- vnstat -h: shows hourly network traffic statistics.
- vnstat -m: shows monthly network traffic statistics.
- vnstat -l: shows real-time traffic statistics for the default interface.
Running the command vnstat --longhelp displays a list of all available options and arguments for the program. The output is as follows:
vnStat 2.10 by Teemu Toivola <tst at iki dot fi>
Query:
-q, --query query database
-s, --short use short output
-5, --fiveminutes [limit] show 5 minutes
-h, --hours [limit] show hours
-hg, --hoursgraph show hours graph
-d, --days [limit] show days
-m, --months [limit] show months
-y, --years [limit] show years
-t, --top [limit] show top days
-b, --begin <date> set list begin date
-e, --end <date> set list end date
--oneline [mode] show simple parsable format
--json [mode] [limit] show database in json format
--xml [mode] [limit] show database in xml format
--alert <output> <exit> <type> <condition> <limit> <unit>
alert if limit is exceeded
Modify:
--add add interface to database
--remove remove interface from database
--rename rename interface in database
--setalias set alias for interface
Misc:
-i, --iface select interface
-?, --help show short help
-D, --debug show some additional debug information
-v, --version show version
-tr, --traffic [time] calculate traffic
-l, --live [mode] show transfer rate in real time
-ru, --rateunit [mode] swap configured rate unit
--limit set output entry limit
--style select output style (0-4)
--iflist [mode] show list of available interfaces
--dbiflist [mode] show list of interfaces in database
--dbdir select database directory
--locale set locale
--config select config file
--showconfig dump config file with current settings
--longhelp show this help
See also "man vnstat" for longer descriptions of each option.
These are just a few examples of the commands you can use with vnStat. The tool also allows for configuration customization, defining new network interfaces, and exporting traffic data to different formats.
We hope this article was helpful 🙂. Remember, if you have any questions about this or any other topic related to your Clouding servers, feel free to write to soporte@clouding.io. We’re here for whatever you need!