#navi(../)
* PowerShellでCPUコア毎のCPU使用率を確認する [#e794a181]
Win32_PerfFormattedData_PerOS_Processorクラスを使用して、CPUコア毎のCPU使用率を確認する方法を以下に記します。~

#contents
#htmlinsertpcsp(win-top.html,win-sp.html)

* 関連記事 [#gae604a8]
-[[PowerShellでモニタリングする方法>PowerShell/PowerShellでモニタリングする方法]]

* Win32_PerfFormattedData_PerOS_ProcessorからProcessorTimeを取得する [#acee00f7]
以下のコマンドにより、PercentProcessorTimeを取得することができます。
 PS C:\> Get-WmiObject Win32_PerfFormattedData_PerfOS_Processor | Select-Object Name, PercentProcessorTime
 
 Name                                                                                               PercentProcessorTime
 ----                                                                                               --------------------
 _Total                                                                                                               14
 0                                                                                                                     5
 1                                                                                                                    17
 2                                                                                                                    29
 3                                                                                                                     5
見た目が悪いので Format-Table -AutoSizeを使います。
 PS C:\> Get-WmiObject Win32_PerfFormattedData_PerfOS_Processor | Select-Object Name, PercentProcessorTime | Format-Table -AutoSize
 
 Name   PercentProcessorTime
 ----   --------------------
 _Total                    4
 0                         0
 1                         5
 2                        11
 3                         0

* 各種PercentTimeを確認してみる [#lda72c85]
PercentProcessorTime以外にも、以下の情報が取得できます。(各項目の内容については割愛します。)
 PercentC1Time
 PercentC2Time
 PercentC3Time
 PercentDPCTime
 PercentIdleTime
 PercentInterruptTime
 PercentPrivilegedTime
 PercentProcessorTime
 PercentUserTime
以下に一例を記します。
 PS C:\> Get-WmiObject Win32_PerfFormattedData_PerfOS_Processor | Select-Object Name,PercentIdleTime,PercentInterruptTime,PercentPrivilegedTime,PercentProcessorTime,PercentUserTime | Format-Table -AutoSize
 
 Name   PercentIdleTime PercentInterruptTime PercentPrivilegedTime PercentProcessorTime PercentUserTime
 ----   --------------- -------------------- --------------------- -------------------- ---------------
 _Total              93                    1                     2                    2               0
 0                   93                    0                     0                    0               0
 1                   91                    5                     5                    5               0
 2                   93                    0                     5                    5               0
 3                   96                    0                     0                    0               0
各コアとTotalのCPU使用率情報が取得できます。

以上、PowerShellでCPUコア毎のCPU使用率を取得する方法でした。

#htmlinsertpcsp(win-btm.html,win-sp.html)

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS