Simple bandwidth monitoring on Linux

If you want a simple lightweight tool to monitor the network traffic in and out of your server vnstat might be just what you need. It keeps hourly, daily and monthly records and provides simple estimates of your expected use, it is also easy to link up to a web based frontend for fancy charts and reporting.

Installing and configuring vnstat is very simple, firstly install using your standard package manager, for example:


apt-get install vnstat


yum install vnstat

Then tell vnstat to create a database for the network interfaces you want to listen to (e.g. eth0):

vnstat -u -i eth0

That’s it, wait a few minutes then run vnstat to view a simple console display of the amount of traffic that has traveled though all the interfaces you’re monitoring:

   eth0 since 01/22/12
          rx:  177.59 MiB      tx:  7.78 MiB      total:  185.37 MiB
                     rx      |     tx      |    total    |   avg. rate
       Jan '12    177.59 MiB |    7.78 MiB |  185.37 MiB |    0.59 kbit/s
     estimated       183 MiB |       7 MiB |     190 MiB |
                     rx      |     tx      |    total    |   avg. rate
     yesterday     12.53 MiB |    1.36 MiB |   13.89 MiB |    1.32 kbit/s
         today      8.28 MiB |     127 KiB |    8.40 MiB |    0.88 kbit/s
     estimated        --     |      --     |      --     |

You can also get vnstat to dump its output in a programming friendly format (semicolon delimited):

vnstat --dumpdb

If you do want a nicer looking interface or one that doesn’t require shell access have a look at: vnstat PHP frontend

If you need a bandwidth monitoring solution that records the utilization of individual protocols instead of just received and transmitted traffic then have a look at bandwidthd

  • sam

    ifstat is a billion times better cos it doesn’t have all this interactive nonsense.

    This is how easy it is to get a log of network usage with ifstat:

    ifstat -t >/path/to/log

    HOW EASY!!!! Imagine trying to get a log with vnstat – would take YEARS OF HASSLE TO WORK IT OUT.

    Then with a little bash ifstat wrapper you can get exactly what you want – none of these overly complicated ridiculous tools that take ages to work out how to get a simple log of blooming network usage!!

    • Seb Dangerfield

      Sounds like you’ve had a bad experience with vnstat. I’m not sure which part of vnstat you are referring to when you say “interactive” because none of the commands I use require any interactivity. To get vnstat to write its’ database to a file doesn’t take “YEARS OF HASSLE” of the caps lock key. It simply involves reading the man page and using the command:

      vnstat --dumpdb

      vnstat is also quite a simple tool, why do you believe it is “overly complicated”?

      The man page for vnstat explains how to use it in a reasonable amount of detail so it shouldn’t take “ages to work out how to get a simple log”. However there are numerous other tools that perform a similar roll to vnstat with more or less functionality and it depends on your requirements as to which one is the best for you.