Wednesday, May 8, 2013

Launching the Performance Monitor from the command line or script


On a Windows 2008 R2 server, I needed to launch the Performance Monitor with a built-in live report. That is targeted to support personnel and I don't want them to have to start it an add counters manually each time.

Man, that task proved to be more complex than I expected.

Here is what I've found in the last few days:

Solution 1: use IE
From the performance manager, the only option offered to save a custom report is to save it to an .HTML file which can then be launched from IE. That is clunky, as it has some ActiveX code and you need to acknowledge running it. Furthermore, when you load up that HTML page, you first have to press on the "play" icon to start the data collection, which is another useless step that I don't want support guys to have to do.

Solution 2: use Typeperf
There is a nice utility named "typeperf.exe" that can be used to dump specific counters to the console. It works, but for an odd reason, it can ONLY output CSV output to the screen. If you specify another format, it insists on dumping in a file. In essence it is a good quick-and-dirty tool for the console but not a terrific all-around solution.

Solution 3: use Perfmon in standalone mode (WE HAVE A WINNER!)
You can launch a standalone Permon using "perfmon /sys". This lets you add counters and, look at the magic, the standalone panel offers the possibility of saving that report in a .PerfmonCfg file. To load the file, simply click on it (or use "start meh.PerfMonCfg" within a batch file) and it will bring up a good old Perfmon report on the screen. That, in my opinion, is the best way to achieve my goal.

Sorry for the lack of details, but that should give you an idea.