Thursday, July 31, 2014

How To: Gather Exchange 2010/2013 Transaction Log Statistics. #MSExchange #iammec

When you have the opportunity to engage with customers on a daily basis about Exchange, the high availability and disaster recovery story always seems to come up quickly. This discussion always turns into a pleasant conversation because Exchange has rich high availability features. As a result, I almost always find myself implementing Exchange 2010/2013 in at least two client data centers. Typically, one of the hard sells with adding a secondary data center (outside of $$) for a new Exchange installation comes down to defining the impact to the corporate WAN. Clients normally already have mission-critical SAN replication traffic going across the WAN and will be hesitant to add additional traffic.

Even though it is my job to ease customer fears – I still need to provide metrics to ensure that Exchange does NOT saturate a customer WAN. In times past, this required interrogating existing Exchange servers to understand how many logs where generated an hour. The transaction log data helps us to quantify the impact of adding database copies to a secondary data center. This always proved to be a painful and manual effort.

Enter the GetTransactionLogsStats script from Mike Hendrickson! Mike has created a script that analyzes transaction logs from a list of servers and/or databases and provides the statistics required to understand the proper sizing and replication of Exchange 2010/2013.

The script is required to run hourly for a predetermined amount of time (7-14 days). During the snapshot process, the log generation numbers are appended to a file. Specifically, Perfmon (MSExchangeIS HA Active Database\Current Log Generation Number) is utilized to record the current log generation number to a file called Logstats.csv.

It is best practice to run this script for 7-14 days to gather true representation of Exchange traffic. Once several days have snapshots have been created, the script will need to be run with the analyze switch. The script will read the data that has been appended to the Logstats.csv file and perform the calculations required to provide usable statistics for each server and/or database. A separate CSV file will actually be created for each server and/or database.


Now, let’s move on and show how the script actually works. The script will need to be downloaded from the TechNet script gallery. Once downloaded, select the Exchange 2013 server you would like to run the script from. Log into the selected server and create the folder C:\GetTransactionLogStats. 

Within this folder then create a file named TargetServers.txt. In this file add in the name of each Exchange 2010/2013 server that you need to collect log statistics from. There is also an option to report on specific databases on an Exchange server as well (srv3, mbx01).

Now, open up an Exchange Management Shell window and change the working directory to C:\GetTransactionLogStats. Since this script is not signed, you may need to change the execution policy (Set-ExecutionPolicy Unrestricted) on your Exchange server in order to properly run the script. At this point we can run the script from the Exchange Management Shell:

.\GetTransactionLogStats.ps1 -Gather -WorkingDirectory "C:\GetTransactionLogStats" -ResetStats

Mike recommends that this PowerShell command should be wrapped up into a script and added in the Scheduled Tasks on each Exchange server to run each hour (without the ResetStats option) to automate collection. Once the script is run for the first time, the LogStats.csv file is created. Each time the script is run the log generation snapshots are saved to the file.

After 7-14 days of appending the log generation snapshots we are ready to analyze the data. We now run the script from the Exchange Management Shell:

.\GetTransactionLogStats.ps1 -Analyze -LogDirectoryOut "C:\GetTransactionLogStats" -MaxSampleIntervalVariance 5 -MaxMinutesPastTheHour 10

After the analyze switch is run, a CSV file for all databases analyzed is created along with a file for each specific database specified in the TargetServers.txt. The analyze switch takes each log generation number in the LogStats.csv (over the 7-14 days) and displays how many logs that Exchange created.

The script works great and I have started to use this for all new engagements. I highly recommend heading over to the TechNet gallery to download Mike’s script If you are implementing Exchange 2013 in the near future (or work as a consultant)!


No comments:

Post a Comment