vnStat is a free OpenSource (GPL License) network traffic monitor for Linux that keeps a log of daily network traffic for the selected interface(s) on the system. Unlike other Network Traffic monitors, vnStat analyzes the traffic information from the /proc filesystem. And, vnStat can be used even without root permissions.
vnStat maintains a database for every interface for which the network traffic analysed. We can watch the live Traffic status on the selected interface(s) or run reports on Hourly, Daily, Weekly and Monthly bandwidth statics for the selected network interfaces.
To install vnStat, all you need is the required C compiler installed.
Here I install vnStat on a Debian 4.0R2 system
Download vnStat
Download the vnStat from here
DebianSystem# wget http://humdi.net/vnstat/vnstat-1.6.tar.gz
Unzip & Untar the downloaded the file
DebianSystem# tar -zxvf vnstat-1.6.tar.gz
Install C Compilers
Ensure that the required C compilers are installed in the system. In debian to install the required packages to compile
DebianSystem# aptitude install build-essentials
ChangeDirectory & Install
DebianSystem# cd vnstat-1.6
DebianSystem:/vnstat-1.6# make
DebianSystem:/vnstat-1.6# make all
That installs the vnStat Bandwidth monitoring software.
Test the Kernel
DebianSystem# vnstat –testkernel
Create Interface Database
Run the following to create a database for each of the interfaces that you would want to monitor traffic bandwidth on.
DebianSystem# vnu -u -i eth0
This creates a database for the interface eth0
Now, give it a few minutes to collect enough data to provide useful statistics.
To show the summary simply type vnstat
DebianSystem# vnstat
Database updated: Sun Dec 2 22:20:01 2007inet (eth0)
received: 735.00 GB (48.9%)
transmitted: 769.38 GB (51.1%)
total: 1.47 TBrx | tx | total
———————–+————+———–
yesterday 23.35 MB | 20.25 MB | 43.60 MB
today 27.47 MB | 21.37 MB | 48.84 MB
———————–+————+———–
estimated 29 MB | 22 MB | 51 MB
To show hourly statistics
DebianSystem# vnstat -h
inet (eth0) 22:15
^ r
| rt r
| rt rt
| rt rt
| r rt rt
| rt r rt rt
| rt rt rt rt rt
| rt rt rt r r rt r rt r rt rt rt
| rt rt rt r rt rt rt rt rt rt rt rt rt
| rt rt rt rt r r r r r rt rt rt rt rt rt rt rt rt rt
-+—————————————————————————>
| 23 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22h rx (kB) tx (kB) h rx (kB) tx (kB) h rx (kB) tx (kB)
23 1,352 1,219 07 277 151 15 1,352 1,165
00 2,281 2,140 08 402 158 16 1,487 878
01 1,485 1,261 09 290 155 17 1,752 1,559
02 648 522 10 589 185 18 1,455 1,001
03 392 261 11 650 202 19 2,332 1,835
04 323 240 12 907 350 20 3,881 3,619
05 311 179 13 1,234 1,044 21 3,695 3,237
06 281 173 14 1,221 812 22 675 591
Other options are
-q, –query query database
-h, –hours show hours
-d, –days show days
-m, –months show months
-w, –weeks show weeks
-t, –top10 show top10
-s, –short use short output
-u, –update update database
-i, –iface change interface (default: eth0)
-?, –help short help
-v, –version show version
-tr, –traffic calculate traffic
-l, –live show transfer rate in real time