Advertisement
Guest User

Untitled

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