Platform SDK: Performance Monitoring

Performance Objects and Counters

The mechanism by which performance data is collected is the counter. A counter is a performance data item whose name is stored in the registry. Each counter is related to a specific area of system functionality. Examples include a processor's busy time, memory usage, or the number of bytes received over a network connection. Each counter is uniquely identified through its name and its path, or location. In the same way that a file path includes drives, directories, subdirectories, and file names, a counter path consists of four elements: the machine, the object, the object instance, and the counter name. The syntax of a counter path is:

\\Machine\PerfObject(ParentInstance/ObjectInstance#InstanceIndex)\Counter

Most performance counters in Windows NT and Windows 2000 increment and are never reset to zero. Therefore, to obtain performance data, perform the following steps.

The machine specification is the network name of the computer where the counter resides. This specification can be omitted if the counter is located on the local machine; therefore, a single path string without the machine specification can be used on any computer the counter is located on.

A machine's performance objects include physical components, such as processors, disks, and memory. There are also system objects, such as processes and threads. Each object is related to a functional element within the computer and has a set of standard counters assigned to it. These objects are listed in the PDH browse dialog box (see PdhBrowseCounters) and in the Add Counters dialog box in the Windows 2000 Performance Monitor, and you must include them in the counter path. Performance data is grouped by the performance object to which is it related. For a list of the system performance objects and performance counters, refer to the counter list contained in the Counters.chm file provided with the Windows 2000 Resource Kit documentation. The Counters.chm file is located in the ResourceKit folder when the Resource Kit is installed.

In certain cases, there may be several copies of the same object. For example, several processes and threads run simultaneously, and some computers contain more than one processor. These object copies are called object instances. Each object instance has a set of standard counters assigned to it. If an object can have more than one instance, an instance specification must be included in the counter path.

The format of the instance specification depends on the object type. If the object has simple instances, then the format is only the instance name enclosed in parentheses. For example:

(Explorer)

If the instance of this object also requires a parent instance name, the parent instance name must come before the object instance and be separated by a forward slash character. For example:

(Explorer/0)

If the object has multiple instances that have the same name string, they can be indexed sequentially by specifying the instance index prefixed by a pound sign. Instance indexes are 0-based, so all instances have an implicit index of "0". For example:

(Explorer/0#1)

The \Counter component is required; it specifies the performance counter. The counter names are displayed in the PDH browse dialog box and in the Add Counter dialog box in the Windows 2000 Performance Monitor. The counters associated with the selected object are displayed.

The following are two common counters in the PDH counter path format:

\Processor(0)\% Processor Time
\System\% Total Processor Time

For more information on counters, see Adding Counters to a Query and Working with Counters, Performance Objects, and Machines.