Last active
June 15, 2019 17:02
-
-
Save mastry/0d712c0114369c4e6a0928052edd475d to your computer and use it in GitHub Desktop.
Continuously sample the queue depth of a single queue on multiple servers. Handy for troubleshooting.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[string[]] | |
$ComputerName, | |
[string] | |
$QueueName, | |
[int] | |
$SampleRate = 5 # once every 5 seconds | |
) | |
while ($true) { | |
Write-Host "Collecting sample..." | |
$SampleTime = [System.DateTime]::Now | |
$Results = $ComputerName | ForEach-Object { | |
gwmi -Class Win32_PerfRawData_MSMQ_MSMQQueue -ComputerName $_ -Filter "Name='$_\\private$\\$($QueueName)'" | |
} | |
$Results | ForEach-Object { Write-Output "$($SampleTime),$($_.PSComputerName),$($_.MessagesInQueue)" } | |
$Summary = $Results | Measure-Object MessagesInQueue -Average -Minimum -Maximum | |
Write-Host "Avg: $($Summary.Average), Min: $($Summary.Minimum), Max: $($Summary.Maximum)" | |
Write-Host "Waiting for next sample period....Press ctrl+c to exit" | |
Start-Sleep -Seconds $SampleRate | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment