Share via


Defining a Class for the Performance Monitoring Provider

An application that uses the Performance Monitoring provider must define a class for storing the provider-supplied data.

A class supported by the Performance Monitoring provider must have the following WMI-specific qualifiers:

  • Provider qualifier

    Specifies the Performance Monitoring provider as the dynamic provider responsible for managing the data for the class.

  • ClassContext qualifier

    Specifies information needed by the Performance Monitoring provider to access the requested data. The format of the ClassContext qualifier is machine | perfobject, where machine is the machine name and perfobject is the name of the performance object shown in System Monitor in Performance Monitoring. For example, a value of "local | Process" indicates processes on the local machine in a class defined to hold data about processes on a machine.

  • PropertyContext qualifiers

    Identifies the display name to be stored in each property. This is the name that will appear in the System Monitor part of Performance Monitoring.

  • Key qualifier

    Specifies the class property that serves as the key.

The following code example describes a class that the Performance Monitoring provider can support.

[dynamic, provider("PerfProv"), ClassContext("local|Process")]
class NTProcesses
{
    [key]
       String Process;
    [PropertyContext("ID Process")]
         uint32 ID;
    [PropertyContext("Elapsed Time")]
         real32 Time;
    [PropertyContext("Handle Count")]
         uint32 Handles;
    [PropertyContext("Working Set")]
         uint32 WorkingSet;
    [PropertyContext("Working Set Peak")]
         uint32 WorkingSetPeak;
    [PropertyContext("Virtual Bytes")]
         uint32 VirtualBytes;
    [PropertyContext("Virtual Bytes Peak")]
         uint32 VirtualBytesPeak;
    [PropertyContext("Thread Count")]
         uint32 Threads;
    [PropertyContext("Priority Base")]
         uint32 Base;
};

The Performance Monitoring provider cannot return some of the available counter types from instances. Those that cannot be accessed include the WMI statistical counter types. However, you can access these instances if you use a singleton class.

You can ensure that only one instance of a class is ever created on a computer by making the class a singleton.

The following procedure describes how to access a singleton class through the Performance Monitoring provider.

Aa389815.wedge(en-us,VS.85).gifTo access a singleton class through the Performance Monitoring provider

  1. Create a singleton class by attaching the Singleton qualifier to the class as shown in the example.
  2. Do not add the Key qualifier to any of the class properties.

The following example shows the MOF code to create a singleton class using the Performance Monitoring provider.

[Singleton, Dynamic, Provider("PerfProv"), 
ClassContext("local|Memory")]
class memory
{
    [PropertyContext("Available Bytes")]
         uint32 Avail;
    [PropertyContext("Cache Bytes")]
         uint32 Cache;
};