在 Ubuntu 上,cpustat 通常是 sysstat 工具包中的命令(也有 Go 写的 cpustat,下面分别说明)。
mpstat / sar(常被叫做 cpustat)mpstat 1 5 > cpu_usage.txt
1:每 1 秒采样5:采样 5 次sar 导出 CPU 历史数据sar -u 1 5 > cpu_sar.txt
mpstat -o CSV 1 5 > cpu.csv
或
sar -u -o cpu.sar 1 5
sar -u -f cpu.sar > cpu.txt
cpustat(如 github.com/uber-common/cpustat)sudo cpustat -t 1 > cpustat.txt
sudo cpustat -t 1 -j > cpustat.json
nohup mpstat 5 > cpu.log 2>&1 &
或
sar -u 5 > cpu.log &
cat cpu_usage.txt
或
less cpu.csv
如果你能告诉我:
我可以给你更精确的命令。