Advertisement
Guest User

Untitled

a guest
Jun 16th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.60 KB | None | 0 0
  1.  
  2. $MAX_RUN_TIME = 300
  3. $TIME_Exceeded = $false
  4. $STATUS = "green"
  5. $STATUSCODE = "&green Everything is looking just fine! &green"
  6. $TEST_FILE = "${env:ProgramFiles(x86)}\BBWin\tmp\aspnethealth"
  7.  
  8. $CurrSTATUS = "&green"
  9. $ExeSTATUS = "&green"
  10. $WaitSTATUS = "&green"
  11. $QueueSTATUS = "&green"
  12. $TimeSTATUS = "&green"
  13.  
  14. $Source = @"
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. using System.Diagnostics;
  21.  
  22. namespace ASPNETPerformance
  23. {
  24.  
  25. public static class Query
  26. {
  27.  
  28. public static IntPtr userHandle = new IntPtr(0);
  29. public static string hostName = ".";
  30. public static string categoryName = "ASP.NET Applications";
  31. public static string instanceName = "__Total__";
  32.  
  33. public static float CurrentConnections()
  34. {
  35.  
  36. string counterName = "Current Connections";
  37.  
  38. PerformanceCounter counter = new PerformanceCounter("Web Service", counterName, "_Total", hostName);
  39.  
  40. return counter.NextValue();
  41.  
  42. }
  43.  
  44. public static float RequestsExecuting()
  45. {
  46.  
  47. string counterName = "Requests Executing";
  48.  
  49. PerformanceCounter counter = new PerformanceCounter(categoryName, counterName, instanceName, hostName);
  50.  
  51. return counter.NextValue();
  52.  
  53. }
  54.  
  55. public static float RequestWaitTime()
  56. {
  57.  
  58. string counterName = "Request Wait Time";
  59.  
  60. PerformanceCounter counter = new PerformanceCounter(categoryName, counterName, instanceName, hostName);
  61.  
  62. return counter.NextValue();
  63.  
  64. }
  65.  
  66. public static float RequestsInApplicationQueue()
  67. {
  68.  
  69. string counterName = "Requests In Application Queue";
  70.  
  71. PerformanceCounter counter = new PerformanceCounter(categoryName, counterName, instanceName, hostName);
  72.  
  73. return counter.NextValue();
  74.  
  75. }
  76.  
  77. public static float RequestExecutionTime()
  78. {
  79.  
  80. string counterName = "Request Execution Time";
  81.  
  82. PerformanceCounter counter = new PerformanceCounter(categoryName, counterName, instanceName, hostName);
  83.  
  84. return counter.NextValue();
  85. }
  86.  
  87. }
  88.  
  89. }
  90.  
  91. "@
  92.  
  93. try{
  94. Add-Type -TypeDefinition $Source -Language CSharp
  95. }
  96. catch
  97. {
  98. }
  99.  
  100. $CurrentConnections = [ASPNETPerformance.Query]::CurrentConnections()
  101. $RequestsExecuting = [ASPNETPerformance.Query]::RequestsExecuting()
  102. $RequestWaitTime = [ASPNETPerformance.Query]::RequestWaitTime()
  103. $RequestsInApplicationQueue = [ASPNETPerformance.Query]::RequestsInApplicationQueue()
  104. $RequestExecutionTime = [ASPNETPerformance.Query]::RequestExecutionTime()
  105.  
  106. if ($TIME_Exceeded) {
  107. $STATUS = "yellow"
  108. $STATUSCODE = "Something is wrong with this test reporting to Hobbit"
  109. }
  110.  
  111. if(($CurrentConnections -gt 15000) -and (!($CurrentConnections -gt 16000)))
  112. {
  113. $CurrSTATUS = "&yellow"
  114. $STATUSCODE = "&yellow Current Connections exceed 15000 &yellow"
  115. }
  116.  
  117. if($CurrentConnections -gt 16000)
  118. {
  119. $CurrSTATUS = "&red"
  120. $STATUSCODE = "&red Current Connections exceed 16000 &red"
  121. }
  122.  
  123.  
  124.  
  125. if(($RequestsExecuting -gt 3000) -and (!($RequestsExecuting -gt 5000)))
  126. {
  127. $ExeSTATUS = "&yellow"
  128. $STATUSCODE = "&yellow Requests Executing exceeds 3000 &yellow"
  129. }
  130.  
  131. if($RequestsExecuting -gt 5000)
  132. {
  133. $ExeSTATUS = "&red"
  134. $STATUSCODE = "&red Requests Executing exceeds 5000 &red"
  135. }
  136.  
  137.  
  138.  
  139. if(($RequestWaitTime -gt 60000) -and (!($RequestWaitTime -gt 70000)))
  140. {
  141. $WaitSTATUS = "&yellow"
  142. $STATUSCODE = "&yellow Request Wait Time exceeds 60000 &yellow"
  143. }
  144.  
  145. if($RequestWaitTime -gt 70000)
  146. {
  147. $WaitSTATUS = "&red"
  148. $STATUSCODE = "&red Requests Wait Time exceeds 70000 &red"
  149. }
  150.  
  151.  
  152.  
  153. if(($RequestsInApplicationQueue -gt 20) -and (!($RequestsInApplicationQueue -gt 50)))
  154. {
  155. $QueueSTATUS = "&yellow"
  156. $STATUSCODE = "&yellow Requests in Queue exceed 20 &yellow"
  157. }
  158.  
  159. if($RequestsInApplicationQueue -gt 50)
  160. {
  161. $QueueSTATUS = "&red"
  162. $STATUSCODE = "&red Requests in Queue exceed 50 &red"
  163. }
  164.  
  165.  
  166.  
  167. if(($RequestExecutionTime -gt 60000) -and (!($RequestExecutionTime -gt 70000)))
  168. {
  169. $TimeSTATUS = "&yellow"
  170. $STATUSCODE = "&yellow Request Execution Time exceeds 60000 &yellow"
  171. }
  172. if($RequestExecutionTime -gt 70000)
  173. {
  174. $TimeSTATUS = "&red"
  175. $STATUSCODE = "&red Request Execution Time exceeds 70000 &red"
  176. }
  177.  
  178.  
  179.  
  180. if(($CurrSTATUS -eq "&yellow") -or ($ExeSTATUS -eq "&yellow") -or ($WaitSTATUS -eq "&yellow") -or ($QueueSTATUS -eq "&yellow") -or ($TimeSTATUS -eq "&yellow"))
  181. {
  182. $STATUS = "yellow"
  183. }
  184. if(($CurrSTATUS -eq "&red") -or ($ExeSTATUS -eq "&red") -or ($WaitSTATUS -eq "&red") -or ($QueueSTATUS -eq "&red") -or ($TimeSTATUS -eq "&red"))
  185. {
  186. $STATUS = "red"
  187. }
  188.  
  189.  
  190.  
  191. $end = Get-Date
  192. $STATUS = "$STATUS $end"
  193. $STATUS | out-file -Encoding ASCII $TEST_FILE -Force
  194. $Herp = "ASP.NET Application Information `n" | out-file -Encoding ASCII $TEST_FILE -Append
  195. $skeep = "$STATUSCODE`n`n" | out-file -Encoding ASCII $TEST_FILE -Append
  196. $Derp = $CurrSTATUS + " Current Connections: " + $CurrentConnections | out-file -Encoding ASCII $TEST_FILE -Append
  197. $Merp = $ExeSTATUS + " Requests Executing: " + $RequestsExecuting | out-file -Encoding ASCII $TEST_FILE -Append
  198. $Cherp = $WaitSTATUS + " Request Wait Time: " + $RequestWaitTime | out-file -Encoding ASCII $TEST_FILE -Append
  199. $Berp = $QueueSTATUS + " Requests In Queue: " + $RequestsInApplicationQueue | out-file -Encoding ASCII $TEST_FILE -Append
  200. $Flerp = $TimeSTATUS + " Request Exec Time: " + $RequestExecutionTime | out-file -Encoding ASCII $TEST_FILE -Append
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement