How to monitor bandwidth on Ubuntu Server

I wanted to monitor the bandwidth usage on my Ubuntu server without a full blown graphic monitoring system but something that I could just check once in a while just to see how things are running. I found an really simple tool called vnstat. It’s good because it’s simple, fast and easy to use and that doesn’t require a PhD in networking to get going. It also nicely presents the data with good summaries.

Here is how I setup network traffic monitoring using vmstat:

1 – Install vnstat – note there is another program called vmstat – so be careful what you type.

sudo apt-get install vnstat

2 – Configure the network adapter to monitor. Vnstat automatically configures the network adapters however it’s worth checking that they are correct and having a quick peek through the configuration file.

sudo nano /etc/vnstat.conf

If you do have made any change then don’t forget to restart the service.

sudo service vnstat restart

3 – Get you first report – You will have to wait a few minutes to get your first report. This how a typical report looks like:

#vnstat

outputs:


Database updated: Sun Nov  9 20:11:55 2014

   eth0 since 07/22/14

          rx:  4.56 GiB      tx:  109.97 GiB      total:  114.53 GiB

   monthly
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
       Oct '14      1.24 GiB |   38.39 GiB |   39.63 GiB |  124.13 kbit/s
       Nov '14    361.70 MiB |    9.56 GiB |    9.91 GiB |  108.84 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated      1.20 GiB |   32.43 GiB |   33.62 GiB |

   daily
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     yesterday     37.62 MiB |  805.67 MiB |  843.29 MiB |   79.96 kbit/s
         today     29.32 MiB |  176.40 MiB |  205.73 MiB |   23.18 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated        34 MiB |     209 MiB |     243 MiB |

Hope this is useful to someone. Let’s me know if you have any improvements to this post or can recommend other tools that readers of this blog might be interested in.

Leave a Reply