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.

143 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name :
  4. stats.cxx
  5. Abstract:
  6. Defines functions required for server statistics
  7. Author:
  8. Murali R. Krishnan ( MuraliK ) 04-Nov-1994
  9. Project:
  10. Web Server DLL
  11. Functions Exported:
  12. SMTP_SERVER_STATISTICS::SERVER_STATISTICS( VOID)
  13. VOID SMTP_SERVER_STATISTICS::ClearStatistics( VOID)
  14. DWORD CopyToStatsBuffer( LPSMTP_STATISTICS_1 lpStat)
  15. Revision History:
  16. Sophia Chung ( SophiaC ) 20-Nov-1996
  17. --*/
  18. /************************************************************
  19. * Include Headers
  20. ************************************************************/
  21. #define INCL_INETSRV_INCS
  22. #include "smtpinc.h"
  23. /************************************************************
  24. * Functions
  25. ************************************************************/
  26. /*++
  27. Initializes statistics information for server.
  28. --*/
  29. SMTP_SERVER_STATISTICS::SMTP_SERVER_STATISTICS(SMTP_SERVER_INSTANCE * pInstance)
  30. {
  31. InitializeCriticalSection( & m_csStatsLock);
  32. m_pInstance = pInstance;
  33. ClearStatistics();
  34. } // SMTP_SERVER_STATISTICS::SMTP_SERVER_STATISTICS();
  35. /*++
  36. Clears the counters used for statistics information
  37. --*/
  38. VOID
  39. SMTP_SERVER_STATISTICS::ClearStatistics( VOID)
  40. {
  41. LockStatistics();
  42. ZeroMemory( &m_SmtpStats, sizeof(SMTP_STATISTICS_0) );
  43. m_SmtpStats.TimeOfLastClear = GetCurrentTime();
  44. UnlockStatistics();
  45. } // SMTP_SERVER_STATISTICS::ClearStatistics()
  46. DWORD
  47. SMTP_SERVER_STATISTICS::CopyToStatsBuffer( LPSMTP_STATISTICS_0 lpStat)
  48. /*++
  49. Description:
  50. copies the statistics data from the server statistcs structure
  51. to the SMTP_STATISTICS_1 structure for RPC access.
  52. Arugments:
  53. lpStat pointer to SMTP_STATISTICS_1 object which contains the
  54. data on successful return
  55. Returns:
  56. Win32 error codes. NO_ERROR on success.
  57. --*/
  58. {
  59. AQPerfCounters AqPerf;
  60. HRESULT hr = S_FALSE;
  61. IAdvQueueConfig *pIAdvQueueConfig = NULL;
  62. _ASSERT( lpStat != NULL);
  63. LockStatistics();
  64. pIAdvQueueConfig = m_pInstance->QueryAqConfigPtr();
  65. if(pIAdvQueueConfig != NULL)
  66. {
  67. AqPerf.cbVersion = sizeof(AQPerfCounters);
  68. hr = pIAdvQueueConfig->GetPerfCounters(
  69. &AqPerf,
  70. &(m_SmtpStats.CatPerfBlock));
  71. if(!FAILED(hr))
  72. {
  73. m_SmtpStats.RemoteQueueLength = AqPerf.cCurrentQueueMsgInstances;
  74. m_SmtpStats.NumMsgsDelivered = AqPerf.cMsgsDeliveredLocal;
  75. m_SmtpStats.LocalQueueLength = AqPerf.cCurrentMsgsPendingLocalDelivery;
  76. m_SmtpStats.RemoteRetryQueueLength = AqPerf.cCurrentMsgsPendingRemoteRetry;
  77. m_SmtpStats.NumSendRetries = AqPerf.cTotalMsgRemoteSendRetries;
  78. m_SmtpStats.NumNDRGenerated = AqPerf.cNDRsGenerated;
  79. m_SmtpStats.RetryQueueLength = AqPerf.cCurrentMsgsPendingLocalRetry;
  80. m_SmtpStats.NumDeliveryRetries = AqPerf.cTotalMsgLocalRetries;
  81. m_SmtpStats.ETRNMessages = AqPerf.cTotalMsgsTURNETRN;
  82. m_SmtpStats.CatQueueLength = AqPerf.cCurrentMsgsPendingCat;
  83. m_SmtpStats.MsgsBadmailNoRecipients = AqPerf.cTotalMsgsBadmailNoRecipients;
  84. m_SmtpStats.MsgsBadmailHopCountExceeded = AqPerf.cTotalMsgsBadmailHopCountExceeded;
  85. m_SmtpStats.MsgsBadmailFailureGeneral = AqPerf.cTotalMsgsBadmailFailureGeneral;
  86. m_SmtpStats.MsgsBadmailBadPickupFile = AqPerf.cTotalMsgsBadmailBadPickupFile;
  87. m_SmtpStats.MsgsBadmailEvent = AqPerf.cTotalMsgsBadmailEvent;
  88. m_SmtpStats.MsgsBadmailNdrOfDsn = AqPerf.cTotalMsgsBadmailNdrOfDsn;
  89. m_SmtpStats.MsgsPendingRouting = AqPerf.cCurrentMsgsPendingRouting;
  90. m_SmtpStats.MsgsPendingUnreachableLink = AqPerf.cCurrentMsgsPendingUnreachableLink;
  91. m_SmtpStats.SubmittedMessages = AqPerf.cTotalMsgsSubmitted;
  92. m_SmtpStats.DSNFailures = AqPerf.cTotalDSNFailures;
  93. m_SmtpStats.MsgsInLocalDelivery = AqPerf.cCurrentMsgsInLocalDelivery;
  94. }
  95. }
  96. CopyMemory( lpStat, &m_SmtpStats, sizeof(SMTP_STATISTICS_0) );
  97. UnlockStatistics();
  98. return ( NO_ERROR);
  99. } // CopyToStatsBuffer()
  100. /************************ End of File ***********************/