cpustat
是一個用于顯示 CPU 使用情況的工具,它是 sysstat
軟件包的一部分。要使用 cpustat
分析數據,首先確保已經安裝了 sysstat
。在 Debian 上,可以使用以下命令安裝:
sudo apt-get update
sudo apt-get install sysstat
安裝完成后,可以通過運行 cpustat
命令來查看 CPU 使用情況。以下是一些常用的 cpustat
選項:
-c
:顯示每個 CPU 的詳細信息。-m
:顯示內存使用情況。-P
:顯示每個進程的 CPU 使用情況。-u
:顯示 CPU 使用率的匯總信息。-y
:顯示系統負載和其他統計信息。以下是一些使用 cpustat
分析數據的示例:
cpustat -c
輸出示例:
Linux 5.4.0-42-generic (hostname) 05/01/2021 _x86_64_ (4 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
12.34 0.01 3.45 0.02 0.00 84.18
CPU : %user %nice %system %iowait %steal %idle
0 : 15.67 0.01 4.56 0.01 0.00 79.75
1 : 10.23 0.02 2.89 0.03 0.00 86.80
2 : 14.56 0.01 3.78 0.02 0.00 81.83
3 : 11.98 0.01 2.67 0.04 0.00 85.30
cpustat -u
輸出示例:
Linux 5.4.0-42-generic (hostname) 05/01/2021 _x86_64_ (4 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
12.34 0.01 3.45 0.02 0.00 84.18
cpustat -y
輸出示例:
Linux 5.4.0-42-generic (hostname) 05/01/2021 _x86_64_ (4 CPU)
uptime : 1 day, 3:45
load average: 0.75 1.25 1.50
System load: 0.85 0.90 0.95
根據需要,可以使用這些選項和其他選項來分析 cpustat
的輸出。此外,可以將輸出重定向到文件中,以便進一步分析或存檔:
cpustat -c > cpu_usage.txt
然后,可以使用文本編輯器或數據分析工具(如 Excel 或 Python)查看和分析數據。