-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update counter descriptions, provide -Recreate option on script (#72)
* Update counter descriptions, provide -Recreate option on script * More updates to descriptions
- Loading branch information
1 parent
412e906
commit bd6373a
Showing
1 changed file
with
49 additions
and
42 deletions.
There are no files selected for viewing
91 changes: 49 additions & 42 deletions
91
src/NServiceBus.Metrics.PerformanceCounters/Scripts/CreateNSBPerfCounters.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,52 @@ | ||
[CmdletBinding()] | ||
param( | ||
[switch]$ForceRecreate | ||
) | ||
|
||
#requires -RunAsAdministrator | ||
Function InstallNSBPerfCounters { | ||
|
||
$category = @{Name="NServiceBus"; Description="NServiceBus statistics"} | ||
$counters = New-Object System.Diagnostics.CounterCreationDataCollection | ||
$counters.AddRange(@( | ||
New-Object System.Diagnostics.CounterCreationData "SLA violation countdown", "Seconds until the SLA for this endpoint is breached.", NumberOfItems32 | ||
New-Object System.Diagnostics.CounterCreationData "Critical Time Average", "The time it took from sending to processing the message.", AverageTimer32 | ||
New-Object System.Diagnostics.CounterCreationData "Critical Time AverageBase", "The time it took from sending to processing the message.", AverageBase | ||
New-Object System.Diagnostics.CounterCreationData "Critical Time", "The time it took from sending to processing the message.", NumberOfItems32 | ||
New-Object System.Diagnostics.CounterCreationData "Processing Time Average", "The time it took to successfully process a message.", AverageTimer32 | ||
New-Object System.Diagnostics.CounterCreationData "Processing Time AverageBase", "The time it took to successfully process a message.", AverageBase | ||
New-Object System.Diagnostics.CounterCreationData "Processing Time", "The time it took to successfully process a message.", NumberOfItems32 | ||
New-Object System.Diagnostics.CounterCreationData "# of msgs failures / sec", "The current number of failed processed messages by the transport per second.", RateOfCountsPerSecond32 | ||
New-Object System.Diagnostics.CounterCreationData "# of msgs successfully processed / sec", "The current number of messages processed successfully by the transport per second.", RateOfCountsPerSecond32 | ||
New-Object System.Diagnostics.CounterCreationData "# of msgs pulled from the input queue /sec", "The current number of messages pulled from the input queue by the transport per second.", RateOfCountsPerSecond32 | ||
New-Object System.Diagnostics.CounterCreationData "Retries", "A message has been scheduled for retry (FLR or SLR)", RateOfCountsPerSecond32 | ||
|
||
)) | ||
|
||
if ([System.Diagnostics.PerformanceCounterCategory]::Exists($category.Name)) { | ||
|
||
foreach($counter in $counters){ | ||
$exists = [System.Diagnostics.PerformanceCounterCategory]::CounterExists($counter.CounterName, $category.Name) | ||
if (!$exists){ | ||
Write-Host "One or more counters are missing.The performance counter category will be recreated" | ||
[System.Diagnostics.PerformanceCounterCategory]::Delete($category.Name) | ||
|
||
break | ||
} | ||
} | ||
} | ||
|
||
if (![System.Diagnostics.PerformanceCounterCategory]::Exists($category.Name)) { | ||
Write-Host "Creating the performance counter category" | ||
[void] [System.Diagnostics.PerformanceCounterCategory]::Create($category.Name, $category.Description, [System.Diagnostics.PerformanceCounterCategoryType]::MultiInstance, $counters) | ||
} | ||
else { | ||
Write-Host "No performance counters have to be created" | ||
} | ||
|
||
[System.Diagnostics.PerformanceCounter]::CloseSharedResources() | ||
|
||
$category = @{Name="NServiceBus"; Description="NServiceBus statistics"} | ||
$counters = New-Object System.Diagnostics.CounterCreationDataCollection | ||
$counters.AddRange(@( | ||
New-Object System.Diagnostics.CounterCreationData "SLA violation countdown", "Duration in seconds until the configured Service Level Agreement (SLA) for this endpoint is breached. This is an instantaneous snapshot, not an average over the time interval.", NumberOfItems32 | ||
New-Object System.Diagnostics.CounterCreationData "Critical Time Average", "Average duration in seconds for sending and processing of all messages during the sample interval. Useful to understand how long a new message added to the queue right now will take to be processed.", AverageTimer32 | ||
New-Object System.Diagnostics.CounterCreationData "Critical Time AverageBase", "A base counter used to calculate the Critical Time Average", AverageBase | ||
New-Object System.Diagnostics.CounterCreationData "Critical Time", "Duration in seconds for sending and processing the last processed message, useful to understand how long a new message added to the queue right now will take to be processed. This is an instantaneous snapshot, not an average over the time interval.", NumberOfItems32 | ||
New-Object System.Diagnostics.CounterCreationData "Processing Time Average", "Average duration in seconds of all successfully processed messages during the sample interval.", AverageTimer32 | ||
New-Object System.Diagnostics.CounterCreationData "Processing Time AverageBase", "A base counter used to calculate the Processing Time.", AverageBase | ||
New-Object System.Diagnostics.CounterCreationData "Processing Time", "Duration in seconds of the last successfully processed message. This is an instantaneous snapshot, not an average over the time interval.", NumberOfItems32 | ||
New-Object System.Diagnostics.CounterCreationData "# of msgs failures / sec", "The current number of failed processed messages by the transport per second.", RateOfCountsPerSecond32 | ||
New-Object System.Diagnostics.CounterCreationData "# of msgs successfully processed / sec", "The current number of messages processed successfully by the transport per second.", RateOfCountsPerSecond32 | ||
New-Object System.Diagnostics.CounterCreationData "# of msgs pulled from the input queue /sec", "The current number of messages pulled from the input queue by the transport per second.", RateOfCountsPerSecond32 | ||
New-Object System.Diagnostics.CounterCreationData "Retries", "A message has been scheduled for retry (FLR or SLR)", RateOfCountsPerSecond32 | ||
|
||
)) | ||
|
||
if ([System.Diagnostics.PerformanceCounterCategory]::Exists($category.Name)) { | ||
|
||
if($ForceRecreate) { | ||
Write-Host "Option -ForceRecreate was used. The performance counter category will be recreated" | ||
[System.Diagnostics.PerformanceCounterCategory]::Delete($category.Name) | ||
} | ||
else { | ||
foreach($counter in $counters){ | ||
$exists = [System.Diagnostics.PerformanceCounterCategory]::CounterExists($counter.CounterName, $category.Name) | ||
if (!$exists){ | ||
Write-Host "One or more counters are missing.The performance counter category will be recreated" | ||
[System.Diagnostics.PerformanceCounterCategory]::Delete($category.Name) | ||
|
||
break | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (![System.Diagnostics.PerformanceCounterCategory]::Exists($category.Name)) { | ||
Write-Host "Creating the performance counter category" | ||
[void] [System.Diagnostics.PerformanceCounterCategory]::Create($category.Name, $category.Description, [System.Diagnostics.PerformanceCounterCategoryType]::MultiInstance, $counters) | ||
} | ||
else { | ||
Write-Host "No performance counters have to be created" | ||
} | ||
InstallNSBPerfCounters | ||
|
||
[System.Diagnostics.PerformanceCounter]::CloseSharedResources() |