Big Picture with vnstat

You,CLInetworktools

A co-located box on fat pipes will put pounds on you.

import Image from 'next/image'

A image of a server and removable drive stack

If you manage servers and need to provide some degree of reporting on network usage by those servers in a high level way (e.g. GBs of traffic passed through interface foo? last month), then you should check out vnstat (opens in a new tab).

For a Debian-ish Linux system, you might do something like this to get it installed:

sudo apt-get install vnstat

This will install vnstat and place a cron script in /etc/cron.d setting up vnstat that's executed every five minutes for the majority of each hour.

After vnstat has had some time to collect statistics, you can access them at the command line. Here are a some examples from the server that manages my collection of news trends on a multitude of topics:

Show usage for today and yesterday on all interfaces

vnstat
 
                     rx      /     tx      /    total    /  estimated
 eth0:
     yesterday      9.46 MB  /  205.37 MB  /  214.83 MB
         today      1.69 MB  /   62.77 MB  /   64.46 MB  /    1.12 GB
 
 eth1:
     yesterday     53.30 MB  /  459.31 MB  /  512.61 MB
         today      2.59 MB  /   37.22 MB  /   39.80 MB  /     710 MB

Show usage for all months on the primary interface

vnstat -m
 
eth0  /  monthly
 
  month         rx      |      tx      |   total
------------------------+--------------+------------------------------------
 Jun '10     358.13 MB  |     8.61 GB  |     8.96 GB   %::::::::::::::::
 Jul '10     294.29 MB  |     5.27 GB  |     5.56 GB   %:::::::::
 Aug '10     289.47 MB  |     6.31 GB  |     6.59 GB   %:::::::::::
 Sep '10     308.96 MB  |     6.25 GB  |     6.55 GB   %:::::::::::
 Oct '10      25.25 MB  |   697.73 MB  |   722.98 MB   :
------------------------+--------------+------------------------------------
estimated       379 MB  |    10.33 GB  |    10.71 GB

Show weekly usage on the primary interface

vnstat -w
 
eth0  /  weekly
 
                    rx      |       tx      |    total
----------------------------+---------------+--------------
  last 7 days     64.96 MB  |      1.49 GB  |      1.55 GB
    last week     69.49 MB  |      1.43 GB  |      1.50 GB
 current week     64.96 MB  |      1.49 GB  |      1.55 GB
----------------------------+---------------+--------------
    estimated        74 MB  |      1.72 GB  |      1.79 GB

There is considerably more traffic generated from people consuming the processed news trends from our front end web interface (tx) than there is coming in from user uploads (rx) which is expected for this particular application.

You can use other command options to get top 10 days in a range, do PNG graphic output, and more.

As always, read the fancy manual (RTFM) page with man vnstat for more possibilities.

© Brian Shumate.RSS