Source code of Windows XP (NT5)
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.

357 lines
8.7 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name :
  4. stats.hxx
  5. Abstract:
  6. Declares a class consisting of server statistics information.
  7. ( Multiple servers can make use of the same statistics
  8. information by creating distinct server statistics object)
  9. Author:
  10. Murali R. Krishnan ( MuraliK ) 04-Nov-1994
  11. Project:
  12. Web Server DLL
  13. Revision History:
  14. Sophia Chung ( SophiaC ) 20-Nov-1996
  15. --*/
  16. # ifndef _STATS_HXX_
  17. # define _STATS_HXX_
  18. /************************************************************
  19. * Include Headers
  20. ************************************************************/
  21. # include "inetinfo.h" // for definition of W3_STATISTICS_1
  22. # include "iperfctr.hxx" // standard macro defs for counters
  23. /************************************************************
  24. * Type Definitions
  25. ************************************************************/
  26. # define IPW3_STATS_INCR( ctrName) \
  27. void Incr ## ctrName(void) \
  28. { \
  29. IP_INCREMENT_COUNTER( m_W3Stats.ctrName); \
  30. }
  31. # define IPW3_STATS_DECR( ctrName) \
  32. void Decr ## ctrName(void) \
  33. { \
  34. IP_DECREMENT_COUNTER( m_W3Stats.ctrName); \
  35. }
  36. # define IPW3_STATS_QUERY( ctrName) \
  37. LONG Query ## ctrName(void) \
  38. { \
  39. return (IP_COUNTER_VALUE( m_W3Stats.ctrName)); \
  40. }
  41. //
  42. // A counter inside the statistics block should use the following three
  43. // macros for defining "query", "incr" and "decr" methods inside
  44. // the statistics object
  45. //
  46. # define IPW3_STATS_COUNTER( ctrName) \
  47. IPW3_STATS_INCR( ctrName); \
  48. IPW3_STATS_DECR( ctrName); \
  49. IPW3_STATS_QUERY( ctrName); \
  50. class W3_SERVER_STATISTICS {
  51. private:
  52. W3_STATISTICS_1 m_W3Stats;
  53. CRITICAL_SECTION m_csStatsLock; // to synchronize access among threads
  54. IPW3_STATS_INCR( CurrentAnonymousUsers);
  55. IPW3_STATS_INCR( CurrentNonAnonymousUsers);
  56. IPW3_STATS_INCR( CurrentCGIRequests);
  57. void IncrCurrentConns( void)
  58. { IP_INCREMENT_COUNTER( m_W3Stats.CurrentConnections); }
  59. public:
  60. VOID LockStatistics( VOID) { EnterCriticalSection( &m_csStatsLock); }
  61. VOID UnlockStatistics( VOID) { LeaveCriticalSection( &m_csStatsLock); }
  62. W3_SERVER_STATISTICS( VOID);
  63. ~W3_SERVER_STATISTICS( VOID)
  64. { DeleteCriticalSection( &m_csStatsLock); };
  65. VOID ClearStatistics( VOID);
  66. LPW3_STATISTICS_1 QueryStatsObj( VOID)
  67. { return &m_W3Stats; }
  68. //
  69. // copies statistics for RPC querying.
  70. //
  71. DWORD CopyToStatsBuffer( LPW3_STATISTICS_1 lpStat );
  72. void IncrCurrentConnections( void);
  73. IPW3_STATS_QUERY( CurrentConnections);
  74. IPW3_STATS_DECR( CurrentConnections);
  75. IPW3_STATS_COUNTER( LogonAttempts);
  76. IPW3_STATS_COUNTER( ConnectionAttempts);
  77. // Anonymous Users
  78. void IncrAnonymousUsers( void);
  79. IPW3_STATS_DECR( CurrentAnonymousUsers);
  80. IPW3_STATS_COUNTER( TotalAnonymousUsers);
  81. // Non Anonymous Users
  82. void IncrNonAnonymousUsers( void);
  83. IPW3_STATS_DECR( CurrentNonAnonymousUsers);
  84. IPW3_STATS_COUNTER( TotalNonAnonymousUsers);
  85. // CGI Requests
  86. void IncrCGIRequests( void);
  87. IPW3_STATS_DECR( CurrentCGIRequests);
  88. IPW3_STATS_QUERY( CurrentCGIRequests);
  89. IPW3_STATS_COUNTER( TotalCGIRequests);
  90. // BGI Requests
  91. void IncrBGIRequests( void);
  92. IPW3_STATS_COUNTER( CurrentBGIRequests); // should be deprecated.
  93. IPW3_STATS_COUNTER( TotalBGIRequests);
  94. VOID UpdateMaxBGI(VOID);
  95. // Various Method Counters
  96. IPW3_STATS_COUNTER( TotalDeletes);
  97. IPW3_STATS_COUNTER( TotalGets);
  98. IPW3_STATS_COUNTER( TotalHeads);
  99. IPW3_STATS_COUNTER( TotalNotFoundErrors);
  100. IPW3_STATS_COUNTER( TotalOthers);
  101. IPW3_STATS_COUNTER( TotalPosts);
  102. IPW3_STATS_COUNTER( TotalPuts);
  103. IPW3_STATS_COUNTER( TotalTraces);
  104. #if defined(CAL_ENABLED)
  105. // CAL counters
  106. void IncrCurrentCalAuth( void );
  107. IPW3_STATS_DECR( CurrentCalAuth );
  108. IPW3_STATS_INCR( TotalFailedCalAuth );
  109. void IncrCurrentCalSsl( void );
  110. IPW3_STATS_DECR( CurrentCalSsl );
  111. IPW3_STATS_INCR( TotalFailedCalSsl );
  112. #endif
  113. VOID UpdateStartTime ();
  114. VOID UpdateStopTime ();
  115. }; // W3_SERVER_STATISTICS
  116. typedef W3_SERVER_STATISTICS FAR * LPW3_SERVER_STATISTICS;
  117. /************************************************************
  118. * Inline Methods
  119. ************************************************************/
  120. inline void W3_SERVER_STATISTICS::UpdateMaxBGI(void)
  121. {
  122. # ifdef IP_ENABLE_COUNTERS
  123. if ( m_W3Stats.CurrentBGIRequests > m_W3Stats.MaxBGIRequests) {
  124. LockStatistics();
  125. if ( m_W3Stats.CurrentBGIRequests > m_W3Stats.MaxBGIRequests) {
  126. m_W3Stats.MaxBGIRequests = m_W3Stats.CurrentBGIRequests;
  127. }
  128. UnlockStatistics();
  129. }
  130. # endif // IP_ENABLE_COUNTERS
  131. return;
  132. } // W3_SERVER_STATISTICS::UpdateMaxBGI()
  133. #if defined(CAL_ENABLED)
  134. inline void W3_SERVER_STATISTICS::IncrCurrentCalAuth(void)
  135. {
  136. # ifdef IP_ENABLE_COUNTERS
  137. IP_INCREMENT_COUNTER( m_W3Stats.CurrentCalAuth);
  138. if ( m_W3Stats.CurrentCalAuth > m_W3Stats.MaxCalAuth) {
  139. LockStatistics();
  140. if ( m_W3Stats.CurrentCalAuth > m_W3Stats.MaxCalAuth) {
  141. m_W3Stats.MaxCalAuth = m_W3Stats.CurrentCalAuth;
  142. }
  143. UnlockStatistics();
  144. }
  145. # endif // IP_ENABLE_COUNTERS
  146. return;
  147. } // W3_SERVER_STATISTICS::UpdateMaxCalAuth()
  148. inline void W3_SERVER_STATISTICS::IncrCurrentCalSsl(void)
  149. {
  150. # ifdef IP_ENABLE_COUNTERS
  151. IP_INCREMENT_COUNTER( m_W3Stats.CurrentCalSsl);
  152. if ( m_W3Stats.CurrentCalSsl > m_W3Stats.MaxCalSsl) {
  153. LockStatistics();
  154. if ( m_W3Stats.CurrentCalSsl > m_W3Stats.MaxCalSsl) {
  155. m_W3Stats.MaxCalSsl = m_W3Stats.CurrentCalSsl;
  156. }
  157. UnlockStatistics();
  158. }
  159. # endif // IP_ENABLE_COUNTERS
  160. return;
  161. } // W3_SERVER_STATISTICS::UpdateMaxCalSsl()
  162. #endif
  163. inline void W3_SERVER_STATISTICS::IncrBGIRequests(void)
  164. {
  165. # ifdef IP_ENABLE_COUNTERS
  166. IncrTotalBGIRequests();
  167. IncrCurrentBGIRequests();
  168. if ( m_W3Stats.CurrentBGIRequests > m_W3Stats.MaxBGIRequests )
  169. {
  170. LockStatistics();
  171. if ( m_W3Stats.CurrentBGIRequests > m_W3Stats.MaxBGIRequests )
  172. m_W3Stats.MaxBGIRequests = m_W3Stats.CurrentBGIRequests;
  173. UnlockStatistics();
  174. }
  175. # endif // IP_ENABLE_COUNTERS
  176. return;
  177. } // W3_SERVER_STATISTICS::IncrBGIRequests()
  178. inline void W3_SERVER_STATISTICS::IncrCGIRequests(void)
  179. {
  180. # ifdef IP_ENABLE_COUNTERS
  181. IncrCurrentCGIRequests();
  182. if ( m_W3Stats.CurrentCGIRequests > m_W3Stats.MaxCGIRequests )
  183. {
  184. LockStatistics();
  185. if ( m_W3Stats.CurrentCGIRequests > m_W3Stats.MaxCGIRequests )
  186. m_W3Stats.MaxCGIRequests = m_W3Stats.CurrentCGIRequests;
  187. UnlockStatistics();
  188. }
  189. # endif // IP_ENABLE_COUNTERS
  190. return;
  191. } // W3_SERVER_STATISTICS::IncrCGIRequests()
  192. inline void W3_SERVER_STATISTICS::IncrCurrentConnections(void)
  193. {
  194. #ifdef IP_ENABLE_COUNTERS
  195. IncrCurrentConns();
  196. if ( m_W3Stats.CurrentConnections > m_W3Stats.MaxConnections ) {
  197. LockStatistics();
  198. if ( m_W3Stats.CurrentConnections > m_W3Stats.MaxConnections ) {
  199. m_W3Stats.MaxConnections = m_W3Stats.CurrentConnections;
  200. }
  201. UnlockStatistics();
  202. }
  203. # endif // IP_ENABLE_COUNTERS
  204. return;
  205. } // W3_SERVER_STATISTICS::IncrCurrentConnections()
  206. inline void W3_SERVER_STATISTICS::IncrAnonymousUsers( void)
  207. {
  208. # ifdef IP_ENABLE_COUNTERS
  209. IncrTotalAnonymousUsers();
  210. IncrCurrentAnonymousUsers();
  211. if ( m_W3Stats.CurrentAnonymousUsers > m_W3Stats.MaxAnonymousUsers )
  212. {
  213. LockStatistics();
  214. if ( m_W3Stats.CurrentAnonymousUsers > m_W3Stats.MaxAnonymousUsers )
  215. {
  216. m_W3Stats.MaxAnonymousUsers = m_W3Stats.CurrentAnonymousUsers;
  217. }
  218. UnlockStatistics();
  219. }
  220. # endif // IP_ENABLE_COUNTERS
  221. return;
  222. } // W3_SERVER_STATISTICS::IncrAnonymousUsers()
  223. inline void W3_SERVER_STATISTICS::IncrNonAnonymousUsers( void)
  224. {
  225. # ifdef IP_ENABLE_COUNTERS
  226. IncrTotalNonAnonymousUsers();
  227. IncrCurrentNonAnonymousUsers();
  228. if ( m_W3Stats.CurrentNonAnonymousUsers > m_W3Stats.MaxNonAnonymousUsers )
  229. {
  230. LockStatistics();
  231. if ( m_W3Stats.CurrentNonAnonymousUsers >
  232. m_W3Stats.MaxNonAnonymousUsers )
  233. {
  234. m_W3Stats.MaxNonAnonymousUsers =
  235. m_W3Stats.CurrentNonAnonymousUsers;
  236. }
  237. UnlockStatistics();
  238. }
  239. # endif // IP_ENABLE_COUNTERS
  240. return;
  241. } // W3_SERVER_STATISTICS::IncrNonAnonymousUsers()
  242. # endif // _STATS_HXX_
  243. /************************ End of File ***********************/