TypePerf - CMD
Overview
TypePerf
writes performance data to the command line or logs it to a file, facilitating real-time monitoring or later analysis. Ideal in server management, system monitoring, and performance tuning scenarios, TypePerf
can capture specific system or application metrics by utilizing various counters.
Syntax
The basic syntax for TypePerf
is:
typeperf [options] [[-cf <filename>] | <counter_paths>] [-f {csv|tsv|bin|sql}] [-si <seconds>] [-o <filename>]
Parameters:
counter_paths
: Specifies the counters to monitor. Multiple counters can be separated by spaces and enclosed in quotes if they include spaces.-cf <filename>
: Use a text file to list the counters, one per line.-si <seconds>
: Interval in seconds to sample data.-o <filename>
: Output file to log the data, default is console if not specified.-f {csv|tsv|bin|sql}
: Specify the format (CSV, TSV, binary, SQL) of the output file.
Options/Flags
- -cf <filename>: Read counter names from a file.
- -sc <samples>: Number of samples to collect.
- -si <seconds>: Interval at which to collect each sample. Default is once per second.
- -o <filename>: Direct the output to a specific file. By default, output is to the command prompt.
- -f {csv|tsv|bin|sql}: Define the output format. Default is CSV.
- -q: Quiet mode that suppresses the output of the counter data.
- -?: Displays help at the command prompt.
Examples
Example 1: Basic Usage
To log processor time every 5 seconds:
typeperf "\Processor(_Total)\% Processor Time" -si 5
Example 2: Using Multiple Counters
To log both Processor Time and Available Memory to a file:
typeperf "\Processor(_Total)\% Processor Time" "\Memory\Available MBytes" -o system_log.csv -f csv -si 10
Example 3: Using a Counter File
If counters.txt
contains a list of required counters on separate lines:
typeperf -cf counters.txt -o results.csv -f csv -si 30
Common Issues
- Counter Not Found Error: Ensure the counter names are spelled correctly and are available on your system.
- Permission Issues: TypePerf might require administrative privileges to access some system counters.
- Output Formatting: Incorrect format flags may result in unstructured output or errors; adjust the
-f
option as necessary.
Integration
TypePerf can be used alongside other utilities, such as Task Scheduler
for automated monitoring. Here’s an example of integrating TypePerf within a batch script to log performance every hour:
@echo off
:LOOP
typeperf "\Processor(_Total)\% Processor Time" -si 3600 -o hourly_log.csv -f csv
goto LOOP
Related Commands
- Logman is another utility for managing and scheduling performance logs.
- Perfmon provides a graphical interface to monitor system performance.
Explore further in the official Microsoft documentation Windows Performance Monitor.