Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
5.9 KiB

  1. PASSPORT PERFORMANCE LIBRARY README.txt 9/10/98
  2. ------------------------------------------------
  3. This library defines an interface class and a single implementation to
  4. synchronously set performance counters in a application. Currently
  5. there is only one implementation: NT Performance Monitor. In the
  6. future there may be other implementations for SNMP traps, etc.
  7. A performance counter is a single DWORD, that an application may
  8. increment, decrement or set. An application may define many performance
  9. counters. Counters are communicated out-of-process to the perfmon
  10. application via a memory-mapped files. Counters are lightweight: for
  11. the application, incrementing a counter is just modifiying a DWORD in a
  12. section of shared memory. Examples of performance counters are numbers
  13. of items in a cache, number of failed authentications, etc.
  14. Typing 'build' in each of the directories hubCounters, brokerCounter,
  15. testCounters creates a single performance Dll for that directory. That
  16. performance Dll is used both by the application and the performance
  17. monitor itself.
  18. This is an implementation of **static** performance counters: the
  19. performance counters must be defined before running the application in
  20. order to be useful. Counters may not be created dynamically while the
  21. program is executing. The reason for this is that installing a perf
  22. counter a pre-existing key for the perfmon application must be modified.
  23. If the application dies suddenly, then the perfmon registry entry can
  24. only be rolled back manually. Datacenter personel have complained that
  25. dynamic counters are messing up their registries.
  26. However, Instances (of performance objects, not counters) may be created
  27. and destroyed dynamicially. This allows the monitoring of, for example,
  28. open socket connections by name.
  29. Initial Setup:
  30. --------------
  31. Build (type "build -c") in the $(PASSDEV)/common/PerfLibrary and in
  32. relevant subdirectory (hubCounters or brokerCounters) to build the
  33. hubCounters.dll or the brokerCoutners.dll.
  34. Setting Up the Registry
  35. -----------------------
  36. In order to use the perfmon counters you must make chages to you
  37. registry. If you do make those changes your application will not be
  38. affected, but you will not be able to read the perfmon counters!
  39. FIRST BACK UP YOUR REGISTRY! INSTALLING THE PERFMON COUNTERS MAKES
  40. CHANGES TO YOUR REGISTRY! **ESPECIALLY** BACK UP THE KEY:
  41. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib]
  42. To install the counters, go to the directory where the <name>Counter.dll
  43. lives Dll lives (most likely $(PASSDEV)/sdk/lib/i386). Make sure you have
  44. these three files in that directory.
  45. <name>Counters.dll
  46. <name>Counters.ini
  47. <name>Counters.h
  48. If those three files are not present copy the from dev. tree (most likely
  49. $(PASSDEV/common/PerfLibrary/<name>Counters) and run the command:
  50. 'regsvr32 <name>Counters.dll'
  51. where <name> is hub or broker. You should see the respective key added
  52. to the "SYSTEM\\CurrentControlSet\\Services\\<name>Counters"
  53. registry location. This modifes both the above
  54. "SYSTEM\\CurrentControlSet\\Services\\<name>Counters" registry key and
  55. the registry you created when you installed NT at:
  56. "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib"
  57. Uninstalling the Registry
  58. -----------------------
  59. To uninstall the counters, go to the directory where the <name>Counter.dll
  60. lives Dll lives (most likely $(PASSDEV)/sdk/lib/i386). Make sure you have
  61. these three files in that directory.
  62. <name>Counters.dll
  63. <name>Counters.ini
  64. <name>Counters.h
  65. If those three files are not present copy the from dev. tree (most likely
  66. $(PASSDEV/common/PerfLibrary/<name>Counters) and run the command:
  67. 'regsvr32 /u <name>Counters.dll'
  68. Class Interface Usage:
  69. ----------------------
  70. #include "PassportPerfDefs.h" // for SHM name defines
  71. #include "TestCounters.h" // for counter defines
  72. #include "PassportPerfInterface.h" // for object interface
  73. static PassportPerfInterface * perf = NULL;
  74. if (perf == NULL)
  75. {
  76. perf = (PassportPerfInterface *)
  77. CreatePassportPerformanceObject(
  78. PassportPerfInterface::PERFMON_TYPE);
  79. if (perf != NULL)
  80. {
  81. if (!perf->init( PASSPORT_PERF_BLOCK))
  82. // error
  83. }
  84. else
  85. // error
  86. }
  87. // to increment a counter without an instance
  88. if (!perf->incrementCounter(TESTCOUNTERS_PERF_TEST_COUNTER1))
  89. {
  90. // error
  91. }
  92. // to add an instance to that object
  93. CHAR instanceName[PassportPerfInterface::MAX_INSTANCE_NAME];
  94. strcpy( instanceName,"Instance");
  95. if (!PA->addInstance( instanceName ))
  96. {
  97. // error
  98. }
  99. // to increment a counter with an instance
  100. if (!perf->incrementCounter(TESTCOUNTERS_PERF_TEST_COUNTER1, instanceName))
  101. {
  102. // error
  103. }
  104. // note if you try perf->incrementCounter(TESTCOUNTERS_PERF_TEST_COUNTER1)
  105. // after you've added an instance to that object it will fail
  106. // to modify a counter type
  107. if (!perf->setCounterType (TESTCOUNTERS_PERF_TEST_COUNTER1,
  108. PassportPerfInterface::AVERAGE_TIMER))
  109. {
  110. // error
  111. }
  112. Modifying Counters
  113. ------------------
  114. The counter definitions for the broker and hub have been created in the
  115. brokerCounter and hubcounter directory. Modifyiing these counters has a few steps:
  116. 1. Make sure you've backed up your registry, especially the
  117. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib] key.
  118. 2. go to the directory where the <name>Counter.dll
  119. lives Dll lives (most likely $(PASSDEV)/sdk/lib/i386). Make sure you have
  120. these three files in that directory.
  121. <name>Counters.dll
  122. <name>Counters.ini
  123. <name>Counters.h
  124. If those three files are not present copy the from dev. tree (most likely
  125. $(PASSDEV/common/PerfLibrary/<name>Counters) and run the command:
  126. 'regsvr32 <name>Counters.dll'
  127. This will both unistall the previous counters and re-install the new counters
  128. 3. Re-start the perfmon and check to see if the new counters
  129. are in the addcounter menu.