gpt4 book ai didi

powershell - 创建性能计数器 PowerShell : The Counter layout for the Category specified is invalid

转载 作者:行者123 更新时间:2023-12-03 22:23:48 25 4
gpt4 key购买 nike

我正在尝试使用 PowerShell 创建性能计数器,但由于使用 AverageCount64 而出现以下错误:

"The Counter layout for the Category specified is invalid, a counter of the type: AverageCount64, AverageTimer32, CounterMultiTimer, CounterMultiTimerInverse, CounterMultiTimer100Ns,CounterMultiTimer100NsInverse, RawFraction, or SampleFraction has to be immediately followed by any of the base counter types: AverageBase, CounterMultiBase, RawBase or SampleBase."

我知道我需要为 AverageCount64 类型添加 AverageBase 但不确定如何在我的代码中添加它,特别是因为我有不需要 AverageBase 的类型 (RateOfCountsPerSecond64):

    $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

最佳答案

这可能会让您参与其中。 T 是 [System.Diagnostics.CounterCreationData] 类型,如果您首先创建该对象,那么您可以将其放入您的 Analytics 集合中。错误消息似乎表明您需要在创建计数器时添加基类型。所以我稍微更改了你的最后一行.. 特别是从枚举中添加 RawFraction 的基类型。

$t = [System.Diagnostics.CounterCreationData]::new()
$t.CounterName = 'test'
$t.CounterHelp = 'help me'
$t.CounterType = [System.Diagnostics.PerformanceCounterType]::AverageCount64
$AnalyticsCollection.Add($t)
[System.Diagnostics.PerformanceCounterCategory]::Create('myCounters', 'OK Get Counting', [System.Diagnostics.PerformanceCounterCategoryType]::MultiInstance, $AnalyticsCollection, [System.Diagnostics.PerformanceCountertype]::RawFraction)

我还使用这个博客来帮助我解读该做什么。我希望这能为您指出解决方案的方向。祝你好运 Windows Performance Counter Types

关于powershell - 创建性能计数器 PowerShell : The Counter layout for the Category specified is invalid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47360146/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com