Using TypePerf to get performance data on the command prompt.

I was tracking a high CPU issue this week and needed to know when one of my servers was pegged so I could investigate.  I could of used perfmon I guess but I really like to do everything I can from the command prompt.  I always like it when there is a tool that can do data collection from the command prompt as this gives you the ability to easily script it if warranted.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/nt_command_typeperf.mspx?mfr=true

C:\Windows\system32>typeperf "\\Server1\Processor(_Total)\% Processor Time"

"(PDH-CSV 4.0)","\\Server1\Processor(_Total)\% Processor Time"
"09/20/2007 15:42:42.926","18.097697"
"09/20/2007 15:42:43.928","21.217785"
"09/20/2007 15:42:44.929","15.757631"
"09/20/2007 15:42:45.931","16.537653"

The command completed successfully.

You can collect any counter that lives in the perfmon world, I'm sure some of you out there will find a use for this.

C:\Debuggers>typeperf "\\serverX\Server\Server Sessions" -sc 2

"(PDH-CSV 4.0)","\\serverX\Server\Server Sessions"
"09/22/2007 13:21:54.110","8.000000"
"09/22/2007 13:21:55.117","8.000000"

The command completed successfully.

Full Syntax below, you can adjust the collection in numerous ways.

C:\Debuggers>typeperf -?

Microsoft r TypePerf.exe (6.0.6001.16656)

Typeperf writes performance data to the command window or to a log file. To stop Typeperf, press CTRL+C.

Usage:
typeperf { <counter [counter ...]> | -cf <filename> | -q [object] | -qx [object] } [options]

Parameters:
<counter [counter ...]> Performance counters to monitor.

Options:
-? Displays context sensitive help.
-f <CSV|TSV|BIN|SQL> Output file format. Default is CSV.
-cf <filename> File containing performance counters to monitor, one per line.
-si <[[hh:]mm:]ss> Time between samples. Default is 1 second.
-o <filename> Path of output file or SQL database. Default is STDOUT.
-q [object] List installed counters (no instances). To list counters for one object, include the object name, such as Processor.
-qx [object] List installed counters with instances. To list counters for one object, include the object name, such as Processor.
-sc <samples> Number of samples to collect. Default is to sample until CTRL+C.
-config <filename> Settings file containing command options.
-s <computer_name> Server to monitor if no server is specified in the counter path.
-y Answer yes to all questions without prompting.

 

Technorati tags: Windows 2008, Vista, XP, Admin