Friday, October 10, 2014

Capturing BizTalk Perfmon Values with PowerShell - Part 1

A couple of posts ago I commented on the recently released BizTalk Health Monitor snap-in that comes with BizTalk 2013.  Remember, this can be installed on just about any version of BizTalk.  It's nice to see some common BizTalk tools being integrated into the BizTalk Administration Console.

One of the things leadership tends to ask I.T. is what kind of value is BizTalk bringing to the company.  In my case, of course, the business leadership is asking: how many, how often, when, etc.

In my case, I've been tasked to do a few things:  determine what kind of load we have on the BizTalk servers.  A couple of reasons why:
  1. Throughput/load.  Management wants to understand "do we have a 'right-sized' environment?"  Keep in mind that Microsoft overhauled their licensing model not too long ago.  Instead of license per CPU, you now are being charged by the core.  This may cause a huge jump in licensing costs.  If BizTalk is constantly under 10% utilization, it may make sense to downsize the environment (by core, at least).  Or, in a worse-case scenario, show how much is really going through BizTalk to justify scaling up your BizTalk environment further.
  2. Understand which processes, applications, ports, etc. within BizTalk are being highly taxed or under-taxed.  In our case, we 'lease' our BizTalk environment to different entities within our organization.  We need to capture data to make sure we are properly charging our internal customer/entity base.
One of the things that the BizTalk Health Monitor has exposed for me are the NUMEROUS Instances that are available.

Also, within each Instance is the actual Counter you may want to monitor.


So knowing and understanding what counters exist is great, but viewing the BTHM Performance counters is a bit inefficient and really only gives you a general snapshot of about (default) 100 seconds .  Why not capture some performance counters and store it somewhere, either as a file or directly into a database?
Side Note: Light reading for those who are interested in documentation on some of these counters.
I recently came across the very excellent PowerShell extension SQLPSX on CodePlex.  All I can say is that the contributors here have done many people a huge favor with these modules.  In this particular case, Laerte Junior really deserves kudos.  I came across his Gathering Perfmon Data with PowerShell post, which led me to the CodePlex site.  Most of this entry follows Laerte's blog to the 'T'.  Credit also goes to Allen White, as one of his posts kicked this whole thing off.  I try to give credit where credit is due.  :)
Note: You will likely need to force PowerShell version 2 for the extensions to work.
Moving on.  You can either install SQLPSX or just copy the psm1 module to your environment.  For me, I just copied the module over and used the Import-Module command.

I wanted a quick list of ALL BizTalk counters and save them to a file.  Easy to do:

Opening the text file shows a rather comprehensive list.

Taking that one step further, I can now create an XML configuration file by using the command

And the results:

Warning: Before one gets too crazy here, make sure you either pair down the configuration file or add some extra filters to the PowerShell command when you generate a config file.  Please be selective with what you really want to monitor.

With that out of the way, we now can go to the next step (and the next blog) - gathering BizTalk performance data.

No comments: