vnstat

vnStat is a wonderful tool that will allow you to grab traffic information from you network interfaces.

From its homepage…

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.

Now let’s install it, for example in Debian:

apt-get install vnstat

Then create a new database to store data:

vnstat -u -i eth0

Please take note to change eth0 with the interface you want to monitor.

When vnstat has collected enough data you can start using it.

Show daily stats:

vnstat -d

eth0 / daily


day rx | tx | total
------------------------+-------------+-------------------------
18.10. 24.37 MB | 40.08 MB | 64.45 MB %::
19.10. 25.38 MB | 52.44 MB | 77.82 MB %:::
20.10. 31.53 MB | 48.58 MB | 80.11 MB %%::
21.10. 29.74 MB | 60.76 MB | 90.50 MB %%:::
22.10. 26.58 MB | 39.07 MB | 65.65 MB %::
23.10. 27.87 MB | 39.51 MB | 67.38 MB %::
24.10. 21.90 MB | 33.94 MB | 55.83 MB %::
25.10. 360.79 MB | 69.73 MB | 430.52 MB %%%%%%%%%%%%%%%%%%%%%::::
26.10. 31.44 MB | 58.90 MB | 90.34 MB %%:::
27.10. 29.08 MB | 39.57 MB | 68.65 MB %::
28.10. 28.98 MB | 39.78 MB | 68.76 MB %::
29.10. 27.16 MB | 40.00 MB | 67.16 MB %::
30.10. 26.07 MB | 68.56 MB | 94.63 MB %::::
31.10. 24.53 MB | 29.31 MB | 53.84 MB %::
01.11. 27.73 MB | 37.07 MB | 64.79 MB %::
02.11. 31.18 MB | 53.65 MB | 84.84 MB %:::
03.11. 36.02 MB | 56.06 MB | 92.08 MB %%:::
04.11. 33.21 MB | 54.05 MB | 87.26 MB %%:::
05.11. 29.01 MB | 39.66 MB | 68.67 MB %::
06.11. 26.97 MB | 45.86 MB | 72.83 MB %:::
07.11. 25.08 MB | 32.49 MB | 57.57 MB %::
08.11. 65.92 MB | 44.18 MB | 110.09 MB %%%%::
09.11. 29.99 MB | 58.19 MB | 88.18 MB %%:::
10.11. 31.84 MB | 58.90 MB | 90.74 MB %%:::
11.11. 29.44 MB | 50.83 MB | 80.28 MB %:::
12.11. 28.17 MB | 36.99 MB | 65.16 MB %::
13.11. 26.67 MB | 31.74 MB | 58.42 MB %::
14.11. 26.06 MB | 30.40 MB | 56.46 MB %::
15.11. 31.31 MB | 45.36 MB | 76.67 MB %%::
16.11. 26.83 MB | 45.36 MB | 72.20 MB %:::
------------------------+-------------+-------------------------
estimated 31 MB | 54 MB | 85 MB

Show monthly stats:

vnstat -m

eth0 / monthly


month rx | tx | total
-------------------------+--------------+-----------------------
Dec '09 780.78 MB | 1.33 GB | 2.10 GB %%%%%::::::::
Jan '10 888.01 MB | 2.50 GB | 3.37 GB %%%%%%::::::::::::::::
Feb '10 702.00 MB | 1.30 GB | 1.98 GB %%%%::::::::
Mar '10 776.67 MB | 1.42 GB | 2.18 GB %%%%%:::::::::
Apr '10 1.01 GB | 1.54 GB | 2.55 GB %%%%%%::::::::::
May '10 831.43 MB | 1.56 GB | 2.37 GB %%%%%::::::::::
Jun '10 831.70 MB | 1.34 GB | 2.15 GB %%%%%:::::::::
Jul '10 859.46 MB | 1.61 GB | 2.45 GB %%%%%:::::::::::
Aug '10 870.38 MB | 1.50 GB | 2.35 GB %%%%%::::::::::
Sep '10 814.80 MB | 1.39 GB | 2.19 GB %%%%%:::::::::
Oct '10 1.13 GB | 1.34 GB | 2.47 GB %%%%%%%:::::::::
Nov '10 505.44 MB | 720.80 MB | 1.20 GB %%%::::
-------------------------+--------------+-----------------------
estimated 959 MB | 1.33 GB | 2.27 GB

Show the top 10:

vnstat -t

eth0 / top 10


# day rx | tx | total
-------------------------------+-------------+------------------
1 23.06.09 64.76 MB | 1.95 GB | 2.02 GB %:::::::::::::::::
2 06.01.10 50.75 MB | 1.13 GB | 1.18 GB ::::::::::
3 25.10.10 360.79 MB | 69.73 MB | 430.52 MB %%%
4 19.04.10 130.48 MB | 156.69 MB | 287.17 MB %:
5 20.05.09 76.08 MB | 177.39 MB | 253.48 MB %:
6 27.08.09 142.93 MB | 50.10 MB | 193.03 MB %
7 28.04.10 134.25 MB | 58.06 MB | 192.31 MB %
8 06.11.09 132.06 MB | 59.30 MB | 191.35 MB %
9 25.05.09 49.61 MB | 124.27 MB | 173.88 MB :
10 21.05.09 30.63 MB | 139.71 MB | 170.34 MB :
-------------------------------+-------------+------------------

For more info:

  • vnstat --help

Tags: , ,

Leave a Reply

You must be logged in to post a comment.