- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 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/
我是一名优秀的程序员,十分优秀!