From bd6373ab28ee7290803e4b139d617429fabaa868 Mon Sep 17 00:00:00 2001 From: David Boike Date: Fri, 19 Jul 2019 13:24:41 -0500 Subject: [PATCH] Update counter descriptions, provide -Recreate option on script (#72) * Update counter descriptions, provide -Recreate option on script * More updates to descriptions --- .../Scripts/CreateNSBPerfCounters.ps1 | 91 ++++++++++--------- 1 file changed, 49 insertions(+), 42 deletions(-) diff --git a/src/NServiceBus.Metrics.PerformanceCounters/Scripts/CreateNSBPerfCounters.ps1 b/src/NServiceBus.Metrics.PerformanceCounters/Scripts/CreateNSBPerfCounters.ps1 index 9c0c67b..e9e8cc9 100644 --- a/src/NServiceBus.Metrics.PerformanceCounters/Scripts/CreateNSBPerfCounters.ps1 +++ b/src/NServiceBus.Metrics.PerformanceCounters/Scripts/CreateNSBPerfCounters.ps1 @@ -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()