vnStat – A lightweight (command line) network traffic monitor
vnStat is a console based (lightweight) network traffic monitor utility for Linux & BSD, that collect & store network interface statistics data (bytes transmitted & bytes received) information provided by the kernel (based on /proc & /sys filesystems) for the selected interfaces in a database for later analysis.
Kernel is the source for vnstat. So, it wont add any additional load to your system when you are running vnstat to capture the network traffic. Database file has been created based on the interface name at
/var/lib/vnstat/ and configuration file located
It will automatically discover the
eth0 interface and create database file & necessary directory too but not for other interfaces.
Make sure, you have to identify your network interface before creating database file with help of IP Command. Optionally we can generate png image output with help of gd library, make sure gd library installed on your system. If no, run the below command to install it.
[Install GD library on CentOS/Fedora] $ sudo yum install php-gd [Install GD library on Fedora 22 and later] $ sudo dnf install php-gd [Install GD library on Debian/Linux Mint/Ubuntu for php5] $ sudo apt-get install php5-gd [Install GD library on Debian/Linux Mint/Ubuntu for php7] $ sudo apt-get install php-gd [Install GD library on openSUSE] $ sudo zypper in php-gd [Install GD library on Mageia] $ sudo urpmi php-gd [Install GD library on Arch based system] $ sudo pacman -S php-gd
Traffic statistics data
- Hourly : It stores last 24 hours data on a hourly basics.
- Daily : It stores last 30 days data on a daily basics.
- Monthly : It stores last 12 months data on a monthly basics.
How to install vnStat
vnStat utility is available on distribution default repository, so just install like that with help of package manager based on distribution.
Note : CentOS/RHEL users need to install EPEL repositories in order to get vnstat package.
[Install vnStat on CentOS/Fedora] $ sudo yum install vnstat [Install vnStat on Fedora] 22 and later] $ sudo dnf install vnstat [Install vnStat on Debian/Linux Mint/Ubuntu] $ sudo apt-get install vnstat [Install vnStat on openSUSE] $ sudo zypper in vnstat [Install vnStat on Mageia] $ sudo urpmi vnstat [Install vnStat on Arch based distro] $ sudo pacman -S vnstat
Start the vnstat service by running below command.
[For systemd system] $ sudo systemctl statrt vnstat [For SysVinit system] $ sudo service vnstat start