Welcome to TechNet Blogs Sign in | Join | Help
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: , , ,

Published Saturday, September 22, 2007 9:29 PM by Brad Rutkowski

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Using TypePerf to get performance data on the command prompt. @ Thursday, March 13, 2008 2:11 PM

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?

Jim Cauble

# re: Using TypePerf to get performance data on the command prompt. @ Friday, March 14, 2008 5:50 PM

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

Brad Rutkowski

# Using TypePerf to get performance data on the command prompt. @ Monday, August 11, 2008 8:11 AM

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!

techguy

# re: Using TypePerf to get performance data on the command prompt. @ Tuesday, August 12, 2008 11:51 AM

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.

Brad Rutkowski

# re: Using TypePerf to get performance data on the command prompt. @ Friday, April 03, 2009 5:32 PM

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.

thanks,

Kurt

Kurt

Leave a Comment

(required) 
required 
(required) 
Page view tracker