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.

133 lines
3.4 KiB

  1. #include "denpre.h"
  2. #include "windows.h"
  3. #define _PERF_CMD
  4. #include <asppdef.h> // from denali
  5. char *counterName[C_PERF_PROC_COUNTERS] = {
  6. "ID_DEBUGDOCREQ",
  7. "ID_REQERRRUNTIME",
  8. "ID_REQERRPREPROC",
  9. "ID_REQERRCOMPILE",
  10. "ID_REQERRORPERSEC",
  11. "ID_REQTOTALBYTEIN",
  12. "ID_REQTOTALBYTEOUT",
  13. "ID_REQEXECTIME",
  14. "ID_REQWAITTIME",
  15. "ID_REQCOMFAILED",
  16. "ID_REQBROWSEREXEC",
  17. "ID_REQFAILED",
  18. "ID_REQNOTAUTH",
  19. "ID_REQNOTFOUND",
  20. "ID_REQCURRENT",
  21. "ID_REQREJECTED",
  22. "ID_REQSUCCEEDED",
  23. "ID_REQTIMEOUT",
  24. "ID_REQTOTAL",
  25. "ID_REQPERSEC",
  26. "ID_SCRIPTFREEENG",
  27. "ID_SESSIONLIFETIME",
  28. "ID_SESSIONCURRENT",
  29. "ID_SESSIONTIMEOUT",
  30. "ID_SESSIONSTOTAL",
  31. "ID_TEMPLCACHE",
  32. "ID_TEMPLCACHEHITS",
  33. "ID_TEMPLCACHETRYS",
  34. "ID_TEMPLFLUSHES",
  35. "ID_TRANSABORTED",
  36. "ID_TRANSCOMMIT",
  37. "ID_TRANSPENDING",
  38. "ID_TRANSTOTAL",
  39. "ID_TRANSPERSEC",
  40. "ID_MEMORYTEMPLCACHE",
  41. "ID_MEMORYTEMPLCACHEHITS",
  42. "ID_MEMORYTEMPLCACHETRYS",
  43. "ID_ENGINECACHEHITS",
  44. "ID_ENGINECACHETRYS",
  45. "ID_ENGINEFLUSHES"
  46. };
  47. CPerfMainBlock g_Shared; // shared global memory block
  48. __cdecl main(int argc, char *argv[])
  49. {
  50. DWORD dwCounters[C_PERF_PROC_COUNTERS];
  51. HRESULT hr;
  52. // Init the shared memory. This will give us access to the global shared
  53. // memory describing the active asp perf counter shared memory arrays
  54. if (FAILED(hr = g_Shared.Init())) {
  55. printf("Init() failed - %x\n", hr);
  56. return -1;
  57. }
  58. // give a little high level info about what is registered in the shared
  59. // array
  60. printf("Number of processes registered = %d\n", g_Shared.m_pData->m_cItems);
  61. // ident past the column with the counter names
  62. printf("\t");
  63. // the first counter column will contain the dead proc counters
  64. printf("DeadProcs\t");
  65. // print out the proc ids of the registered asp perf counter memory arrays
  66. for (DWORD i = 0; i < g_Shared.m_pData->m_cItems; i++) {
  67. printf("%d\t", g_Shared.m_pData->m_dwProcIds[i]);
  68. }
  69. // the last column is the counters total across all instances plus dead procs
  70. printf("Total\n");
  71. // need to call GetStats() to cause the perf blocks to get loaded
  72. if (FAILED(hr = g_Shared.GetStats(dwCounters))) {
  73. printf("GetStats() failed - %x\n",hr);
  74. goto LExit;
  75. }
  76. // now enter a loop to print out all of the counter values
  77. for (DWORD i=0; i < C_PERF_PROC_COUNTERS; i++) {
  78. // initialize total to be the value found in the dead proc array
  79. DWORD total=g_Shared.m_pData->m_rgdwCounters[i];
  80. // get the first proc block in the list
  81. CPerfProcBlock *pBlock = g_Shared.m_pProcBlock;
  82. // print the name of the counter first
  83. printf("%s\t",counterName[i]);
  84. // next the dead proc counter value
  85. printf("%d\t",g_Shared.m_pData->m_rgdwCounters[i]);
  86. // print out each proc block's value for this counter. Add the
  87. // value to the running total
  88. while (pBlock) {
  89. total += pBlock->m_pData->m_rgdwCounters[i];
  90. printf("%d\t",pBlock->m_pData->m_rgdwCounters[i]);
  91. pBlock = pBlock->m_pNext;
  92. }
  93. // print out the final total
  94. printf("%d\n",total);
  95. }
  96. LExit:
  97. g_Shared.UnInit();
  98. return 0;
  99. }