Battling with BizTalk

Scripting Perfmon

Scripting Perfmon

 

We have a test team in India that I would like to run some load and performance testing. They have access to the required test server and load tools but limited experience using tools such as perfmon.

 

I have previously only used Perfmon to take a real-time view of performance counters, or used the ui to configure logging to a data file for later evaluation. In this particular case I didn't have access to the test server to enable me to manually configure the logging, and I know that trying to walk someone through this on the phone would be painful. After a little searching the web I discovered that it's possible to script the perfmon counter logging - exactly what I needed!

 

I started by creating a config file containing the counters that I wished to monitor. I called this baseling.cfg . It simply contains a unique line for each counter to be logged, as follows:

 

"\Memory\Available MBytes"

"\Memory\Pool Nonpaged Bytes"

"\Memory\Pool Paged Bytes"

"\PhysicalDisk(*)\Current Disk Queue Length"

"\PhysicalDisk(*)\Disk Reads/sec"

"\PhysicalDisk(*)\Disk Reads Bytes/sec"

"\PhysicalDisk(*)\Disk Writes/sec"

"\PhysicalDisk(*)\Disk Writes Bytes/sec"

"\Process(*)\% Processor Time"

"\Process(*)\Private Bytes

"\Process(*)\Virtual Bytes"

 

I then created a batch file containing the required command line to setup the data capture. I called the file create_data_collector.bat, it contains the following:

 

logman create counter BASELINE -f bincirc -max 200 -si 00:00:05 --v -o "c:\perfmon\serverbaseline" -cf "c:\perfmon\baseline.config"

 

To find out what the various parameters mean and other options available just run a quick google for 'logman'. In my particular case:

 

  •  I am creating a data collector called 'BASELINE', logging to file up to a max size of 200mb
  • The file is binary circular file, meaning that once it reaches maximum size it will begin overwriting the oldest records within the file
  •  The log is to be updated every 5 seconds
  • The file will be output to the folder c:\perfmon\serverbaseline
  • Counters to include in the log are contained within the previously mentioned configuration file: "c:\perfmon\baseline.config"

 

On first running the batch file locally (to test it) I received a message telling me that the data capture vehicle couldn't be created because of a permissions issue. I adjusted the permissions to the logging folder "c:\perfmon\serverbaseline" and all was good.

 

All that remained was to script to start the data collection. For this I created the batch file start_collector.bat, containing the following single line:

 

  • logman.exe start baseline

 

A few minutes after starting the logging I could see the log file beginning to grow. Great, I thought! I went back to the perfmon ui, clicked the 'view log data' button (looks like a db drum) and selected my new and continually growing log file. It didn't complain, and the current data view was cleared - but where was the historic data that should be been logged? I opened the log file in notepad - just binary data. I wanted to check that it was logging the data I expected so I deleted the BASELINE data collector, then re-created, choosing to log to text file, rather than binary. I then started logging, gave it a few minutes and opened the newly logged data in notepad. It appeared just as I expected, with column headers for my counters and lots of data for each subsequent row.

 

Great - I was logging the data but couldn't get it to appear in the perfmon graph! Then it struck me, in addition to choosing the data file as the data source for the perfmon graph I needed to add the counters to the graph. I hit the add button on the toolbar (+ symbol) and was presented with a dialog offering a limited set of counters - just the ones I'd specified in the baseline.cfg file. After selecting the counters, my historic data was displayed in the graph. Such a result called for celebratory cup of tea!


Feedback

No comments posted yet.