我試圖創建一個使用PowerShell的性能計數器,但我得到以下錯誤,由於我使用AverageCount64的:創建Peformance計數器的PowerShell:爲指定類別的計數器佈局無效
「反佈局對於指定的類別是無效的,一個計數器的類型的 :AverageCount64,AverageTimer32,CounterMultiTimer, CounterMultiTimerInverse, CounterMultiTimer100Ns,CounterMultiTimer100NsInverse,RawFraction,或 SampleFraction必須被隨後立即任何基部 計數器類型:AverageBase,CounterMultiBase ,RawBase或S ampleBase「。
我知道,我需要添加AverageBase對於那些AverageCount64但我不確定如何添加在我的代碼,尤其是因爲我有類型(RateOfCountsPerSecond64)類型不需要AverageBase:
$AnalyticsCollection = New-Object System.Diagnostics.CounterCreationDataCollection
$AnalyticsCollection.Add((New-Object $ccdTypeName "Aggregation | Total Aggregation Errors/sec", "The total number of interactions which could not be aggregated due to an exception.", RateOfCountsPerSecond64))
$AnalyticsCollection.Add((New-Object $ccdTypeName "Aggregation | Average Check Out Time - History (ms)", "Average time it takes to obtain a work item from a range scheduler while rebuilding the reporting database.", AverageCount64))
$AnalyticsCollection.Add((New-Object $ccdTypeName "Collection | Total Visits/sec", "The total number of visits per second that are registered by the system.", RateOfCountsPerSecond64))
$AnalyticsCollection.Add((New-Object $ccdTypeName "Aggregation | Average Check In Time - History (ms)", "Average time it takes to mark a work item as completed in a range scheduler while rebuilding the reporting database.", AverageCount64))
[System.Diagnostics.PerformanceCounterCategory]::Create("My Counters", "I love my performance counters", [Diagnostics.PerformanceCounterCategoryType]::MultiInstance, $AnalyticsCollection) | out-null
謝謝。我的實際收藏有70多個計數器,有些需要AverageBase,其他則不需要。這將如何工作的混合類型的多個計數器? – Kode
我認爲每次添加都可以指定底層計數器的類型,無論它是Averagebase還是Rawfraction。因此您只需圍繞添加編寫一個循環,並更改您添加到AnalyticsCollection變量中的每個項目所需的類型。 –