NEW VERSION
I have added a GUI interface now to the project (pictured below).  It now allows for customizations of the reported data by setting user defined packet size, the bandwidth units to display (bytes, kilobytes, etc), the ability to exclude specific users, and group the summary results by login or by hour.
GUI
I was in the process of migrating the database servers for one of our applications from an onsite local server to a third party hosted server on the internet. One of the key factors that goes into which hosting package to purchase is how much bandwidth will be required for communication between the client and server. To determine the most cost effective solution I needed to figure out how much bandwidth each Microsoft SQL Server instance was using on a daily and monthly basis. Unfortunately Microsoft SQL Server 2005 doesn't have a built in tool to track this so I turned to the trusty internet to try and find one.

I found a ton of tools that were way overkill for the kind of data that we wanted. After some serious digging I finally found a simple application developed by the guys at Hosts Tools that is amazingly easy to configure and setup and does just what I needed. They call it the SQL Bandwidth Meter. It requires the Windows Packet Capture (WinPCap) library so make sure you install that first (it comes in the download package).

Once the application is setup, it will log the number of packets received and the number of packets sent by a given Microsoft SQL Server instance on a per user level every hour. It is a Windows service so it can run in the background without any user having to be logged in.

The log file is just a csv file in the format of [Hour],[SQL_Login],[Packets_In],[Packets_Out] (see sample below).

0,,0,0
1,,0,0
2,,0,0
3,,0,0
4,,0,0
5,,0,0
6,,0,0
7,,0,0
8,administrator,29120,29119
8,Shea,1678,2236
8,nick,1637,2181
9,Jaalisa,3591,4928
9,Shea,7532,8972
...

The default packet size set by Microsoft SQL Server is 4,096 bytes or 4 Kilobytes as indicated in the documentation here. Since the application logs the number of packets sent and received and not the number of bytes a bit of simple math is required to calculate bandwidth used. As a true computer programmer, instead of just opening the log file up in Excel and writing a simple summation formula, I wrote this application that parses the log files and performs the calculations and conversions automatically. I am monitoring multiple instances and thus have multiple log files so when the application starts up, you are prompted to enter the path to the directory that contains the log files.

Last edited Aug 24, 2010 at 2:15 PM by nickolsen, version 12