home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / monitor.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  9KB  |  178 lines

  1. // --monitor.h------------------------------------------------------------------
  2. //
  3. // Header file for module containing performance monitoring functions.
  4. //
  5. // Copyright 1986 - 1998 Microsoft Corporation.  All Rights Reserved.
  6. // -----------------------------------------------------------------------------
  7. #if !defined(_MONITOR_H)
  8. #define _MONITOR_H
  9.  
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif // __cplusplus
  13.  
  14. //
  15. // Enumerated Types
  16. //
  17.  
  18. //$--DIRECTIONTYPE--------------------------------------------------------------
  19. //  Tells shether a statistic applies to messages going into or out of Exchange.
  20. // -----------------------------------------------------------------------------
  21. typedef enum _DirectionType                // (hungarian notation = dir)
  22. {
  23.     DIRECTIONTYPE_IN = 0,                 // coming into Exchange
  24.     DIRECTIONTYPE_OUT,                     // going out of Exchange
  25.     DIRECTIONTYPE_LAST                    // all direction types less than this
  26. } DIRECTIONTYPE;
  27.  
  28. //$--COUNTERTYPE----------------------------------------------------------------
  29. //  Tells what statistic is to be counted.
  30. // -----------------------------------------------------------------------------
  31. typedef enum _CounterType                // (hungarian notation = ct)
  32. {
  33.     COUNTERTYPE_MESSAGES_IN_FOLDER = 0,    // total number of messages in folder
  34.     COUNTERTYPE_BYTES_IN_FOLDER,        // total number of bytes in folder
  35.     COUNTERTYPE_MESSAGES_ENTERING_FOLDER, // number of messages entering folder
  36.     COUNTERTYPE_BYTES_ENTERING_FOLDER,    // number of bytes entering folder
  37.     COUNTERTYPE_MESSAGES_LEAVING_FOLDER, // number of messages leaving folder
  38.     COUNTERTYPE_BYTES_LEAVING_FOLDER,    // NOT IMPLEMENTED!!! (placeholder)
  39.     COUNTERTYPE_MESSAGES_TRANSFERRED_IN, // messages transferred into Exchange
  40.     COUNTERTYPE_BYTES_TRANSFERRED_IN,    // bytes transferred into Exchange
  41.     COUNTERTYPE_MESSAGES_TRANSFERRED_OUT, // msgs transferred out of Exchange
  42.     COUNTERTYPE_BYTES_TRANSFERRED_OUT,    // bytes transferred out of Exchange
  43.     COUNTERTYPE_NDRS_IN,                // number of NDRs into Exchange
  44.     COUNTERTYPE_NDRS_OUT,                // number of NDRs out of Exchange
  45.     COUNTERTYPE_ASSOCIATIONS,             // total number of associations
  46.     COUNTERTYPE_USER_DEFINED,             // counter maintained by user
  47.     COUNTERTYPE_LAST                    // all counter types are less than this
  48. } COUNTERTYPE;
  49.  
  50. //$--PERIODTYPE-----------------------------------------------------------------
  51. //  Tells what period the given statistic is to be totaled over.
  52. // -----------------------------------------------------------------------------
  53. typedef enum _PeriodType                // (hungarian notation = per)
  54. {
  55.     PERIODTYPE_NONE = 0,                // not a period statistic
  56.     PERIODTYPE_CONTINUOUS,                // last Perf. Monitor sampling period
  57.     PERIODTYPE_LAST_N_MINUTES,            // past N 1-minute intervals
  58.     PERIODTYPE_TOTAL,                    // since gateway started
  59.     PERIODTYPE_LAST                        // all period types are less than this
  60. } PERIODTYPE;
  61.  
  62. //
  63. // Structure Definitions
  64. //
  65.  
  66. //$--COUNTER--------------------------------------------------------------------
  67. //  The type for a variable that is being used as a counter.
  68. // -----------------------------------------------------------------------------
  69. typedef DWORD COUNTER, *LPCOUNTER;      // (hungarian notation = cnt)
  70.  
  71. //$--COUNTERDEF-----------------------------------------------------------------
  72. //  A table of these structures is passed into rcMonitorInit() to describe the 
  73. //  counters used in performance monitoring.  A counter table consisting of a 
  74. //  table of COUNTER's is created, and it is guaranteed that the counters will 
  75. //  be contiguous and in the same order as they are described in this table.
  76. //  Contiguity is needed for some cases of calculated counters using user 
  77. //  defined counters.
  78. // -----------------------------------------------------------------------------
  79. typedef struct _CounterDef                // (hungarian notation = cd)
  80. {
  81.     DWORD iCounterTitleOffset;            // index to counter name in registry 
  82.                                         // (offset from First Counter)
  83.     COUNTERTYPE ctStatistic;            // which statistic this counter monitors
  84.     LPMAPIFOLDER lpFolder;                // folder that counter is from (if 
  85.                                         // applicable)
  86.     PERIODTYPE perPeriod;                // Period to total statistic (if 
  87.                                         // applicable)
  88.     DWORD cMinutes;                        // N for PERIODTYPE_LAST_N_MINUTES
  89.     LPCOUNTER * lppcntUserCounter;        // address to return a pointer to 
  90.                                         // actual counter (for a user defined 
  91.                                         // counter), or NULL if not needed
  92.     DWORD dwUserCounterType;            // counter type as defined in winperf.h
  93.                                         // (for a user defined counter)
  94.     DWORD dwDetailLevel;                // counter complexity (from winperf.h)
  95.     DWORD dwDefaultScale;                // default scale (from winperf.h)
  96. } COUNTERDEF, *LPCOUNTERDEF;
  97.  
  98. //
  99. // Public Function Declarations
  100. //
  101.  
  102. //$--HrMonInit--------------------------------------------------------------
  103. //  Begins performance monitoring of the current monitored object.
  104. //
  105. //  If lpszObjectClass != NULL, then use lpszObjectClass as the class of the  
  106. //  monitored object.
  107. //  If lpszObjectClass == NULL, then read the object class from the 
  108. //  Parameters\ObjectClass value under the object's registry key, or if 
  109. //  it's not present, assume that the object class is the same as the object 
  110. //  name.
  111. // -----------------------------------------------------------------------------
  112. HRESULT HrMonInit(                     // RETURNS: HRESULT
  113.     IN DWORD dwFlags,                    // for future use--must be zero
  114.     IN LPSTR lpszObjectClass,            // class of monitored object, or NULL
  115.     IN LPSTR lpszObjectName,             // gateway instance name
  116.     IN DWORD dwObjectTitleOffset,        // index number of object name in 
  117.                                         // the registry database (offset from
  118.                                         // First Counter)
  119.     IN DWORD dwObjectDetailLevel,        // complexity of object (see winperf.h)
  120.     IN LONG dwDefaultCounter,            // zero-based number of default counter 
  121.                                         // for this object
  122.     IN DWORD ccdNumberOfCounters,        // number of counter structures
  123.                                         // being passed in
  124.     IN LPCOUNTERDEF lpcdCounters);        // pointer to array of counter
  125.                                         // structures
  126.  
  127. //$--HrMonUninit----------------------------------------------------------
  128. //  Ends performance monitoring of the current gateway.
  129. // -----------------------------------------------------------------------------
  130. HRESULT HrMonUninit(void);        // RETURNS: HRESULT
  131.  
  132. //$--HrMonCollectNDRStats----------------------------------------------------
  133. //  Call this after processing an NDR.
  134. // -----------------------------------------------------------------------------
  135. HRESULT HrMonCollectNDRStats(        // RETURNS: HRESULT
  136.     IN DWORD cNDRs,                        // number of NDR's processed
  137.     IN DIRECTIONTYPE dir);                // direction of NDR's
  138.  
  139. //$--HrMonCollectMessageXferStats-------------------------------------
  140. //  Call this after transferring a message.
  141. // -----------------------------------------------------------------------------
  142. HRESULT HrMonCollectMessageXferStats( // RETURNS: HRESULT
  143.     IN DWORD cMessages,                 // number of messages transferred
  144.     IN DWORD cBytes,                     // number of bytes transferred
  145.     IN DIRECTIONTYPE dir);                // direction of message transfer
  146.  
  147. //$--HrMonCollectAssociationStats--------------------------------------------
  148. //  Call this after making or breaking an association, or to set a new total 
  149. //  number of associations.
  150. // -----------------------------------------------------------------------------
  151. HRESULT HrMonCollectAssociationStats( // RETURNS: HRESULT
  152.     IN BOOL fSetNewTotal,                // if TRUE, iAssociations becomes 
  153.                                         // the new total of associations.
  154.                                         // if FALSE, iAssociations is added 
  155.                                         // to the number of associations.
  156.  
  157.     IN LONG cAssociations);                // number of associations to add to
  158.                                         // total (can be negative), or new 
  159.                                         // total if fSetNewTotal == TRUE
  160.  
  161. //$--HrMonLockCounters------------------------------------------------------
  162. //  Locks the block of counters against access by other threads/processes.
  163. //  This should be called before accessing a user defined counter.
  164. // -----------------------------------------------------------------------------
  165. HRESULT HrMonLockCounters(void);    // RETURNS: HRESULT
  166.  
  167. //$--HrMonUnlockCounters----------------------------------------------------
  168. //  Unlocks the block of counters to allow access by other threads/processes.
  169. //  This should be called after accessing a user defined counter.
  170. // -----------------------------------------------------------------------------
  171. HRESULT HrMonUnlockCounters(void);    // RETURNS: HRESULT
  172.  
  173. #ifdef __cplusplus
  174. }
  175. #endif
  176.  
  177. #endif
  178.