Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $MAX_RUN_TIME = 300
- $TIME_Exceeded = $false
- $STATUS = "green"
- $STATUSCODE = "&green Everything is looking just fine! &green"
- $TEST_FILE = "${env:ProgramFiles(x86)}\BBWin\tmp\aspnethealth"
- $CurrSTATUS = "&green"
- $ExeSTATUS = "&green"
- $WaitSTATUS = "&green"
- $QueueSTATUS = "&green"
- $TimeSTATUS = "&green"
- $Source = @"
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Diagnostics;
- namespace ASPNETPerformance
- {
- public static class Query
- {
- public static IntPtr userHandle = new IntPtr(0);
- public static string hostName = ".";
- public static string categoryName = "ASP.NET Applications";
- public static string instanceName = "__Total__";
- public static float CurrentConnections()
- {
- string counterName = "Current Connections";
- PerformanceCounter counter = new PerformanceCounter("Web Service", counterName, "_Total", hostName);
- return counter.NextValue();
- }
- public static float RequestsExecuting()
- {
- string counterName = "Requests Executing";
- PerformanceCounter counter = new PerformanceCounter(categoryName, counterName, instanceName, hostName);
- return counter.NextValue();
- }
- public static float RequestWaitTime()
- {
- string counterName = "Request Wait Time";
- PerformanceCounter counter = new PerformanceCounter(categoryName, counterName, instanceName, hostName);
- return counter.NextValue();
- }
- public static float RequestsInApplicationQueue()
- {
- string counterName = "Requests In Application Queue";
- PerformanceCounter counter = new PerformanceCounter(categoryName, counterName, instanceName, hostName);
- return counter.NextValue();
- }
- public static float RequestExecutionTime()
- {
- string counterName = "Request Execution Time";
- PerformanceCounter counter = new PerformanceCounter(categoryName, counterName, instanceName, hostName);
- return counter.NextValue();
- }
- }
- }
- "@
- try{
- Add-Type -TypeDefinition $Source -Language CSharp
- }
- catch
- {
- }
- $CurrentConnections = [ASPNETPerformance.Query]::CurrentConnections()
- $RequestsExecuting = [ASPNETPerformance.Query]::RequestsExecuting()
- $RequestWaitTime = [ASPNETPerformance.Query]::RequestWaitTime()
- $RequestsInApplicationQueue = [ASPNETPerformance.Query]::RequestsInApplicationQueue()
- $RequestExecutionTime = [ASPNETPerformance.Query]::RequestExecutionTime()
- if ($TIME_Exceeded) {
- $STATUS = "yellow"
- $STATUSCODE = "Something is wrong with this test reporting to Hobbit"
- }
- if(($CurrentConnections -gt 15000) -and (!($CurrentConnections -gt 16000)))
- {
- $CurrSTATUS = "&yellow"
- $STATUSCODE = "&yellow Current Connections exceed 15000 &yellow"
- }
- if($CurrentConnections -gt 16000)
- {
- $CurrSTATUS = "&red"
- $STATUSCODE = "&red Current Connections exceed 16000 &red"
- }
- if(($RequestsExecuting -gt 3000) -and (!($RequestsExecuting -gt 5000)))
- {
- $ExeSTATUS = "&yellow"
- $STATUSCODE = "&yellow Requests Executing exceeds 3000 &yellow"
- }
- if($RequestsExecuting -gt 5000)
- {
- $ExeSTATUS = "&red"
- $STATUSCODE = "&red Requests Executing exceeds 5000 &red"
- }
- if(($RequestWaitTime -gt 60000) -and (!($RequestWaitTime -gt 70000)))
- {
- $WaitSTATUS = "&yellow"
- $STATUSCODE = "&yellow Request Wait Time exceeds 60000 &yellow"
- }
- if($RequestWaitTime -gt 70000)
- {
- $WaitSTATUS = "&red"
- $STATUSCODE = "&red Requests Wait Time exceeds 70000 &red"
- }
- if(($RequestsInApplicationQueue -gt 20) -and (!($RequestsInApplicationQueue -gt 50)))
- {
- $QueueSTATUS = "&yellow"
- $STATUSCODE = "&yellow Requests in Queue exceed 20 &yellow"
- }
- if($RequestsInApplicationQueue -gt 50)
- {
- $QueueSTATUS = "&red"
- $STATUSCODE = "&red Requests in Queue exceed 50 &red"
- }
- if(($RequestExecutionTime -gt 60000) -and (!($RequestExecutionTime -gt 70000)))
- {
- $TimeSTATUS = "&yellow"
- $STATUSCODE = "&yellow Request Execution Time exceeds 60000 &yellow"
- }
- if($RequestExecutionTime -gt 70000)
- {
- $TimeSTATUS = "&red"
- $STATUSCODE = "&red Request Execution Time exceeds 70000 &red"
- }
- if(($CurrSTATUS -eq "&yellow") -or ($ExeSTATUS -eq "&yellow") -or ($WaitSTATUS -eq "&yellow") -or ($QueueSTATUS -eq "&yellow") -or ($TimeSTATUS -eq "&yellow"))
- {
- $STATUS = "yellow"
- }
- if(($CurrSTATUS -eq "&red") -or ($ExeSTATUS -eq "&red") -or ($WaitSTATUS -eq "&red") -or ($QueueSTATUS -eq "&red") -or ($TimeSTATUS -eq "&red"))
- {
- $STATUS = "red"
- }
- $end = Get-Date
- $STATUS = "$STATUS $end"
- $STATUS | out-file -Encoding ASCII $TEST_FILE -Force
- $Herp = "ASP.NET Application Information `n" | out-file -Encoding ASCII $TEST_FILE -Append
- $skeep = "$STATUSCODE`n`n" | out-file -Encoding ASCII $TEST_FILE -Append
- $Derp = $CurrSTATUS + " Current Connections: " + $CurrentConnections | out-file -Encoding ASCII $TEST_FILE -Append
- $Merp = $ExeSTATUS + " Requests Executing: " + $RequestsExecuting | out-file -Encoding ASCII $TEST_FILE -Append
- $Cherp = $WaitSTATUS + " Request Wait Time: " + $RequestWaitTime | out-file -Encoding ASCII $TEST_FILE -Append
- $Berp = $QueueSTATUS + " Requests In Queue: " + $RequestsInApplicationQueue | out-file -Encoding ASCII $TEST_FILE -Append
- $Flerp = $TimeSTATUS + " Request Exec Time: " + $RequestExecutionTime | out-file -Encoding ASCII $TEST_FILE -Append
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement