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.

149 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. svcstats.c
  5. Abstract:
  6. This module contains routines for supporting the NetStatisticsGet.
  7. Author:
  8. David Treadwell (davidtr) 12-Apr-1991
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. #include "svcstats.tmh"
  13. #pragma hdrstop
  14. #ifdef ALLOC_PRAGMA
  15. #pragma alloc_text( PAGE, SrvNetStatisticsGet )
  16. #endif
  17. NTSTATUS
  18. SrvNetStatisticsGet (
  19. IN PSERVER_REQUEST_PACKET Srp,
  20. IN PVOID Buffer,
  21. IN ULONG BufferLength
  22. )
  23. /*++
  24. Routine Description:
  25. This routine processes the server half of NetStatisticsGet in
  26. the server FSD.
  27. Arguments:
  28. Srp - a pointer to the server request packet that contains all
  29. the information necessary to satisfy the request. This includes:
  30. INPUT:
  31. Flags - MBZ
  32. OUTPUT:
  33. Not used.
  34. Buffer - a pointer to a STAT_SERVER_0 structure for the new share.
  35. BufferLength - total length of this buffer.
  36. Return Value:
  37. NTSTATUS - result of operation to return to the server service.
  38. --*/
  39. {
  40. SRV_STATISTICS capturedStats;
  41. PSTAT_SERVER_0 sts0 = Buffer;
  42. NTSTATUS status;
  43. PAGED_CODE( );
  44. //
  45. // Make sure that the user's buffer is large enough.
  46. //
  47. if ( BufferLength < sizeof(STAT_SERVER_0) ) {
  48. Srp->ErrorCode = NERR_BufTooSmall;
  49. return STATUS_SUCCESS;
  50. }
  51. //
  52. // Indicate in the SRP that we read one stucture. We always read
  53. // exactly one structure for this API.
  54. //
  55. Srp->Parameters.Get.EntriesRead = 1;
  56. //
  57. // Get a copy of the latest server statistics.
  58. //
  59. SrvUpdateStatisticsFromQueues( &capturedStats );
  60. //
  61. // Fill in the fields in the statistics structure.
  62. //
  63. try {
  64. RtlTimeToSecondsSince1970(
  65. &capturedStats.StatisticsStartTime,
  66. &sts0->sts0_start
  67. );
  68. sts0->sts0_fopens = capturedStats.TotalFilesOpened;
  69. sts0->sts0_devopens = 0;
  70. sts0->sts0_jobsqueued = 0;
  71. sts0->sts0_sopens = capturedStats.CurrentNumberOfSessions;
  72. sts0->sts0_stimedout = capturedStats.SessionsTimedOut;
  73. sts0->sts0_serrorout = capturedStats.SessionsErroredOut;
  74. sts0->sts0_pwerrors = capturedStats.LogonErrors;
  75. sts0->sts0_permerrors = capturedStats.AccessPermissionErrors;
  76. sts0->sts0_syserrors = capturedStats.SystemErrors;
  77. sts0->sts0_bytessent_low = capturedStats.TotalBytesSent.LowPart;
  78. sts0->sts0_bytessent_high = capturedStats.TotalBytesSent.HighPart;
  79. sts0->sts0_bytesrcvd_low = capturedStats.TotalBytesReceived.LowPart;
  80. sts0->sts0_bytesrcvd_high = capturedStats.TotalBytesReceived.HighPart;
  81. //
  82. // Calculate the average response time by finding the total number
  83. // of SMBs we have received, the total time we have spent processing
  84. // them, and dividing to get the average.
  85. //
  86. sts0->sts0_avresponse = 0;
  87. //
  88. // Since we autotune the buffer counts, we never say that we had to
  89. // add more of them. These are supposed to flag an admin that
  90. // parameters need adjustment, but we do it ourselves.
  91. //
  92. // !!! We probably won't really autotune them!
  93. sts0->sts0_reqbufneed = 0;
  94. sts0->sts0_bigbufneed = 0;
  95. status = STATUS_SUCCESS;
  96. } except( EXCEPTION_EXECUTE_HANDLER ) {
  97. status = GetExceptionCode();
  98. }
  99. return status;
  100. } // SrvNetStatisticsGet