Compartir a través de


Bandwidth Logging Sample Application

The Bandwidth Logging sample shows you how to create an agent that responds to the OnSubmittedMessage and OnRoutedMessage events, captures bandwidth usage for specified recipients, and logs the bandwidth usage information to a text file.

To download this sample, download the Exchange 2010 Transport Agents SDK from the Microsoft Download Center.

Prerequisites

You must have the following before you use this agent:

  • A recipient whose bandwidth is to be logged. You can create and log bandwidth for multiple recipients.

  • A distribution list that contains the recipients to be logged. This distribution list must have an Simple Mail Transfer Protocol (SMTP) address of "BandwidthLogging" without a domain part.

  • A "FromInternet" receive connector.

  • A "ToInternet" send connector.

A message must arrive on a FromInternet receive connector and be delivered over a send connector that does not deliver to the Internet for the message to count in the incoming bandwidth of a recipient.

A message must leave the system through a ToInternet send connector to be counted in the outgoing bandwidth of a recipient.

Structure of the Sample

The Bandwidth Logging sample agent consists of a simple MicrosoftVisual Studio .NET 2005 C# project. By default, the files are installed in the directory in which the Microsoft Exchange Server 2010 Transport Agents Software Development Kit (SDK) is installed, in the \Samples\BandwidthLogging folder.

The following are the primary files for the sample:

  • Install.ps1   An Exchange Management Shell script that installs the compiled sample.

  • Uninstall.ps1   An Exchange Management Shell script that uninstalls the compiled sample.

  • BandwidthLogging.csproj   The Visual Studio C# project file.

  • BandwidthLogging.cs   The C# source code for the sample.

Building the Sample

To build the Bandwidth Logging sample agent, you must first install Visual Studio .NET 2005 and the Microsoft.NET Framework version 2.0 on the computer that is running Exchange 2010 that has the Hub Transport server role installed.

After you install the required software, open the C# project by using Visual Studio .NET. If it is necessary, update the references to the Microsoft.Exchange.Data.* namespaces. Build the project and fix any errors you encounter.

Installing the Sample

To install the Bandwidth logging sample agent

  1. Edit the install.ps1 script to make sure that the $EXDIR variable is correctly initialized for your system. The value of the $EXDIR variable should be the path of the Exchange Server 2010 installation directory.

  2. Open the Exchange Management Shell and run the install.ps1 script.

  3. Exit the Exchange Management Shell.

Uninstalling the Sample

To uninstall the Bandwidth Logging sample agent

  1. Edit the uninstall.ps1 script to make sure that the $EXDIR variable is correctly initialized for your system. The value of the $EXDIR variable should be the path of the MicrosoftExchange Server 2010 installation directory.

  2. Open the Exchange Management Shell and run the uninstall.ps1 script.