Adding Performance Counters: the Big Picture
Performance Monitor was designed so that developers could add performance counters for their own applications to the system. To add performance counters to the system, you must create an extended object. Your extended object is called when Performance Monitor collects data, as shown in Figure 13.1. The Configuration Registry is handled by ADVAPI32.DLL in the Performance Monitor process on the local computer, and by SCREG.EXE on remotely monitored computers.
Figure 13.1 How Performance Monitor collects data from an extended object
To add performance objects and counters for your application, follow the basic steps in the list below. Each of these steps is discussed in detail in following sections of this chapter.
- Design the object types and counters for the application.
- Set up the necessary performance monitoring entries in the Registry. This includes the following steps:
- Create a Performance key in the application's Services node in the Registry. If you don't have such a node you must create one. Create it under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services.
- Create an .INI file containing the names and descriptions of the counter objects and counters.
- Create an .H file containing the relative offsets at which the counter objects and counters will be installed in the Registry.
- Use the lodctr utility with the .INI and .H files to install the information in the Registry. Lodctr succeeds only if a Performance key exists in the application's Services node.
- Add Library, Open, Collect, and Close value entries to the application's Services node in the Registry. These entries specify the name of the application's performance DLL, and the names of the DLLs required functions. The Open and Close entries are optional.
- To your application, add functions and data structures for collecting and storing performance data, and a mechanism for communicating the data to the performance DLL.
- Create a performance DLL containing a set of exported functions that provide the link between the application and a performance monitoring application (such as Windows NT Performance Monitor).
- Modify the application's OEMSETUP.INF file to automate the Registry setup described in step 2.