vnStat

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.

This program is open source/GPL'ed and can be installed either as root or as a single user. Better instructions are included in the README. Feel free to send comments by email (remove the spamfilter) or try contacting me from irc (Vergo @ IRCNet). The forum is also once again available. Announcements about new versions can be obtained by subscribing to the vnStat project at freshmeat.net.


Why?

Some years ago (in 2002) I felt that I needed some kind of network traffic monitor to see how much traffic my server/router actually generated. I had been using mrtg for a while but the problem with it was that it didn't tell how many megabytes the daily traffic was.

Next I tested ntop, but it had far too many features compared to my needs. Then I found darkstat that was much smaller and stabler, but after using it for about a week, I came to a conclusion that a packet sniffer wasn't what I needed since it generates too much cpu load with high network traffic and requires the process running with root permissions. Since I needed something really simple but stable, I decided to write it by myself.


Downloads

External vnStat reladed links:
Screenshots

Since vnStat doesn't have/need a fancy GUI, all 'screenshots' are console captures. Examples of the image output can be found from the cgi demo page.


$ vnstat --help
 vnStat 1.7 by Teemu Toivola

         -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          select interface (default: eth0)
         -?,  --help           short help
         -v,  --version        show version
         -tr, --traffic        calculate traffic
         -l,  --live           show transfer rate in real time

See also "--longhelp" for complete options list and "man vnstat".

$ vnstat
Database updated: Sun Apr 12 21:25:01 2009

        eth1

           received:       1.40 TiB   (48.4%)
        transmitted:       1.50 TiB   (51.6%)
              total:       2.90 TiB   since 20.11.08

                        rx      |     tx      |   total
        ------------------------+-------------+------------
        yesterday      6.15 GiB |    8.50 GiB |   14.65 GiB
            today      6.98 GiB |    4.77 GiB |   11.75 GiB
        ------------------------+-------------+------------
        estimated      7.82 GiB |    5.35 GiB |   13.17 GiB

(with 2 interfaces)
$ vnstat

                      rx      /      tx      /     total    /   estimated
 Internet (eth1):
     yesterday      3.62 GiB  /    1.70 GiB  /    5.32 GiB
         today      2.73 GiB  /    1.83 GiB  /    4.57 GiB  /    5.10 GiB

 Local (eth0):
     yesterday      1.57 GiB  /    7.33 GiB  /    8.90 GiB
         today      1.67 GiB  /    3.21 GiB  /    4.88 GiB  /    5.45 GiB

$ vnstat -h
 eth1                                                                     21:25
  ^           r
  |           r
  |           r                                            r
  |        r  r                                            r
  |      t r  r                                            r            t
  |     rt r  r                                            r  r      t  t
  |     rt r  r                                            r  r      t  t
  |     rt r  r         t                      r           r  r      t  t
  |     rt r  rt        t                   r  r        r  rt rt  t rt rt  t
  |  rt rt rt rt rt r  rt r              r  r  r  r  rt rt rt rt rt rt rt  t
 -+--------------------------------------------------------------------------->
  |  22 23 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21

 h  rx (KiB)   tx (KiB)      h  rx (KiB)   tx (KiB)      h  rx (KiB)   tx (KiB)
22    250,801    205,825    06    100,529     49,054    14    205,356    157,877
23    705,144    885,844    07     52,806     44,130    15    258,228    226,265
00    928,792    224,789    08     52,298     45,230    16  1,028,043    343,843
01  1,271,180    292,260    09     70,396     61,719    17    755,804    293,309
02    212,296    186,481    10    155,502     72,451    18    235,691    284,886
03    165,931     91,943    11    266,673     92,497    19    275,554    658,386
04    150,997    437,071    12    392,244    122,185    20    307,819    850,813
05    180,170     56,391    13    133,829    120,555    21    117,474    292,787

$ vnstat -d

 eth1  /  daily

    day         rx      |     tx      |  total
------------------------+-------------+----------------------------------------
   14.03.      8.41 GiB |    6.57 GiB |   14.99 GiB  %%%%%%::::
   15.03.      7.81 GiB |    7.69 GiB |   15.50 GiB  %%%%%:::::
   16.03.     13.92 GiB |    9.70 GiB |   23.62 GiB  %%%%%%%%%:::::::
   17.03.     12.07 GiB |    8.68 GiB |   20.75 GiB  %%%%%%%%::::::
   18.03.     13.34 GiB |    7.72 GiB |   21.06 GiB  %%%%%%%%%:::::
   19.03.     27.82 GiB |    8.71 GiB |   36.53 GiB  %%%%%%%%%%%%%%%%%%%::::::
   20.03.      8.47 GiB |    6.32 GiB |   14.79 GiB  %%%%%%::::
   21.03.      6.48 GiB |    7.06 GiB |   13.54 GiB  %%%%:::::
   22.03.     10.07 GiB |    8.83 GiB |   18.90 GiB  %%%%%%::::::
   23.03.     10.78 GiB |    8.89 GiB |   19.67 GiB  %%%%%%%::::::
   24.03.      9.30 GiB |    9.51 GiB |   18.81 GiB  %%%%%%::::::
   25.03.     12.40 GiB |    9.81 GiB |   22.21 GiB  %%%%%%%%:::::::
   26.03.     11.17 GiB |   11.58 GiB |   22.75 GiB  %%%%%%%::::::::
   27.03.     12.40 GiB |    7.08 GiB |   19.48 GiB  %%%%%%%%:::::
   28.03.     12.42 GiB |    6.00 GiB |   18.42 GiB  %%%%%%%%::::
   29.03.     15.75 GiB |    8.80 GiB |   24.55 GiB  %%%%%%%%%%::::::
   30.03.     10.32 GiB |    8.39 GiB |   18.70 GiB  %%%%%%%:::::
   31.03.     15.53 GiB |   11.54 GiB |   27.07 GiB  %%%%%%%%%%::::::::
   01.04.      9.66 GiB |    7.20 GiB |   16.86 GiB  %%%%%%:::::
   02.04.     19.35 GiB |    9.21 GiB |   28.57 GiB  %%%%%%%%%%%%%::::::
   03.04.     11.62 GiB |   10.72 GiB |   22.34 GiB  %%%%%%%%:::::::
   04.04.     13.18 GiB |   10.61 GiB |   23.79 GiB  %%%%%%%%%:::::::
   05.04.     14.87 GiB |    9.39 GiB |   24.27 GiB  %%%%%%%%%%::::::
   06.04.      9.42 GiB |    9.33 GiB |   18.75 GiB  %%%%%%::::::
   07.04.      9.73 GiB |   21.84 GiB |   31.58 GiB  %%%%%%:::::::::::::::
   08.04.      7.28 GiB |    7.09 GiB |   14.36 GiB  %%%%%::::
   09.04.     10.45 GiB |    8.92 GiB |   19.37 GiB  %%%%%%%::::::
   10.04.     10.58 GiB |    5.50 GiB |   16.07 GiB  %%%%%%%::::
   11.04.      6.15 GiB |    8.50 GiB |   14.65 GiB  %%%%::::::
   12.04.      6.98 GiB |    4.77 GiB |   11.75 GiB  %%%%%:::
------------------------+-------------+----------------------------------------
 estimated     7.82 GiB |    5.35 GiB |   13.17 GiB

$ vnstat -m

 eth1  /  monthly

   month         rx      |      tx      |   total
-------------------------+--------------+--------------------------------------
  Nov '08      74.94 GiB |    96.48 GiB |   171.42 GiB  %%:::
  Dec '08     279.32 GiB |   276.05 GiB |   555.37 GiB  %%%%%%%%::::::::
  Jan '09     324.34 GiB |   413.38 GiB |   737.72 GiB  %%%%%%%%%%::::::::::::
  Feb '09     273.73 GiB |   362.49 GiB |   636.22 GiB  %%%%%%%%::::::::::
  Mar '09     353.50 GiB |   270.03 GiB |   623.53 GiB  %%%%%%%%%%::::::::
  Apr '09     129.27 GiB |   113.10 GiB |   242.37 GiB  %%%%:::
-------------------------+--------------+--------------------------------------
 estimated    326.58 GiB |   285.72 GiB |   612.30 GiB

$ vnstat -t

 eth1  /  top 10

   #       day          rx     |      tx     |  total
-------------------------------+-------------+---------------------------------
   1    20.02.09     19.15 GiB |   37.55 GiB |   56.70 GiB  %%%%%%::::::::::::
   2    02.02.09     20.65 GiB |   34.03 GiB |   54.68 GiB  %%%%%%:::::::::::
   3    14.01.09     20.00 GiB |   32.99 GiB |   52.99 GiB  %%%%%%::::::::::
   4    31.01.09     13.33 GiB |   29.83 GiB |   43.16 GiB  %%%%:::::::::
   5    30.12.08     30.52 GiB |   11.81 GiB |   42.33 GiB  %%%%%%%%%::::
   6    13.01.09     19.09 GiB |   20.43 GiB |   39.53 GiB  %%%%%%::::::
   7    04.02.09     13.16 GiB |   24.09 GiB |   37.25 GiB  %%%%:::::::
   8    19.03.09     27.82 GiB |    8.71 GiB |   36.53 GiB  %%%%%%%%:::
   9    20.01.09     11.92 GiB |   21.00 GiB |   32.91 GiB  %%%%::::::
  10    09.02.09     12.95 GiB |   19.26 GiB |   32.21 GiB  %%%%::::::
-------------------------------+-------------+---------------------------------

$ vnstat -w

        eth1  /  weekly

                            rx      |     tx      |  total
         ---------------------------+-------------+------------
          last 7 days     60.66 GiB |   66.02 GiB |  126.67 GiB
            last week     94.53 GiB |   67.07 GiB |  161.60 GiB
         current week     60.66 GiB |   66.02 GiB |  126.67 GiB
         ---------------------------+-------------+------------
            estimated     61.76 GiB |   67.22 GiB |  128.98 GiB

$ vnstat -tr
3103 packets sampled in 5 seconds
Traffic average for eth1

      rx          50.41 KiB/s           289 packets/s
      tx          82.11 KiB/s           331 packets/s

$ vnstat -l
Monitoring eth1...    (press CTRL-C to stop)

   rx:      63.06 KiB/s   365 p/s          tx:     112.84 KiB/s   436 p/s


 eth1  /  traffic statistics

                             rx       |       tx
--------------------------------------+----------------------------------------
  bytes                     3.83 MiB  |      5.63 MiB
--------------------------------------+----------------------------------------
          max           206.55 KiB/s  |  273.35 KiB/s
      average            63.21 KiB/s  |   93.01 KiB/s
          min            36.86 KiB/s  |   24.02 KiB/s
--------------------------------------+----------------------------------------
  packets                      17251  |         20214
--------------------------------------+----------------------------------------
          max                376 p/s  |       473 p/s
      average                278 p/s  |       326 p/s
          min                183 p/s  |       215 p/s
--------------------------------------+----------------------------------------
  time                  1.03 minutes


vnStat is © 2002-09 Teemu Toivola