How To Monitor Your Linux Network Bandwidth Usage
By Pete Freitag
Expert Author
Article Date: 2009-01-30
Did you ever wonder how much bandwidth your linux server is using each month, or each day? There are a number of tools that can give you this information, but many of them are packet sniffers, and can effect performance.
I recently came across a really nice lightweight tool that monitors your network bandwidth utilization on Linux (actually I just learned that it also works on BSD operating systems as well, eg. Mac OSX , so I am running it on my desktop now as well) called vnstat. It works by analyzing the /proc stats on Linux (at regular intervals using a cron job), and then stores summaries in a really small database.
You can then access these stats whenever using the vnstat command line utility.
For example if you run vnstat -m it will generate a nice plain text summary report:
month rx | tx | total
-------------------------+--------------+--------------------------------------
Dec '08 1.10 GB | 28.88 MB | 1.13 GB %%%%%%%%%%%%%%%%%
Jan '09 1.35 GB | 68.79 MB | 1.41 GB %%%%%%%%%%%%%%%%%%%%%:
-------------------------+--------------+--------------------------------------
estimated 2.21 GB | 111 MB | 2.31 GB
That particular server is only being used for backups right now, so the numbers are kind of low.
Highly recommend this tool if you are looking for a simple and lightweight way to monitor network bandwidth.
Here's a full list of command line options:
-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
Comments
About the Author: Pete Freitag (http://www.petefreitag.com/) is a software engineer, and
web developer located in central new york. Pete specializes in the
HTTP protocol, web services, xml, java, and coldfusion. In 2003 Pete
published the ColdFusion MX Developers Cookbook with SAMs Publishing.
Pete owns a Firm called Foundeo (http://foundeo.com/) that specializes
in Web Consulting, and Products for Web Developers.
|