Windows NT 4.0 source code leak
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.

138 lines
3.1 KiB

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