- Published on
Bash/Powershell コマンドラインからCPU使用率を出力する
- Authors
- Name
- Shou Arisaka / 有坂翔
LinuxのWSL BashやWindowsのcmd.exe、Powershellなどのコマンドライン上から、CPU使用率を出力する方法について紹介します。

Bashの場合
grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage "%"}'
Powershellの場合
$( Get-WmiObject win32_processor | Measure-Object -property LoadPercentage -Average | Select Average ).Average
C#とかでやりたい場合に参考にどうぞ
get cpu usage site:stackoverflow.com - Google Search