Welcome to MSDN Blogs Sign in | Join | Help

A Script to Paste Performance Counters into PerfMon

A Script to Paste Performance Counters into PerfMon   

Overview

Click Here to download the Script and supporting files as a .zip file

If you have or know of other cool PerfMon tricks, I would very much appreciate it if you would send me a pointer.

If you've spent much time using PerfMon you may have experienced frustration with using the UI to add counters to monitor real-time. I know that I did. What I wanted was script that would take two parameters, a filename of a text file containing a list of computers and a filename of a text file containing a list of counters.

The list of computers would simply look something like the following:

Computer1

Computer2

The list of counters would simply look something list the following:

Processor(_Total)\% Processor Time

LogicalDisk(_Total)\% Disk Time

The Usage of the Script would be as follows:

PastePerfCounters.ps1 Filename_Computers.txt Filename_Counters.txt

Items to Understand First

Perfmon has a "Paste Counters" button

In the image below, please notice the button bar portion of the System Monitor Snap-In. Specifically, notice 5th and 6th buttons from the right. These are the "copy" and "paste counters" buttons. Many people that I talk to were not familiar with this capability of PerfMon so I'm pointing it out here. After you run the script described in this post, the clipboard will contain properly formatted text that can be pasted into PerfMon using the "paste counters" button. I'm looking for a way to automate this part too and have the counters just land in PerfMon but I haven't found a satisfying solution yet. If you have ideas, please email

PerfMon Main Window

Details

Perfmon Goo

In the script below, you will notice two template files are used. These two files, called BaseTemplate.txt and CounterTemplate.txt, must be located in the same directory as this script in order for everything to run as designed. These two files contain a lot of PerfMon Goo that I didn't want to put in the script. If you look at the contents of these two files, you will quickly realize that this is just a bunch of PerfMon settings. Yes, please feel free to change the template to suit your needs by modifying default values. However, if you break this file you will still copy information to the clipboard but it might not paste successfully into Perfmon or have the desired effects. To avoid problems, a good idea might be to make a backup copy of the original template files before you modify.

Non-Existent machines or counters

If you have bogus information in your lists or if the counters pasted are not functional on a machine in the computer list, then you will encounter errors. When you do, Perfmon will likely give you a dialog telling you what counters were bogus and then Perfmon will happily work with the rest.

The Script, in Powershell of course!

# Get the path to where the script lives

$ScriptBase = split-path -parent $myinvocation.mycommand.path

# In the same folder as this .ps1 file should exist the BaseTemplate.txt file

# This file contains much goo required by PerfMon to control various setttings

# You can modify this Template, but save the origional in case you make an invalid change

# Note if the BaseTemplate.txt file is not located, the script will exit with an error

$BaseTemplatePath = Join-Path $ScriptBase "\BaseTemplate.txt"

$BaseTemplateContent = Get-Content $BaseTemplatePath

Write-Output "Base path : $BaseTemplatePath"

# In the same folder as this .ps1 file should also exist the CounterTemplate.txt file

# This file contains much goo required by PerfMon to control various setttings

# You can modify this Template, but save the origional in case you make an invalid change

# Note if the CounterTemplate.txt file is not located, the script will exit with an error

$CounterTemplatePath = Join-Path $ScriptBase "\CounterTemplate.txt"

$CounterTemplateContent = Get-Content $CounterTemplatePath

Write-Output "Counter path : $CounterTemplatePath"

# Validate the the user passed in the correct number of args and

# call Write-Error to print a noticable usage statement if they did not

if ( $Args.Length -ne 2 ) {

    Write-Error "usage: Add-Counters <file containing list of counters> <file containing list of computers>"

    return

}

# If we get this far, we believe that we have two parameters which shoudl represent filenames

# for the ComputerList and the CountersList files

$ListOfComputersFile = $Args[0]

$ListOfCountersFile = $Args[1]

# Get the content from the computer and coutners files

$ComputerList = Get-Content $ListOfComputersFile

$CounterList = Get-Content $ListOfCountersFile

# Instantiate an ArrayList for us to work with

$CounterCollection = New-Object System.Collections.ArrayList

foreach ( $Computer in $ComputerList ) {

    foreach ( $Counter in $CounterList ) {

        if ( $Counter.IndexOf("\") -ne 0 ) {

            $data = "\\$Computer\$Counter"

        }else{

            $data = "\\$Computer$Counter"

        }

        Write-Output "Adding counter : $data"

        $CounterCollection.Add($data)

    }

}

$NumberOfCounters = $CounterCollection.Count

Write-Output "Number of counters : $NumberOfCounters"

$OutputBuffer = ""

$index = 1

$color = 0

foreach ( $item in $CounterCollection) {    

$indexString = "0000" + $index

    if ($indexString.Length -gt 5 ) {    $indexString = "000" + $index }

    $OutputBuffer += [System.String]::Format($CounterTemplateContent, $item, $indexString, $color)    

    $index += 1

    $color += 10 }

#format the output

$BaseOutputBuffer = [System.String]::Format($BaseTemplateContent, $NumberOfCounters, $OutputBuffer)

$OutputFile = "temp_" + (Get-Date).ToString("ddMMyyyyhhmmss") + ".xml"

Add-Content $OutputFile $BaseOutputBuffer

#Copy to clip board

$BaseOutputBuffer | clip

Write-Output "Successfully added $NumberOfCounters counters to the clipboard"

Asks

If you find make any improvements to this script, please blog about them and post a comment on this posting pointing to your improvements.

Posted by robsteel | 1 Comments
Filed under:

BizTalk Performance Lab Delivery Guide – TOC v 0.02 – Please Comment

As promised, here is the deeper look at the Table of Contents for the BizTalk Performance Lab Delivery Guide.

As Pages are added to this site, I will update the links in this post.

Since the whole purpose of this site is to give the community a dirty read during the evolution process of the guide, please remember that everything is subject to change based upon community feedback.

Chapter 1, Introduction,

Chapter 2, A Lab Process, outlines a process and walks you through the process we use to conduct BizTalk Performance Labs on the BizTalk Ranger Team.

Chapter 3, Performance Factors, enumerates the Factors affect performance because if you don't know what to look out for it's hard to know where to start. This chapter starts by reiterating that the factors in Wayne Clark's 2004 paper are all still valid. Factors for 2006 are then discussed.

Chapter 4, Performance Metrics, is short but important as it provides reference material for learning about Performance Metrics used during a BizTalk Server Performance Lab. It's important to note that Performance Metrics involves many other technologies than BizTalk, like SQL Server, IIS, COM+, ASP.NET, etc.

Chapter 5, Performance Bottlenecks, enumerates the types of performance bottlenecks that can be encountered and offers guidance for identifying, isolating, measuring and tuning in each specific situation.

Chapter 6, Useful Tools, will probably be the most entertaining chapter since it will give how-to information on usage of various powerful tools and techniques.

Chapter 7, Engagement Documents, will provide those following the guide with a starting point from which to document the activity and planning for a performance lab engagement.

Introduction    6

What Is a BizTalk Performance Lab?    6

Who is the Audience?    6

Why was this Written?    6

A Process for Conducting Performance Labs    7

Before the Process Begins    9

The Scope Phase    9

Why Consider Scope?    10

A Document Engagement Summary    10

Hardware Diagram    14

High Level Architecture Diagram    16

The Plan Phase    16

Why Plan    17

Third-Party Software and Technology    17

Detailed Lab Hardware Stack    17

Detailed Lab Software Stack    18

Physical Space and other Logistics    18

The Prepare Phase    18

A Detailed Solution Design    19

The Application to be Tested    20

The Build Lab Phase    21

Build Lab Infrastructure    21

Configuring Third-Party Software    22

Configure Performance Monitoring    23

Run Automated Deploy    23

Run Automated Functional Testing    23

Run Automated Load Tests    23

Document Solution Performance Baseline    24

The Execute Phase    24

Performance Factors    24

Performance Factors in 2004    24

Performance Factors in BizTalk 2006    26

BAM    26

Host Design    26

Orchestrations    26

Receive Ports    26

Send Ports    26

The Tracking Host    26

The Tracking Service    26

Delivery Notification    26

Correlation    26

Message Size    26

Flat File Processing    27

Business Rules Engine    27

Performance Metrics    27

BizTalk Performance Metrics    27

SQL Server Performance Metrics    27

Windows Server 2003 Performance Metrics    28

IIS 6.0 Performance Metrics    28

ASP.Net Performance Metrics    28

Performance Bottlenecks    28

High-Level BizTalk System Bottlenecks    28

Items to Check First    29

Processing Host Queues    29

Specific Types of Performance Bottlenecks    29

Disk I/O Bottlenecks

CPU Bottlenecks

Memory Bottlenecks

Network I/O Bottlenecks

Database Contention Bottlenecks

MaxConnections Causing Bottlenecks

Thread Starvation Bottlenecks

Large Message Size Bottlenecks

XML Bottlenecks

Pipeline Bottlenecks

Tracking Bottlenecks

ASP.Net Bottlenecks

Errors and Exceptions Causing Bottlenecks

HTTP Bottlenecks

SOAP and Web Services Bottlenecks

MQ Series Bottlenecks

Throttling Bottlenecks

MaxReceiveInterval as Related to Latency and Bottlenecks    66

Useful Tools and How to Use Them    67

PerfMon    67

Tracelog.exe    67

Logman.exe    67

Log Parser    67

PALS    67

Performance Log Viewer 1.6 (toolbox)    67

SQLIO    67

Where to Obtain SQLIO    67

How to "Quickly" Use SQLIO    67

SQLIO Resources    67

SQLIOSIM    68

When To Use SQLIO vs. SQLIOSIM    68

Log Parser 2.2    68

RDCMan (toolbox)    69

Where to Obtain RDCMan    70

How to "Quickly" Use RDCMan    70

RDCMan resources    70

The F1 Profiler    70

PerfConsole    70

PowerShell Scripts Which Make use of These Tools    70

Engagement Documentation Examples

    70

BizTalk Performance Lab Delivery Guide TOC submitted for comment

I have seen instances where others have used blogs to evolve published works into more useful and powerful assets. I like this idea because it gets the content to the users, via the blog, before the publication date. I also like the concept of getting as much feedback as possible. This blog will attempt to serve this purpose for my upcoming "BizTalk Performance Lab Delivery Guide". I'm hoping that readers in the community will be generous with their comments and constructive criticism regarding the structure and content of this document.

To begin this experiment…

Please find below, a top-level outline for content which I intend to publish through an as yet to be determined mechanism. Effectively the content will all be available via this blog for those who like blogs, but it will eventually end up as a downloadable document of some sort, probably on MSDN. I'd like to ask the community to comment on the taxonomy of this material as it currently exists so that I can tailor the structure and content as much as possible, ultimately increasing the value to the community.

If you feel strongly that something is missing, organized strangely, off-topic or otherwise less than it could be I very much appreciate your comments.

You will a list in the bar on the left with links to the sections of the document as they are posted. This strategy will hopefully allow for more collaboration then the typical temporal organization of a blog would provide. Each section will have a separate page and if sections get long, sub-sections will have pages

If anyone has a better ideas, they are very welcome, please comment.

The top-level outline for this content is currently as follows: I will modify and add top-line sections based upon feedback from the community. In my next post I will elaborate on the next level of this outline. You can click the links to go to each section or you can also get to them via the Tags list on the left column of this blog.

NOTE: BPLDG is an abbreviation for BizTalk Performance Lab Delivery Guide.

Introduction

A Lab Process

Performance Factors

Performance Metrics

Perf Bottlenecks

Useful Tools

Example Engagement Docs

Initial Post – New BizTalk Performance Blog

·         Do you use BizTalk Server 2006?

·         Do you need to understand the performance characteristics of your BizTalk solutions?

·         Have you tried to document the performance of your solution and been frustrated by

o   A lack of specific information about BizTalk Performance

o   Not finding step-by-step guidance on profiling your solution’s performance

o   Other frustrations? (please comment or email me about your frustrations)

·         Have you had some success and want to share it with the world?

o   Were the results positive or negative?

o   What were the side effects?

o   What results did you get?

·         Do your customers or stakeholders require you to conduct a Performance Lab to document the solution of an existing or proposed solution?

·         Do you dream of a world in which visibility into the performance characteristics of your BizTalk Solution would be guided by some sort of dashboard or application?

o   What does your dream look like?

o   What would you have such a dashboard or application do and look like?

 

This blog is specifically for people who answer yes to two or more of these questions. I will commit to at least 3 posts weekly via this blog. I will discuss, explain, point to knowledge, give insight and guidance, discuss techniques and provide other informational nuggets regarding the performance of BizTalk solutions.

With the help of the community, via email and comments, this blog will hopefully evolve into three specific uses:

1.       A Compendium of Knowledge Regarding Performance of BizTalk Server 2006 based solutions

This blog will become a compendium of knowledge regarding the understanding, measurement, tuning and exploration of BizTalk Server 2006 Performance. I will write original content, point to interesting articles written by others, and provide a discussion forum for related ideas.

2.       Provide a living and ever improving Delivery Guide for conducting BizTalk Performance Labs

This section will begin by outlining a Table of Contents for such a guide, and proceed by fleshing out the initial TOC. Evolution of the guide will hopefully occur via feedback from the community on both the taxonomy and content included. This effort is started by me, but I sincerely hope that others will see value in the effort and want to contribute. Contributions from the community are always welcome and will, of course, be fully credited.

3.       Collaborate with the community to discuss and evolve a vision for an application or other type of automated capability which would deserve the title, ‘BizTalk Server Performance Explorer’

Do you wish that an application existed to help developers, architects, and IT Pros explore, understand, and document the performance of BizTalk Server solutions? I spend a lot of time thinking about just such an animal.

During my day job, I conduct Performance Lab engagements for some of Microsoft’s most strategic and visible BizTalk Server customers. My dream is to one day be replaced by an application that any developer could use to document a given BizTalk solution’s performance identify potential bottlenecks, and explore infrastructure, configuration and possibly application design changes that could remove the bottlenecks and optimize performance.

 

So, if you’ve read this far, I would invite you to subscribe to this blog via RSS and travel with me.  This journey will no doubt be rife with dragons, monsters and all manner of evil, but then some of us like dealing with such things. With some effort, we can take what was black magic and convert it into a science.

 

Posted by robsteel | 1 Comments
 
Page view tracker