powershellコマンドを使用して、特定のプロセスのCPU使用率(プロセッサ時間ではなく)を取得したいとします。powershellを使用して特定のプロセスのCPU%を取得する
私はコマンドでその2.9%
を取得したいです。
powershellコマンドを使用して、特定のプロセスのCPU使用率(プロセッサ時間ではなく)を取得したいとします。powershellを使用して特定のプロセスのCPU%を取得する
私はコマンドでその2.9%
を取得したいです。
Get-Process -Name PowerShell | Select CPU
これはあなたが探しているものですか? それ以上のモニタリングに基づいていますか? |ここで
param
(
[String]
[Parameter(Mandatory)]
$Title
)
do
{
$process = Get-Process -Name $Title
$process
Start-Sleep -Seconds 1
} while ($process)
'Get-Process'は、プロセスが持つプロセッサ時間の量すべてのプロセッサで使用され、私はこれを探していません。私はCPU使用率%が欲しいです。 – galahad
は、同じ名前を持つ複数のprocesss https://stackoverflow.com/a/34844682/483997
# To get the PID of the process (this will give you the first occurrance if multiple matches)
$proc_pid = (get-process "slack").Id[0]
# To match the CPU usage to for example Process Explorer you need to divide by the number of cores
$cpu_cores = (Get-WMIObject Win32_ComputerSystem).NumberOfLogicalProcessors
# This is to find the exact counter path, as you might have multiple processes with the same name
$proc_path = ((Get-Counter "\Process(*)\ID Process").CounterSamples | ? {$_.RawValue -eq $proc_pid}).Path
# We now get the CPU percentage
$prod_percentage_cpu = [Math]::Round(((Get-Counter ($proc_path -replace "\\id process$","\% Processor Time")).CounterSamples.CookedValue)/$cpu_cores)
のGet-プロセス-Nameシステムを持ってサポートケースで正しい答えがありますCPUを選択
(cpu2-cpu1)/(t2-t1)* 100の2つのインスタンスでCPU時間を取得します。あなたは%でCPU値を取得します。
[powershellスクリプトで特定のプロセスが消費するCPU使用量とメモリを取得する方法]を参照してください(https://stackoverflow.com/a/34844682) – wOxxOm
'Get-Process'はプロセスが使用したプロセッサ時間すべてのプロセッサで、これはCPU使用率% – galahad
と同じではないと私は考えていません。私は最初の答えだけを見ていました。とった。ありがとう – galahad