HOW TO MONITOR NETWORK BANDWIDTH WITH VNSTAT
- Category : Server Administration
- Posted on : Feb 20, 2016
- Views : 2,002
- By : Tadashi P.

vnStat is a console-based network traffic monitor for Linux and BSD that keeps a log of network traffic for the selected interface(s). It uses the network interface statistics provided by the kernel as information source. This means that vnstat won’t actually be sniffing any traffic and also ensures light use of system resources. However, in Linux at least a 2.2 series kernel is required.
It is very simple to install and use. It can monitor multiple network interfaces at the same time. It will display the output summary in hourly, daily, weekly and as well as monthly basis. And it can be used without root permissions.
Install vnstat
On Debian/Ubuntu:
1 user@centriohost# sudo apt-get install vnstat
On RHEL/CentOS:
vnstat will not be found in Official repositories, so add EPEL repository to install vnstat:
1 [root@server ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
Install vnstat with following command:
1 [root@server ~]# yum install vnstat -y
Usage
To view all network interfaces statistics, enter the following command:
1 user@centriohost# vnstat
This shows network bandwidth usage of all network interfaces:
rx / tx / total / estimatedeth1:Jul '13 4.77 MiB / 204 KiB / 4.97 MiB / 0 KiBtoday 4.77 MiB / 204 KiB / 4.97 MiB / --wlan0: Not enough data available yet.eth0: Not enough data available yet.
To view a particular interface bandwidth usage, enter the command:
1 user@centriohost# vnstat -i eth1
The above command will display the bandwidth usage of eth1:
Database updated: Thu Jul 4 13:26:10 2013eth1 since 07/04/13rx: 4.82 MiB tx: 249 KiB total: 5.07 MiBmonthlyrx | tx | total | avg. rate------------------------+-------------+-------------+---------------Jul '13 4.82 MiB | 249 KiB | 5.07 MiB | 0.13 kbit/s------------------------+-------------+-------------+---------------estimated -- | -- | -- |dailyrx | tx | total | avg. rate------------------------+-------------+-------------+---------------today 4.82 MiB | 249 KiB | 5.07 MiB | 0.86 kbit/s------------------------+-------------+-------------+---------------estimated -- | -- | -- |
To view the hourly usage, use the parameter “-h” without quotes:
user@centriohost# vnstat -i eth1 -heth1 13:31^ r| r| r| r| r| r| r| r| r| r-+--------------------------------------------------------------------------->| 14 15 16 17 18 19 20 21 22 23 00 01 02 03 04 05 06 07 08 09 10 11 12 13h rx (KiB) tx (KiB) h rx (KiB) tx (KiB) h rx (KiB) tx (KiB)14 0 0 22 0 0 06 0 015 0 0 23 0 0 07 0 016 0 0 00 0 0 08 0 017 0 0 01 0 0 09 0 018 0 0 02 0 0 10 0 019 0 0 03 0 0 11 0 020 0 0 04 0 0 12 0 021 0 0 05 0 0 13 4964 290
To view daily usage, use the parameter “-d”:
user@centriohostt# vnstat -i eth1 -deth1 / dailyday rx | tx | total | avg. rate------------------------+-------------+-------------+---------------07/04/13 4.82 MiB | 249 KiB | 5.07 MiB | 0.86 kbit/s------------------------+-------------+-------------+---------------estimated -- | -- | -- |To view weekly usage, use the parameter “-w”:
user@centriohostt# vnstat -i eth1 -weth1 / weeklyrx | tx | total | avg. rate---------------------------+-------------+-------------+---------------last 7 days 4.85 MiB | 290 KiB | 5.13 MiB | 0.07 kbit/scurrent week 4.85 MiB | 290 KiB | 5.13 MiB | 0.14 kbit/s---------------------------+-------------+-------------+------