2017-11-17 14 views
3

である私はPowerShellを使用してパフォーマンスカウンタを作成しようとしていますが、原因AverageCount64の私の使用に次のエラーを取得しています:パフォーマンス比較は、PowerShellをカウンタの作成:指定したカテゴリのカウンタのレイアウトが無効

「カウンターレイアウトを指定されたカテゴリが無効であるため、タイプのカウンタ :AverageBase、CounterMultiBase:AverageCount64、AverageTimer32、CounterMultiTimer、 CounterMultiTimerInverse、 CounterMultiTimer100Ns、CounterMultiTimer100NsInverse、RawFraction、または SampleFractionは直ちにベース カウンタタイプのいずれかが続くされなければなりません、RawBaseまたはS ampleBase "

私はAverageCount64ですが、私はAverageBaseを必要としないタイプ(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 

答えて

6

これはあなたを途中降機にさせるかもしれません。最初にそのオブジェクトを作成してからAnalyticsコレクションに入れることができる場合、Tは[System.Diagnostics.CounterCreationData]タイプです。エラーメッセージは、カウンタの作成に基本型を追加する必要があることを示しているようです。最後の行を少し変更しました。具体的には、列挙からRawFractionのbasetypeを追加しました。

$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

+0

感謝。私の実際のコレクションは70以上のカウンターがあり、あるものはAverageBaseが必要です。混合型の複数のカウンターではどのように機能しますか? – Kode

+2

私はあなたがAveragebaseかRawfractionであるかどうかにかかわらず、基礎となるカウンターのタイプを指定することができると思います。そのため、追加の周りにループを作成し、AnalyticsCollection変数に追加する各アイテムに使用する必要があるタイプを変更するだけで済みます。 –

関連する問題