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.

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.

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

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

  -?                            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: , , ,
Comments (5)
  1. BooRadely says:

    Jim, just give me an exmaple of what you’re trying to do and I’ll see if I have an example around.

  2. BooRadely says:

    Hey Techguy, I don’t know if typeperf is the best solution.  I’d use WMI to pull the data perhaps from more than one server.  Check out the post I did on scriptomatic.  Using this you should be able to do what you want quite easily.

  3. Jim Cauble says:

    This is great, I, too, am a big fan of the command prompt, and really like to batch these up for automating the task.

    Maybe you can provide some examples of the most useful operands you have used?

  4. techguy says:

    Hey brad I need to script typeperf in such a way that we can use it to find avg cpu usage on about 50 servers. Do you think its possible. Need help ! Thanks a ton!

  5. la_bruin says:

    I have moved to a Vista business laptop.  I have both sql 2008 dev and express installed.  I can use the sql counters in performance monitor but when I execute "typeperf -q" from command prompt, I get a long list of counters but no SQL counters.

    I have seen cases where sql counters weren’t installed on a machine but they are clearly installed because I can use them in the UI version of perfmon.



Comments are closed.

Skip to main content