Two Minute Drill: TYPEPERF

Two Minute Drill: TYPEPERF

  • Comments 5
  • Likes

Hello again AskPerf! Blake Morrison here to discuss a little known OS tool called TYPEPERF.  TYPEPERF is a built-in tool that writes performance data to the command window or to a log file.  If you are a command line junkie, love to script, and need to get Performance data from your Workstation or Server, then TYPEPERF is the tool for you.  Let's check out its options and some examples.  When you type "typeperf /?" at a command prompt, the following appears:

C:\>typeperf /?
Microsoft r TypePerf.exe (6.0.6000.16386)
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.
Note:
  Counter is the full name of a performance counter in "\\<Computer>\<Object>(<Instance>)\<Counter>" format,
  such as "\\Server1\Processor(0)\% User Time".

Here are some quick examples:

Check your Total CPU usage every second:
C:\>typeperf "\processor(_Total)\% Processor Time"

"(PDH-CSV 4.0)","\\2K8SRV\processor(_Total)\% Processor Time"
"04/13/2009 09:50:04.359","2.509119"
"04/13/2009 09:50:05.360","0.754295"
"04/13/2009 09:50:06.360","2.899090"
"04/13/2009 09:50:07.360","1.534207"
"04/13/2009 09:50:08.360","0.559314"
"04/13/2009 09:50:09.360","10.113409"
"04/13/2009 09:50:10.360","10.113409"
"04/13/2009 09:50:11.360","3.094071"
"04/13/2009 09:50:12.360","0.559314"

The command completed successfully.

Check your available memory in bytes every 5 seconds:
C:\>typeperf "\memory\Available Bytes" -si 5

"(PDH-CSV 4.0)","\\2K8SRV\memory\Available Bytes"
"04/13/2009 09:56:30.818","12821381120.000000"
"04/13/2009 09:56:35.819","12821602304.000000"
"04/13/2009 09:56:40.819","12821659648.000000"
"04/13/2009 09:56:45.820","12821610496.000000"
"04/13/2009 09:56:50.820","12821794816.000000"

The command completed successfully.

Grab 5 samples of pagefile total usage on a remote system every 10 seconds:
C:\>typeperf "\\REMOTESRV\paging file(_Total)\% Usage" -sc 5 -si 10

"(PDH-CSV 4.0)","\\REMOTESRV\paging file(_Total)\% Usage"
"04/13/2009 10:01:12.004","1.770573"
"04/13/2009 10:01:22.007","1.770573"
"04/13/2009 10:01:32.009","1.770573"
"04/13/2009 10:01:42.011","1.770573"
"04/13/2009 10:01:52.013","1.770573"

The command completed successfully.

As you can see, this tool is quite powerful.  In terms of scenarios in which you might use this tool, consider a situation where you need to gather a limited set of performance data from 500 servers at 3:00 am when the backup job kicks off.  Using TYPEPERF, you can configure this in just a few minutes via batch files and scripts.  Don’t forget that you need to either use the –sc switch to limit the number of samples or use CTRL+C within the command window.  The links below have more information and examples.  Take care!

Additional Resources:

- Blake Morrison

Share this post :


Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Hi,

    Its possible to get information from local machine.

    But is there any way to get information from remote machine?

    When I tried to get information from remote machine by executing following command:

    typeperf "\\<remote-IP>\Process(*)\% Processor Time" -sc 1

    it returns following error:

    "Error: No valid counters."

    Please help me out in this issue.

  • RE:

    >>Hi,

    >>Its possible to get information from local machine.

    >>But is there any way to get information from remote machine?

    >>When I tried to get information from remote machine by executing following command:

    >>typeperf "\\<remote-IP>\Process(*)\% Processor Time" -sc 1

    >>it returns following error:

    >>"Error: No valid counters."

    >>Please help me out in this issue.

    I realise this is a bit late, but might help someone...

    Include a double '%%', i.e.

    typeperf "\\<remote-IP>\Process(*)\%% Processor Time" -sc 1

    Sorted it out for me today. Hope it helps you.

  • Hi,

    I am trying to use typeperf to get processor utilization on remote machine. It doesn't give any error but always monitors local machine.

    I am using command like this: typeperf  \\<IP> "\Processor(_Total)\% Processor Time"

    It starts giving me output, but in the header line of output, i can see name of my local machine.

    I can ping to the IP i am using above.

  • I wrote this script to wait for %SystemDrive% idle. The purpose was to prevent running the shutdown command until the disk was idle, as a proxy that startup had completed (all autostart services running, etc).

    <script>

    @echo off

    setlocal

    REM timeout /T 15 /NOBREAK 1>nul

    echo Waiting for SystemDrive idle...

    set loop=0

    :loop

    set /a loop+=1

    for /F "tokens=2 delims=," %%A in ('typeperf "\logicalDisk(%SystemDrive%)\%% Idle Time" -si 5 -sc 1 ^| findstr .*/.*/.*') do (

    set idleTime=%%~A

    )

    echo idleTime=%idleTime%%%

    if %idleTime:~0,3% equ 100 set idleTime=99

    if %idleTime% equ 99 endlocal&exit /b %loop%

    if %loop% lss 60 (goto :loop) else (

    echo Timeout after %loop% iterations

    REM pause

    )

    </script>

    I tried to do similar with 'logman create alert' but i'm having problems making the trigger work.

  • The line

    > if %idleTime% equ 99 endlocal&exit /b %loop%

    should be

    > if %idleTime% GEQ 99 endlocal&exit /b %loop%

    My bad. Where is edit option? :-)

    Have since worked out how to use the logman command to create alerts, which is a little more elegant than this script, but it works well, and is the only option on XP.

    Ideally an inbox command would simplify this to something like;

    > sleep while "\logicalDisk(%SystemDrive%)\%% Idle Time<99"