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.

471 lines
19 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. perrepsr.h
  5. Abstract:
  6. This header file contains definitions of data structures used by the
  7. functions in the perrepsr.c file.
  8. Author:
  9. Rohan Kumar [rohank] 13-Sept-1998
  10. Environment:
  11. User Mode Service
  12. Revision History:
  13. --*/
  14. #ifndef _PERREPSR_H_
  15. #define _PERREPSR_H_
  16. #include <NTreppch.h>
  17. #pragma hdrstop
  18. #include <wchar.h>
  19. #include <frs.h>
  20. #include <winperf.h>
  21. //
  22. // REMOVE THE BELOW ONCE THE CHECKIN IS DONE TO WINPERF.H
  23. //
  24. #ifndef WINPERF_LOG_NONE
  25. //
  26. // The following are the possible values for
  27. // HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\EventLogLevel
  28. // The default is WINPERF_LOG_NONE if the registry value is not defined.
  29. // This should be adopted by all perfdlls to avoid flooding the application
  30. // event log.
  31. //
  32. #define WINPERF_LOG_NONE 0 // No event reported
  33. #define WINPERF_LOG_USER 1 // Report only errors
  34. #define WINPERF_LOG_DEBUG 2 // Report debug errors as well
  35. #define WINPERF_LOG_VERBOSE 3 // Report everything
  36. #endif
  37. //
  38. // Used in the RegEnumValue function
  39. //
  40. #define SIZEOFVALUENAME 10
  41. #define SIZEOFVALUEDATA 10000
  42. #define INVALIDKEY 0
  43. #define HASHTABLESIZE sizeof(QHASH_ENTRY)*100
  44. #define PERFMON_MAX_INSTANCE_LENGTH 1024
  45. #define REPSETOBJSUBKEY L"SYSTEM\\CurrentControlSet\\Services\\FileReplicaSet"
  46. #define REPSETPERFSUBKEY L"SYSTEM\\CurrentControlSet\\Services\\FileReplicaSet\\Performance"
  47. #define REPSETLINSUBKEY L"SYSTEM\\CurrentControlSet\\Services\\FileReplicaSet\\Linkage"
  48. #define REPSETOPENFN L"OpenReplicaSetPerformanceData"
  49. #define REPSETCLOSEFN L"CloseReplicaSetPerformanceData"
  50. #define REPSETCOLLECTFN L"CollectReplicaSetPerformanceData"
  51. #define LDCTRAPP L"%SystemRoot%\\system32\\lodctr.exe"
  52. #define REPSETINI LDCTRAPP L" %SystemRoot%\\system32\\NTFRSREP.ini"
  53. #define UNLDCTRAPP L"%SystemRoot%\\system32\\unlodctr.exe"
  54. #define REPSETUNLD UNLDCTRAPP L" FileReplicaSet"
  55. #define REPCONNOBJSUBKEY L"SYSTEM\\CurrentControlSet\\Services\\FileReplicaConn"
  56. #define REPCONNPERFSUBKEY L"SYSTEM\\CurrentControlSet\\Services\\FileReplicaConn\\Performance"
  57. #define REPCONNLINSUBKEY L"SYSTEM\\CurrentControlSet\\Services\\FileReplicaConn\\Linkage"
  58. #define REPCONNOPENFN L"OpenReplicaConnPerformanceData"
  59. #define REPCONNCLOSEFN L"CloseReplicaConnPerformanceData"
  60. #define REPCONNCOLLECTFN L"CollectReplicaConnPerformanceData"
  61. #define REPCONNINI LDCTRAPP L" %SystemRoot%\\system32\\NTFRSCON.ini"
  62. #define REPCONNUNLD UNLDCTRAPP L" FileReplicaConn"
  63. #define PERFDLLDIRECTORY L"%SystemRoot%\\system32\\NTFRSPRF.dll"
  64. //
  65. // Name of the Total Instance
  66. //
  67. #define TOTAL_NAME L"_Total"
  68. //
  69. // Macros used for incrementing or setting counter values for Replica Set
  70. // objects, connection objects and Service total counters.
  71. //
  72. //
  73. // Increment a replica set counter value.
  74. //
  75. #define PM_INC_CTR_REPSET(_Replica_, _Ctr_, _Value_) \
  76. { \
  77. if (((_Replica_) != NULL) && \
  78. ((_Replica_)->PerfRepSetData != NULL) && \
  79. ((_Replica_)->PerfRepSetData->oid != NULL)) { \
  80. \
  81. (_Replica_)->PerfRepSetData->FRSCounter._Ctr_ += (_Value_); \
  82. } \
  83. }
  84. //
  85. // Set a new value for a replica set perfmon counter.
  86. //
  87. #define PM_SET_CTR_REPSET(_Replica_, _Ctr_, _Value_) \
  88. { \
  89. if (((_Replica_) != NULL) && \
  90. ((_Replica_)->PerfRepSetData != NULL) && \
  91. ((_Replica_)->PerfRepSetData->oid != NULL)) { \
  92. \
  93. (_Replica_)->PerfRepSetData->FRSCounter._Ctr_ = (_Value_); \
  94. } \
  95. }
  96. //
  97. // Read the value for a replica set perfmon counter.
  98. //
  99. #define PM_READ_CTR_REPSET(_Replica_, _Ctr_) \
  100. ( \
  101. (((_Replica_) != NULL) && \
  102. ((_Replica_)->PerfRepSetData != NULL) && \
  103. ((_Replica_)->PerfRepSetData->oid != NULL)) ? \
  104. ((_Replica_)->PerfRepSetData->FRSCounter._Ctr_) : 0 \
  105. )
  106. //
  107. // Increment a Cxtion counter value.
  108. //
  109. #define PM_INC_CTR_CXTION(_Cxtion_, _Ctr_, _Value_) \
  110. { \
  111. if (((_Cxtion_) != NULL) && \
  112. ((_Cxtion_)->PerfRepConnData != NULL) && \
  113. ((_Cxtion_)->PerfRepConnData->oid != NULL)) { \
  114. (_Cxtion_)->PerfRepConnData->FRCCounter._Ctr_ += (_Value_); \
  115. } \
  116. }
  117. //
  118. // Set a new value for a Cxtion perfmon counter.
  119. //
  120. #define PM_SET_CTR_CXTION(_Cxtion_, _Ctr_, _Value_) \
  121. { \
  122. if (((_Cxtion_) != NULL) && \
  123. ((_Cxtion_)->PerfRepConnData != NULL) && \
  124. ((_Cxtion_)->PerfRepConnData->oid != NULL)) { \
  125. (_Cxtion_)->PerfRepConnData->FRCCounter._Ctr_ = (_Value_); \
  126. } \
  127. }
  128. //
  129. // Read the value for a Cxtion perfmon counter.
  130. //
  131. #define PM_READ_CTR_CXTION(_Cxtion_, _Ctr_) \
  132. ( \
  133. (((_Cxtion_) != NULL) && \
  134. ((_Cxtion_)->PerfRepConnData != NULL) && \
  135. ((_Cxtion_)->PerfRepConnData->oid != NULL)) ? \
  136. ((_Cxtion_)->PerfRepConnData->FRCCounter._Ctr_) : 0 \
  137. )
  138. //
  139. // Increment a Service Wide Total counter value.
  140. //
  141. #define PM_INC_CTR_SERVICE(_Total_, _Ctr_, _Value_) \
  142. { \
  143. if (((_Total_) != NULL) && ((_Total_)->oid != NULL)) { \
  144. (_Total_)->FRSCounter._Ctr_ += (_Value_); \
  145. } \
  146. }
  147. //
  148. // Set a new value for a Service Wide Total counter value.
  149. //
  150. #define PM_SET_CTR_SERVICE(_Total_, _Ctr_, _Value_) \
  151. { \
  152. if (((_Total_) != NULL) && ((_Total_)->oid != NULL)) { \
  153. (_Total_)->FRSCounter._Ctr_ = (_Value_); \
  154. } \
  155. }
  156. //
  157. // Read the value for a Service Wide Total counter.
  158. //
  159. #define PM_READ_CTR_SERVICE(_Total_, _Ctr_) \
  160. ( \
  161. (((_Total_) != NULL) && ((_Total_)->oid != NULL)) ? \
  162. ((_Total_)->FRSCounter._Ctr_) : 0 \
  163. )
  164. //
  165. // The global variables below are used to synchronize access to the variables
  166. // FRS_dwOpenCount and FRC_dwOpenCount respectively.
  167. //
  168. CRITICAL_SECTION FRS_ThrdCounter;
  169. CRITICAL_SECTION FRC_ThrdCounter;
  170. //
  171. // EventLog Handle and severity level which controls if log entry is made.
  172. //
  173. extern HANDLE hEventLog;
  174. //extern BOOLEAN DoLogging;
  175. extern DWORD PerfEventLogLevel;
  176. //
  177. // Macro to filter eventlog messages
  178. //
  179. // Only print if severity level of message is less than or equal to the current
  180. // perfmon event log level from the registry value:
  181. // "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\EventLogLevel"
  182. // Each eventlog message is only printed once per loading of the dll.
  183. //
  184. #define FilterAndPrintToEventLog(_sev_, _once_, _evid_) \
  185. { \
  186. if (/*DoLogging && */ (PerfEventLogLevel >= (_sev_))) { \
  187. if (_once_) { \
  188. ReportEvent(hEventLog, \
  189. EVENTLOG_ERROR_TYPE, \
  190. 0, \
  191. _evid_, \
  192. (PSID)NULL, \
  193. 0, \
  194. 0, \
  195. NULL, \
  196. (PVOID)NULL); \
  197. _once_ = FALSE; \
  198. } \
  199. } \
  200. }
  201. //
  202. // This is used in the Open function where memory gets allocated.
  203. // If memory allocation fails, just return failure.
  204. //
  205. #define NTFRS_MALLOC_TEST(_x_, _y_, _z_) \
  206. { \
  207. if ((_x_) == NULL) { \
  208. if (_z_) { \
  209. RpcBindingFree(&Handle); \
  210. } \
  211. _y_; \
  212. return ERROR_NO_SYSTEM_RESOURCES; \
  213. } \
  214. }
  215. //
  216. // Object Types
  217. //
  218. enum object { REPLICASET, REPLICACONN };
  219. //
  220. // The PERFMON_OBJECT_ID data structure
  221. //
  222. typedef struct _PERFMON_OBJECT_ID {
  223. PWCHAR name; // name of the Instance
  224. ULONGLONG key; // The Instances's Unique Key
  225. } PERFMON_OBJECT_ID, *PPERFMON_OBJECT_ID;
  226. //
  227. // WARNING !!!! The fields in the structure below should be changed
  228. // if any new counters are to be added or deleted for the REPLICASET Object
  229. // The counter structure for the ReplicaSet Object Instance
  230. //
  231. typedef struct _REPLICASET_COUNTERS {
  232. ULONGLONG SFGeneratedB; // Bytes of Staging Generated
  233. ULONGLONG SFFetchedB; // Bytes of Staging Fetched
  234. ULONGLONG SFReGeneratedB; // Bytes of Staging Regenerated
  235. ULONGLONG FInstalledB; // Bytes of Files Installed
  236. ULONGLONG SSInUseKB; // KB of Staging Space In Use
  237. ULONGLONG SSFreeKB; // KB of Staging Space Free
  238. ULONGLONG PacketsRcvdBytes; // Packets Received in Bytes
  239. ULONGLONG PacketsSentBytes; // Packets Sent in Bytes
  240. ULONGLONG FetBSentBytes; // Fetch Blocks Sent in Bytes
  241. ULONGLONG FetBRcvdBytes; // Fetch Blocks Received in Bytes
  242. ULONG SFGenerated; // Staging Files Generated
  243. ULONG SFGeneratedError; // Staging Files Generated with Error
  244. ULONG SFFetched; // Staging Files Fetched
  245. ULONG SFReGenerated; // Staging Files Regenerated
  246. ULONG FInstalled; // Files Installed
  247. ULONG FInstalledError; // Files Installed with Error
  248. ULONG COIssued; // Change Orders Issued
  249. ULONG CORetired; // Change Orders Retired
  250. ULONG COAborted; // Change Orders Aborted
  251. ULONG CORetried; // Change Orders Retried
  252. ULONG CORetriedGen; // Change Orders Retried at Generate
  253. ULONG CORetriedFet; // Change Orders Retried at Fetch
  254. ULONG CORetriedIns; // Change Orders Retried at Install
  255. ULONG CORetriedRen; // Change Orders Retried at Rename
  256. ULONG COMorphed; // Change Orders Morphed
  257. ULONG COPropagated; // Change Orders Propagated
  258. ULONG COReceived; // Change Orders Received
  259. ULONG COSent; // Change Orders Sent
  260. ULONG COEvaporated; // Change Orders Evaporated
  261. ULONG LCOIssued; // Local Change Orders Issued
  262. ULONG LCORetired; // Local Change Orders Retired
  263. ULONG LCOAborted; // Local Change Orders Aborted
  264. ULONG LCORetried; // Local Change Orders Retried
  265. ULONG LCORetriedGen; // Local Change Orders Retried at Generate
  266. ULONG LCORetriedFet; // Local Change Orders Retried at Fetch
  267. ULONG LCORetriedIns; // Local Change Orders Retried at Install
  268. ULONG LCORetriedRen; // Local Change Orders Retried at Rename
  269. ULONG LCOMorphed; // Local Change Orders Morphed
  270. ULONG LCOPropagated; // Local Change Orders Propagated
  271. ULONG LCOSent; // Local Change Orders Sent
  272. ULONG LCOSentAtJoin; // Local Change Orders Sent At Join
  273. ULONG RCOIssued; // Remote Change Orders Issued
  274. ULONG RCORetired; // Remote Change Orders Retired
  275. ULONG RCOAborted; // Remote Change Orders Aborted
  276. ULONG RCORetried; // Remote Change Orders Retried
  277. ULONG RCORetriedGen; // Remote Change Orders Retried at Generate
  278. ULONG RCORetriedFet; // Remote Change Orders Retried at Fetch
  279. ULONG RCORetriedIns; // Remote Change Orders Retried at Install
  280. ULONG RCORetriedRen; // Remote Change Orders Retried at Rename
  281. ULONG RCOMorphed; // Remote Change Orders Morphed
  282. ULONG RCOPropagated; // Remote Change Orders Propagated
  283. ULONG RCOSent; // Remote Change Orders Sent
  284. ULONG RCOReceived; // Remote Change Orders Received
  285. ULONG InCODampned; // Inbound Change Orders Dampened
  286. ULONG OutCODampned; // Outbound Change Orders Dampened
  287. ULONG UsnReads; // Usn Reads
  288. ULONG UsnRecExamined; // Usn Records Examined
  289. ULONG UsnRecAccepted; // Usn Records Accepted
  290. ULONG UsnRecRejected; // Usn Records Rejected
  291. ULONG PacketsRcvd; // Packets Received
  292. ULONG PacketsRcvdError; // Packets Received in Error
  293. ULONG PacketsSent; // Packets Sent
  294. ULONG PacketsSentError; // Packets Sent in Error
  295. ULONG CommTimeouts; // Communication Timeouts
  296. ULONG FetRSent; // Fetch Requests Sent
  297. ULONG FetRReceived; // Fetch Requests Received
  298. ULONG FetBSent; // Fetch Blocks Sent
  299. ULONG FetBRcvd; // Fetch Blocks Received
  300. ULONG JoinNSent; // Join Notifications Sent
  301. ULONG JoinNRcvd; // Join Notifications Received
  302. ULONG Joins; // Joins
  303. ULONG Unjoins; // Unjoins
  304. ULONG Bindings; // Bindings
  305. ULONG BindingsError; // Bindings in Error
  306. ULONG Authentications; // Authentications
  307. ULONG AuthenticationsError; // Authentications in Error
  308. ULONG DSPolls; // DS Polls
  309. ULONG DSPollsWOChanges; // DS Polls without Changes
  310. ULONG DSPollsWChanges; // DS Polls with Changes
  311. ULONG DSSearches; // DS Searches
  312. ULONG DSSearchesError; // DS Searches in Error
  313. ULONG DSObjects; // DS Objects
  314. ULONG DSObjectsError; // DS Objects in Error
  315. ULONG DSBindings; // DS Bindings
  316. ULONG DSBindingsError; // DS Bindings in Error
  317. ULONG RSCreated; // Replica Sets Created
  318. ULONG RSDeleted; // Replica Sets Deleted
  319. ULONG RSRemoved; // Replica Sets Removed
  320. ULONG RSStarted; // Replica Sets Started
  321. // ULONG RSRepaired; // Replica Sets Repaired
  322. // ULONG Threads; // Threads
  323. ULONG ThreadsStarted; // Threads started
  324. ULONG ThreadsExited; // Threads exited
  325. } ReplicaSetCounters, *PReplicaSetCounters;
  326. //
  327. // Size of the structure above
  328. //
  329. #define SIZEOF_REPSET_COUNTER_DATA sizeof(ReplicaSetCounters)
  330. //
  331. // The data structure for the ReplicaSet Object Instance
  332. //
  333. typedef struct _HASHTABLEDATA_REPLICASET {
  334. PPERFMON_OBJECT_ID oid; // The Instance ID
  335. PREPLICA RepBackPtr; // Back pointer to the replica structure
  336. ReplicaSetCounters FRSCounter; // The counter structure
  337. } HT_REPLICA_SET_DATA, *PHT_REPLICA_SET_DATA;
  338. //
  339. // The Total Instance
  340. //
  341. extern PHT_REPLICA_SET_DATA PMTotalInst;
  342. //
  343. // WARNING !!!! The fields in the structure below should be changed
  344. // if any new counters are to be added or deleted for the REPLICACONN Object
  345. // The counter structure for the ReplicaConn Object Instance
  346. //
  347. typedef struct _REPLICACONN_COUNTERS {
  348. ULONGLONG PacketsSentBytes; // Packets Sent in Bytes
  349. ULONGLONG FetBSentBytes; // Fetch Blocks Sent in Bytes
  350. ULONGLONG FetBRcvdBytes; // Fetch Blocks Received in Bytes
  351. ULONG LCOSent; // Local Change Orders Sent
  352. ULONG LCOSentAtJoin; // Local Change Orders Sent At Join
  353. ULONG RCOSent; // Remote Change Orders Sent
  354. ULONG RCOReceived; // Remote Change Orders Received
  355. ULONG InCODampned; // Inbound Change Orders Dampened
  356. ULONG OutCODampned; // Outbound Change Orders Dampened
  357. ULONG PacketsSent; // Packets Sent
  358. ULONG PacketsSentError; // Packets Sent in Error
  359. ULONG CommTimeouts; // Communication Timeouts
  360. ULONG FetRSent; // Fetch Requests Sent
  361. ULONG FetRReceived; // Fetch Requests Received
  362. ULONG FetBSent; // Fetch Blocks Sent
  363. ULONG FetBRcvd; // Fetch Blocks Received
  364. ULONG JoinNSent; // Join Notifications Sent
  365. ULONG JoinNRcvd; // Join Notifications Received
  366. ULONG Joins; // Joins
  367. ULONG Unjoins; // Unjoins
  368. ULONG Bindings; // Bindings
  369. ULONG BindingsError; // Bindings in Error
  370. ULONG Authentications; // Authentications
  371. ULONG AuthenticationsError; // Authentications in Error
  372. } ReplicaConnCounters, *PReplicaConnCounters;
  373. //
  374. // Size of the structure above
  375. //
  376. #define SIZEOF_REPCONN_COUNTER_DATA sizeof(ReplicaConnCounters)
  377. //
  378. // The data structure for the ReplicaConn Object Instance
  379. //
  380. typedef struct _HASHTABLEDATA_REPLICACONN {
  381. PPERFMON_OBJECT_ID oid; // The Instance ID
  382. ReplicaConnCounters FRCCounter; // The counter structure
  383. } HT_REPLICA_CONN_DATA, *PHT_REPLICA_CONN_DATA;
  384. //
  385. // Signature's of exported functions defined in the perrepsr.c file
  386. //
  387. VOID
  388. InitializePerfmonServer (
  389. VOID
  390. );
  391. VOID
  392. ShutdownPerfmonServer (
  393. VOID
  394. );
  395. ULONG
  396. AddPerfmonInstance (
  397. IN DWORD ObjectType,
  398. IN PVOID addr,
  399. IN PWCHAR InstanceName
  400. );
  401. DWORD
  402. DeletePerfmonInstance(
  403. IN DWORD ObjectType,
  404. IN PVOID addr
  405. );
  406. #endif // perrepsr.h