This is third part in series about how to work with performance counters in PowerShell and visualize them. The last step in our series is to display the data that we collected in previous post. The easier way is to generate HTML, the slitly more difficult – export to Excel – way will be covered next time.
The tool of choice is PowerShell, of course. We will use canvas to get pretty results. That's why you need to try it in Opera, Firefox, Chrome or Safari. Not in IE. It works in IE as well, although it is a little bit slow (tested in IE8).

Look at the result.

It displays counters related of Chrome browser when I started browsing Google Wave.

What we already know from previous posts

Start PowerShell console and get data from some performance counters.

[0]: Start-Job {
    d:\start-counters.ps1 `
        -dir c:\temp\counters\chrome-gw `
        -start (get-date) -end (get-date).addminutes(10) `
        -computer devol `
        -counterNames `
            'Process(chrome)\% Processor Time','Process(chrome)\% User Time','Process(chrome)\% Privileged Time',
            'Process(chrome)\Virtual Bytes','Process(chrome)\Working Set','Process(chrome)\Page File Bytes',
            'Process(chrome)\Private Bytes','Process(chrome)\Thread Count','Process(chrome)\Handle Count',
            'Process(chrome)\Working Set - Private' `
        -secsWait 5
}
[1]:  #we will wait 10 minutes until the task is finished
[2]: d:\Get-CountersData.ps1 C:\temp\counters\chrome-gw

First we collect data from counters and process them (convert them into csv and clixml files). If you are lost, check the two previous parts

Export to html

[3]: d:\Export-Counters2Html.ps1 -clixmlFile C:\temp\counters\chrome-gw\res.clixml `
        -outputFile C:\temp\counters\chrome-gw\res.html `
        -interestingCounters `
          'Process(chrome)\% Processor Time',`
          ('Process(chrome)\% User Time','Process(chrome)\% Privileged Time'),`
          ('Process(chrome)\Virtual Bytes','Process(chrome)\Working Set',`
              'Process(chrome)\Page File Bytes','Process(chrome)\Private Bytes',`
              'Process(chrome)\Working Set - Private'), `
          'Process(chrome)\Thread Count',`
          'Process(chrome)\Handle Count'

What are the parameters?

  • -clixmlFile is output of previous function Get-CountersData.ps1
  • -outputFile is path to file that will contain the result html such as my example html file
  • -interestingCounters specifies the counters that should be displayed. Note that it is array of arrays. The structure is as follows:
    (name of counter1 for first chart, name of counter2 of first chart,...),
    (name of counterx for second chart, (name of countery for second chart, ...),
    ...,
    counterA that is the only in 1000th chart, # this need not be an array, just string is ok
    ...
    So in my example 'Process(chrome)\% Processor Time' will be the only counter in first chart, whereas 'Process(chrome)\% User Time' and 'Process(chrome)\% Privileged Time' will be displayed together in second chart.

After you have run the Export-Counters2Html script, you need to do a final step. The charts are drawn using great canvas library jQuery Visualize Plugin. I prepared only the needed files – just download visualize.zip, and unzip it into folder with the resulting html. That's all.

If you don't use browser that supports canvas, look at the screen shot or in light box:

Result with the charts

Download

Download the PowerShell script for exporting to html and jquery canvas plugin that draws the charts.

Check all the parts

Today I've shown you how to visualize the data in your browser using html5 and canvas with help of PowerShell. In the last chapter we will try to achieve the same – visualize the data using charts in Excel.

  1. Series about performance counters [1] - how to read the data
  2. Series about performance counters [2] - process the data and export them
  3. Series about performance counters [3] - show me the data in my browser – currently reading
  4. Series about performance counters [4] - export data into Excel

Meta: 2009-10-29, Pepa