要在远程计算机上使用 cpustat 监控 CPU 使用情况,您可以通过 SSH(安全外壳协议)连接到远程计算机,并在远程命令行上运行 cpustat。以下是基本步骤:
安装 sysstat 包:
sysstat 包,它包含了 cpustat 工具:sudo apt update
sudo apt install sysstat
设置 SSH 访问:
~/.ssh/authorized_keys 文件中。ssh-keygen
ssh-copy-id username@remote_host
通过 SSH 运行 cpustat:
cpustat:ssh username@remote_host cpustat
cpustat 的参数来定制输出,例如每秒更新一次,持续监控 10 秒:ssh username@remote_host "cpustat -i ALL 1 10"
后台运行 cpustat:
cpustat 在后台运行并记录输出到文件,可以使用以下命令:ssh username@remote_host "cpustat -i ALL 1 10 > cpu_usage.log 2>&1 &"
cpustat 并将输出重定向到 cpu_usage.log 文件。通过这些步骤,您可以在远程计算机上使用 cpustat 监控 CPU 使用情况,并将输出记录到本地或远程文件中。