Freigeben über


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.

https://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

Comments

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

  • Anonymous
    January 01, 2003
    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.

  • Anonymous
    March 13, 2008
    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?

  • Anonymous
    August 11, 2008
    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!

  • Anonymous
    April 03, 2009
    The comment has been removed