Automating PerfMon Report Generation With PAL

After my blog post about the server diagnostics lifecycle, PerfMon and PAL, many of you asked me how the report automation could be set up. In this post, I’ll therefore outline a couple of ideas and provide you with some guidelines on how automation of PerfMon and PAL could be configured and scheduled in practice. In this post, you will find information on how to configure PerfMon and how to execute PAL from PowerShell to create fully automated diagnostics reports on a regular basis.

How to configurate PerfMon

1. Configure Data Collector Set

Download the latest version of PAL on codeplex, extract the contents and execute PALWizard.exe.
Navigate to the tab “threshold file”, select the desired software and click “Export to PerfMon template file”.

Export perfmon template

The output file contains all kinds of data collector configurations data points that will be measured in the local environment. Adapting the configuration file to connect to a remote server requires some manual work. To do so, open the exported perform template file, search for <Counter> and adapt the necessary connection by applying a “\\SERVERNAME” in front of each value. The illustration here under provides an example.

<Counter>\MSSQL$BIZTALKMESSAGEBOX:Latches()\Total Latch Wait Time (ms)</Counter>

becomes:

<Counter>\\SQLSERVER01\MSSQL$BIZTALKMESSAGEBOX:Latches()\Total Latch Wait Time (ms)</Counter>

2. Schedule PerfMon

First of all, open PerfMon.

open perfmon

Next, navigate to “Data Collector Sets” and create a new “User Defined” data collector set.

new data collector set

In the data collector set configuration, specify a name and click “Next”.

perfmon create new data collector set

Browse to the recent created data collector set .xml file and click “Finish”.

template data collector set

Now, open the configuration of the recent created data collector set: right click the chosen name and navigate to “Properties”. Change the username in the “Run As” configuration to an account with local admin rights on the remote server.

159

Open the tab “Schedule” and click “Add…”.
Configure the desired schedule window.

perfmon add schedule

Finally, open the tab “Stop Condition” and configure the desired stop condition.

perfmon stop condition

3. PAL execution

• Execute with PowerShell

NOTE: In this tutorial I won’t go into detail on how to execute PAL with the wizard, as this is not useful for an automated setup.

In addition to the classic (manual) wizard, the PAL tool is perfectly capable to interact from command line. The line below provides an example on how to execute this process. Adapt the necessary arguments according to the needs and environment you are working with. The most important parameters are:

  • $pal: reference to the .blg file; the output from PerfMon.
  • $thresholdFile: a configuration file that defines the minimum and maximal values of a measured value; the threshold.

$pal = "C:\PAL\Perflogs\BIZTALKSERVER1_PAL\capture.blg"
$thresholdFile = "C:\PAL\PAL_Flatfiles_v2.7.5_x64\SQLServer2012.xml"
Powershell -ExecutionPolicy ByPass -NoProfile -File “.\PAL.ps1” -Log $blg -ThresholdFile $thresholdFile -Interval “AUTO” -IsOutputHtml $True -HtmlOutputFileName “[LogFileName]_PAL_ANALYSIS_[DateTimeStamp].htm” -IsOutputXml $False -XmlOutputFileName “[LogFileName]_PAL_ANALYSIS_[DateTimeStamp].xml” -OutputDir $outdir -AllCounterStats $True -NumberOfThreads 2 -IsLowPriority $False -OS “64-bit Windows Server 2012” -PhysicalMemory “16” -UserVa “2048”

Process automation with PowerShell

Now that we know how to set up and configure PerfMon and execute the PAL analytics from the command line, all tools are in place to set up the automated reporting. The PerfMon process is scheduled weekly for 24 hours. This results in a .blg output file. To analyze the contents in an automated way, a PowerShell script can be created to:

  • Read a configuration (settings.xml) with references to:
    • Friendly name of the measured capture
    • The perfmon blg output file location
    • Threshold file location
  • Capture PerfMon file and move this towards an “archive location” for later detailed usage
  • Capture PerfMon file and executes the PAL process, which results into a report
  • Perform some cleanup of old folders.

PAL automation overview

Once the PerfMon has completed its task, you can execute the PowerShell script using your favorite scheduler tool, including SQL, Windows Scheduler, and custom frameworks. If you let it run an entire day, this will be done by midnight. Additionally, PerfMon offers the option to execute a program after the collection has been finished. I didn’t cover this in my tutorial, but that doesn’t mean I don’t consider it a valuable feature – especially if multiple processes are scheduled with different timings. The links down below show you a basic example of how this setup can be achieved.

That’s it for now!

In this post, we learnt how to set up a remote collection of PerfMon data counters as well as schedule and analyze them in an automated way without any manual interaction. If you want to make the process production-friendly, take care of error handling, logging and how to spread the reports online. For example, publish your reports on a SharePoint website or send them by email.

The main purpose is to give some guideline or useful ideas. Free free to extend the process, the sky is the limit!