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:
user@vpscheap.net# sudo apt-get install vnstatOn RHEL/CentOS:
vnstat will not be found in Official repositories, so add EPEL repository to install vnstat:
[root@server ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpmInstall vnstat with following command:
[root@server ~]# yum install vnstat -yUsage
To view all network interfaces statistics, enter the following command:
user@vpscheap.net# vnstatThis shows network bandwidth usage of all network interfaces:
rx / tx / total / estimated eth1: Jul '13 4.77 MiB / 204 KiB / 4.97 MiB / 0 KiB today 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:
user@vpscheap.net# vnstat -i eth1The above command will display the bandwidth usage of eth1:
Database updated: Thu Jul 4 13:26:10 2013 eth1 since 07/04/13 rx: 4.82 MiB tx: 249 KiB total: 5.07 MiB monthly rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- Jul '13 4.82 MiB | 249 KiB | 5.07 MiB | 0.13 kbit/s ------------------------+-------------+-------------+--------------- estimated -- | -- | -- | daily rx | 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@vpscheap.net# vnstat -i eth1 -h eth1 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 13 h rx (KiB) tx (KiB) h rx (KiB) tx (KiB) h rx (KiB) tx (KiB) 14 0 0 22 0 0 06 0 0 15 0 0 23 0 0 07 0 0 16 0 0 00 0 0 08 0 0 17 0 0 01 0 0 09 0 0 18 0 0 02 0 0 10 0 0 19 0 0 03 0 0 11 0 0 20 0 0 04 0 0 12 0 0 21 0 0 05 0 0 13 4964 290To view daily usage, use the parameter “-d”:
user@vpscheap.net# vnstat -i eth1 -d eth1 / daily day 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@vpscheap.net# vnstat -i eth1 -w eth1 / weekly rx | tx | total | avg. rate ---------------------------+-------------+-------------+--------------- last 7 days 4.85 MiB | 290 KiB | 5.13 MiB | 0.07 kbit/s current week 4.85 MiB | 290 KiB | 5.13 MiB | 0.14 kbit/s ---------------------------+-------------+-------------+--------------- estimated -- | -- | -- |And to view monthly usage, use “-m”:
user@vpscheap.net# vnstat -i eth1 -m eth1 / monthly month rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- Jul '13 4.85 MiB | 290 KiB | 5.13 MiB | 0.14 kbit/s ------------------------+-------------+-------------+--------------- estimated -- | -- | -- |To see top ten network bandwidth usage of eth1:
user@vpscheap.net# vnstat -i eth1 -tTo view the bandwidth usage of 5 seconds, enter the following command:
user@vpscheap.net# vnstat -i eth1 -trTo view the usage of 10 seconds, enter the following command:
user@vpscheap.net# vnstat -i eth1 -tr 10Finally to see the real live bandwidth usage of eth1:
user@vpscheap.net# vnstat -i eth1 -lThis command will collect the network bandwidth usage of eth1. You can stop the process by pressing CTRL+C at any time.
Sample Output:
Monitoring eth1... (press CTRL-C to stop) rx: 0 kbit/s 0 p/s tx: 0 kbit/s 0 p/s rx: 0 kbit/s 0 p/s tx: 0 kbit/s 0 p/s^C eth1 / traffic statistics rx | tx --------------------------------------+------------------ bytes 17.96 MiB | 4.48 MiB --------------------------------------+------------------ max 3.78 Mbit/s | 420 kbit/s average 31.62 kbit/s | 7.90 kbit/s min 0 kbit/s | 0 kbit/s --------------------------------------+------------------ packets 22511 | 21780 --------------------------------------+------------------ max 336 p/s | 206 p/s average 4 p/s | 4 p/s min 0 p/s | 0 p/s --------------------------------------+------------------ time 77.55 minutesHope you have a basic idea about vnstat.
Happy Monitoring!