Skip to content

Commit

Permalink
Update counter descriptions, provide -Recreate option on script (#72)
Browse files Browse the repository at this point in the history
* Update counter descriptions, provide -Recreate option on script

* More updates to descriptions
  • Loading branch information
DavidBoike authored Jul 19, 2019
1 parent 412e906 commit bd6373a
Showing 1 changed file with 49 additions and 42 deletions.
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()

0 comments on commit bd6373a

Please sign in to comment.