Keeping a Log Of Daily Network Traffic for ADSL or Dedicated Remote Linux Server

Posted on in Categories CentOS, FreeBSD, Gentoo Linux, Howto, Linux, Monitoring, Networking, OpenBSD, RedHat/Fedora Linux, Suse Linux, Tips, UNIX last updated December 13, 2005

Almost a year ago, I wrote about Linux MRTG configuration how-to. However, some user seems to confused with MRTG, most users would like to know – how much traffic actually generated by ADSL/Cable service provider on daily and monthly basis.

MRTG is for network monitoring and it can be use to see how much traffic your server or ADSL router actually generated, however it will not tell you how much megabytes or gigabytes the daily traffic was. For all such home user and people having dedicated single Linux box hosted somewhere remote at IDC/ISP there is a tool called vnStat:

  • It is a console-base network traffic monitor for Linux (perfect tool for remote Linux box hosted at ISP)
  • It keeps a log of daily and monthly network traffic for the selected network interface(s).
  • It collects all data from /proc file system it means normal user can monitor traffic (no need to run vnstat as a root user)
  • Easy to setup & configure
  • Ease of use

Step # 1: Install vnstat

Debian / Ubuntu Linux user can install vnstat using apt-get command, enter:

# apt-get install vnstat 

Step # 2: Enable vnstat

Once installed, you need to create a database with the following command:

# vnstat -u -i eth0


  • -u :forces a database update for interface or creates the database if it doesn’t exist
  • -i eth0 : use to specify interface

Please note that it will start to collect data via cronjob:

0-55/5 * * * *   root    /usr/bin/vnstat -u

You do not have to install cronjob yourself; it should be automatically configure by apt-get.

Step # 3 View statistics

Display default traffic statistics

$ vnstat

Display daily traffic statistics

$ vnstat -d

Display monthly traffic statistics:

$ vnstat -m

Display all time top10 traffic days:

$ vnstat -t 

Try help option to get all query options:

$ vnstat --help

Read man page of vnstat for complete options and more information and download vnstat here

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

15 comment

  1. Just perfect so far! I haven’t accumulated a lot of stats yet but it seems to be working well!

    It is also a real bonus that it operates in the ‘background’, unobtrusive but efficient.

    Thanks for the effort and thanks for an excellent tool.

  2. This tool is really nice …It worked for me on my Ubuntu 8.10 distribution ,when coming to F10 its just didnt ….I’ve done the same config…Seems ” Not enough data available yet ” even after 3 days …

    But this is amazing tool with very less config …………

    Thanks for the Help

  3. any way to whitelist certain destinatons?

    australian ISPs enforce a monthly bandwidth quota on consumers. Most good australians ISP also provide larges amounts of locally mirrored data that don’t count towards that monthly quota.

    I’d like to white list some IP addresses in order to obtain a report relevant to usage affecting the monthly quota my isp provides me.

Leave a Comment