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.

251 lines
12 KiB

  1. //////////////////////////////////////////////////////////////////////
  2. // File: WinHttpStressScheduler.h
  3. //
  4. // Copyright (c) 2001 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // Purpose:
  7. // ServerCommands.h: interface for the ServerCommands class.
  8. // This class is used to retrieve and act on command from the server.
  9. //
  10. // History:
  11. // 02/08/01 DennisCh Created
  12. //
  13. //////////////////////////////////////////////////////////////////////
  14. //////////////////////////////////////////////////////////////////////
  15. // Includes
  16. //////////////////////////////////////////////////////////////////////
  17. //
  18. // WIN32 headers
  19. //
  20. #define UNICODE
  21. #define _UNICODE
  22. #include <stdio.h>
  23. #include <shlwapi.h>
  24. #include <windows.h>
  25. #include <tchar.h>
  26. #include <winhttp.h>
  27. #include <vector>
  28. //
  29. // Project headers
  30. //
  31. #include "StressInstance.h"
  32. //////////////////////////////////////////////////////////////////////
  33. // Constants
  34. //////////////////////////////////////////////////////////////////////
  35. #if !defined(AFX_SERVERCOMMANDS_H__6B84102D_2F79_4FE0_A936_ED4F043AC75E__INCLUDED_)
  36. #define AFX_SERVERCOMMANDS_H__6B84102D_2F79_4FE0_A936_ED4F043AC75E__INCLUDED_
  37. #if _MSC_VER > 1000
  38. #pragma once
  39. #endif // _MSC_VER > 1000
  40. #define STRESS_SCHEDULER_USER_AGENT _T("WinHttp Stress Scheduler")
  41. //#define STRESS_COMMAND_SERVER_URL _T("http://hairball/api/Stress/set-response-header.asp?name=WinHttpStress_Quit&value=")
  42. #define STRESS_COMMAND_SERVER_URL _T("http://hairball/stressAdmin/stressCommand.asp")
  43. #define STRESS_COMMAND_SERVER_RESULTS_URL _T("http://hairball/api/Stress/set-response-header.asp")
  44. // When we first start up, we report our client stats and post them to this page to let the server know that we're alive
  45. #define STRESS_COMMAND_SERVER_REGISTERCLIENT_URL _T("http://hairball/stressAdmin/registerClient.asp")
  46. #define STRESS_COMMAND_SERVER_LOGURL _T("http://hairball/stressAdmin/logStress.asp")
  47. #define STRESS_COMMAND_SERVER_UPDATE_INTERVAL 4000 // 4 second default timeout
  48. #define STRESS_COMMAND_SERVER_MINIMUM_UPDATE_INTERVAL 2000 // 2 second minimum timeout. Don't want to flood the network.
  49. #define STRESS_COMMAND_SERVER_MAXIMUM_UPDATE_INTERVAL 300000 // 5 minute maximum timeout. Don't want to lose you!
  50. #define MAX_URL MAX_PATH * 2
  51. // Timer related definitions
  52. #define IDT_QUERY_COMMAND_SERVER 1 // timer identifier for pinging the command server
  53. // List of URLs for the stress EXE's that we need to download
  54. using namespace std;
  55. typedef StressInstance *PSTRESSINSTANCE;
  56. typedef vector<PSTRESSINSTANCE> PSTRESSINSTANCE_LIST;
  57. // *****************************************************
  58. // *****************************************************
  59. // *** List of headers that the command server can send us.
  60. // ***
  61. #define COMMANDHEADER__EXIT _T("WinHttpStress_Exit") // valid values: None. If the header is present, then assume we want to exit.
  62. #define COMMANDHEADER__WINHTTP_DLL_URL _T("WinHttpStress_WinHttpDllURL") // valid values: Valid URL
  63. #define COMMANDHEADER__WINHTTP_PDB_URL _T("WinHttpStress_WinHttpPDBURL") // valid values: Valid URL
  64. #define COMMANDHEADER__WINHTTP_SYM_URL _T("WinHttpStress_WinHttpSYMURL") // valid values: Valid URL
  65. #define COMMANDHEADER__ABORT _T("WinHttpStress_Abort") // valid values: ID of a stressInstance from the DB that needs to be aborted
  66. #define COMMANDHEADER__MEMORY_DUMP_PATH _T("WinHttpStress_MemoryDumpPath") // valid values: Valid path
  67. #define COMMANDHEADER__STRESS_EXE_URL _T("WinHttpStress_StressExeURL") // valid values: Valid URL
  68. #define COMMANDHEADER__STRESS_PDB_URL _T("WinHttpStress_StressPDBURL") // valid values: Valid URL
  69. #define COMMANDHEADER__STRESS_SYM_URL _T("WinHttpStress_StressSYMURL") // valid values: Valid URL
  70. #define COMMANDHEADER__STRESS_EXE_INSTANCEID _T("WinHttpStress_StressExeInstanceID") // valid values: Valid ID from the stressAdmin DB table identifying the stressInstance. This is how stressScheduler tells stressAdmin the status of each stressInstance.
  71. #define COMMANDHEADER__STRESS_EXE_PAGEHEAP _T("WinHttpStress_PageHeapCommand") // valid values: pageheap command line. will not use pageheap if missing
  72. #define COMMANDHEADER__STRESS_EXE_UMDH _T("WinHttpStress_UMDHCommand") // valid values: UMDH command line. will not use UMDH if missing
  73. #define COMMANDHEADER__COMMANDSERVER_URL _T("WinHttpStress_CommandServerURL") // valid values: Valid URL
  74. #define COMMANDHEADER__BEGIN_TIME_HOUR _T("WinHttpStress_BeginTimeHour") // valid values: 0-23
  75. #define COMMANDHEADER__BEGIN_TIME_MINUTE _T("WinHttpStress_BeginTimeMinute") // valid values: 0-59
  76. #define COMMANDHEADER__END_TIME_HOUR _T("WinHttpStress_EndTimeHour") // valid values: 0-23
  77. #define COMMANDHEADER__END_TIME_MINUTE _T("WinHttpStress_EndTimeMinute") // valid values: 0-59
  78. #define COMMANDHEADER__RUN_FOREVER _T("WinHttpStress_RunForever") // valid values: 0 or 1
  79. #define COMMANDHEADER__UPDATE_INTERVAL _T("WinHttpStress_UpdateInterval") // valid values: Time to wait to ping the command server in milliseconds.
  80. // *****************************************************
  81. // *****************************************************
  82. // *** List of form names and values that we send back to the command server
  83. // ***
  84. // **********************
  85. // ** Logging POST fields
  86. #define FIELDNAME__LOGTYPE "LogType="
  87. #define FIELDNAME__LOGTYPE_INFORMATION FIELDNAME__LOGTYPE "INFORMATION"
  88. #define FIELDNAME__LOGTYPE_START_UP FIELDNAME__LOGTYPE "STRESSSECHDULER_START_UP"
  89. #define FIELDNAME__LOGTYPE_EXIT FIELDNAME__LOGTYPE "STRESSSECHDULER_EXIT"
  90. #define FIELDNAME__LOGTYPE_MEMORY_INFORMATION FIELDNAME__LOGTYPE "MEMORY_INFORMATION"
  91. #define FIELDNAME__LOGTYPE_DUMPFILE_CREATED FIELDNAME__LOGTYPE "DUMP_FILE_CREATED"
  92. #define FIELDNAME__LOGTYPE_ERROR FIELDNAME__LOGTYPE "ERROR"
  93. #define FIELDNAME__LOGTYPE_SUCCESS FIELDNAME__LOGTYPE "SUCCESS"
  94. #define FIELDNAME__LOGTYPE_BEGIN_STRESS FIELDNAME__LOGTYPE "BEGIN_STRESS"
  95. #define FIELDNAME__LOGTYPE_END_STRESS FIELDNAME__LOGTYPE "END_STRESS"
  96. #define FIELDNAME__LOGTYPE_BEGIN FIELDNAME__LOGTYPE "BEGIN_STRESS_INSTANCE"
  97. #define FIELDNAME__LOGTYPE_END FIELDNAME__LOGTYPE "END_STRESS_INSTANCE"
  98. #define FIELDNAME__LOG_TEXT "LogText="
  99. #define FIELDNAME__STRESSINSTANCE_ID "StressInstanceID="
  100. // **********************
  101. // ** System information for registering the client POST fields.
  102. // StressExe process return values
  103. #define FIELDNAME__STRESSEXE_PRIVATEBYTES "StressExe_PrivateBytes=%d"
  104. #define FIELDNAME__STRESSEXE_HANDLECOUNT "StressExe_HandleCount=%d"
  105. #define FIELDNAME__STRESSEXE_THREADCOUNT "StressExe_ThreadCount=%d"
  106. // System Memory Info
  107. #define FIELDNAME__MEMORY_HANDLES "System_Handles=%d"
  108. #define FIELDNAME__MEMORY_THREADS "System_Threads=%d"
  109. #define FIELDNAME__MEMORY_VMSIZE "System_VMSize=%d"
  110. #define FIELDNAME__MEMORY_COMMITTEDPAGEFILETOTAL "System_CommittedPageFileTotal=%d"
  111. #define FIELDNAME__MEMORY_AVAILABLEPAGEFILETOTAL "System_AvailablePageFileTotal=%d"
  112. #define FIELDNAME__MEMORY_SYSTEMCODETOTAL "System_SystemCodeTotal=%d"
  113. #define FIELDNAME__MEMORY_SYSTEMDRIVERTOTAL "System_SystemDriverTotal=%d"
  114. #define FIELDNAME__MEMORY_NONPAGEDPOOLTOTAL "System_NonPagedPoolTotal=%d"
  115. #define FIELDNAME__MEMORY_PAGEDPOOLTOTAL "System_PagedPoolTotal=%d"
  116. #define FIELDNAME__MEMORY_PHYSICAL_MEMORY_AVAILABLE "System_PhysicalMemoryAvailable=%d"
  117. #define FIELDNAME__MEMORY_SYSTEMCACHETOTAL "System_SystemCacheTotal=%d"
  118. #define FIELDNAME__MEMORY_FREESYSTEM_PAGETABLE_ENTRIES "System_FreeSystemPageTableEntries=%d"
  119. #define FIELDNAME__MEMORY_DISK_SPACE_AVAILABLE "System_DiskSpaceAvailable=%d"
  120. // Processor Info
  121. #define FIELDNAME__SYSTEMINFO_PROCSSSOR_ARCHITECTURE "StressExeSystemInfo_ProcessorArchitecture="
  122. #define FIELDNAME__SYSTEMINFO_PROCSSSOR_ID "StressExeSystemInfo_ProcessorID="
  123. #define FIELDNAME__SYSTEMINFO_PROCSSSOR_LEVEL "StressExeSystemInfo_ProcessorLevel="
  124. #define FIELDNAME__SYSTEMINFO_PROCSSSOR_REVISION "StressExeSystemInfo_ProcessorRevision="
  125. #define FIELDNAME__SYSTEMINFO_PROCSSSOR_NUMBER_OF "StressExeSystemInfo_ProcessorNumberOf="
  126. // OS Info
  127. #define FIELDNAME__OS_PLATFORM "StressExeOSInfo_Platform="
  128. #define FIELDNAME__OS_BUILD "StressExeOSInfo_Build="
  129. #define FIELDNAME__OS_MAJORVERSION "StressExeOSInfo_MajorVersion="
  130. #define FIELDNAME__OS_MINORVERSION "StressExeOSInfo_MinorVersion="
  131. #define FIELDNAME__OS_EXTRAINFO "StressExeOSInfo_ExtraInfo="
  132. // User Info
  133. #define FIELDNAME__USERINFO_USERALIAS "StressExeUserInfo_Alias="
  134. #define FIELDNAME__USERINFO_USERDOMAIN "StressExeUserInfo_Domain="
  135. #define FIELDNAME__USERINFO_FULLNAME "StressExeUserInfo_FullName="
  136. #define FIELDNAME__USERINFO_MACHINENAME "StressExeUserInfo_MachineName="
  137. // Test info
  138. #define FIELDNAME__TESTINFO_TEST_DLL_VERSION "StressExeTestInfo_TestDLLVersion="
  139. class ServerCommands
  140. {
  141. public:
  142. // *****************************************************
  143. // *****************************************************
  144. // ** Public ServerCommands methods
  145. // **
  146. ServerCommands();
  147. virtual ~ServerCommands();
  148. BOOL QueryServerForCommands();
  149. BOOL IsStressRunning();
  150. BOOL IsTimeToBeginStress();
  151. BOOL IsTimeToExitStress();
  152. BOOL Download_WinHttpDLL();
  153. VOID Clear_StressExeURLs();
  154. LPSTR Get_ClientMachineName();
  155. DWORD Get_CommandServerUpdateInterval();
  156. LPTSTR Get_CommandServerResultsURL();
  157. LPTSTR Get_CommandServerURL();
  158. LPTSTR Get_CurrentWorkingDirectory();
  159. DWORD Get_NumberOfStressInstances();
  160. LPTSTR Get_TestDllFileName();
  161. VOID Create_StressInstance(DWORD, LPTSTR, LPTSTR, LPTSTR, LPTSTR, LPTSTR, LPTSTR);
  162. BOOL RegisterClient();
  163. VOID Set_WinHttpDllURL(LPTSTR, DWORD);
  164. VOID Set_WinHttpPDBURL(LPTSTR, DWORD);
  165. VOID Set_WinHttpSYMURL(LPTSTR, DWORD);
  166. VOID Set_CommandServerURL(LPTSTR, DWORD);
  167. VOID Set_CommandServerUpdateInterval(DWORD);
  168. VOID Set_TimeStressBegins(LPTSTR, LPTSTR);
  169. VOID Set_TimeStressEnds(LPTSTR, LPTSTR);
  170. VOID Set_RunForever(BOOL);
  171. VOID Set_ExitStress(BOOL);
  172. VOID BeginStress();
  173. VOID EndStress();
  174. VOID AbortStressInstance(DWORD);
  175. private:
  176. // *****************************************************
  177. // *****************************************************
  178. // ** These vars contain commands(headers) from the command server
  179. // **
  180. LPTSTR m_szCommandServerURL; // Command server URL to request commands from
  181. LPTSTR m_szCommandServerResultsURL; // Command server URL where the results will be posted
  182. DWORD m_dwCommandServerUpdateInternval; // Time to wait to ping the server for commands in milliseconds.
  183. LPTSTR m_szWinHttpDLL_DownloadURL; // Where to get the latest WinHttp from
  184. LPTSTR m_szWinHttpPDB_DownloadURL; // Where winhttp's PDB symbol file from
  185. LPTSTR m_szWinHttpSYM_DownloadURL; // Where winhttp's SYM symbol file from
  186. LPTSTR m_szWinHttpDLL_FileName; // Filename of the WinHttp DLL.
  187. LPSTR m_szClientMachineName; // Computer name of the client
  188. LPTSTR m_szStressSchedulerCurrentDirectory; // stressScheduler's current directory.
  189. INT m_iTimeStressBeginsHour; // 0-23
  190. INT m_iTimeStressBeginsMinute; // 0-59
  191. INT m_iTimeStressEndsHour; // 0-23
  192. INT m_iTimeStressEndsMinute; // 0-59
  193. BOOL m_bRunForever; // 1 to run stress until stopped and 0 to rely on begin/end times
  194. BOOL m_bExit; // Quit signal from server to exit the app
  195. BOOL m_bStressHasStarted; // TRUE = started; FALSE = inactive
  196. PSTRESSINSTANCE_LIST m_arStressInstanceList; // List of URLs for the stress EXEs to download
  197. PSTRESSINSTANCE_LIST::iterator m_dwStressInstanceIterator; // Iterator for m_arszStressExeList
  198. };
  199. #endif // !defined(AFX_SERVERCOMMANDS_H__6B84102D_2F79_4FE0_A936_ED4F043AC75E__INCLUDED_)