我想检查Linux服务器中的空闲和保留CPU。我找到了这个命令mpstat
,下面是输出:
CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
all 7.13 0.00 2.46 1.73 0.00 0.08 0.00 0.00 0.00 88.59
如果 %idle 是例如 1.0%,这意味着我正在使用 99.00% 的可用 CPU?有更好的方法来查找此信息吗?
答案1
如果可能,请安装该htop
工具。我喜欢它并且已经使用了很多次。它很像top
,但更好、更漂亮,有更多选择。要获得CPU average
执行以下步骤:
- 执行
htop
- 按
f2
进入设置 - 按
3 x right arrow key
- 按
36 x down arrow key
至CPU average
- 按下
2 x Enter
或选择使用箭头键将其移动到您想要的位置 - 您可以根据
Spacebar
需要多次按 来更改显示格式
我建议您探索该htop
命令,它有很多选项:)
你可以通过运行以下命令获取mpstat output explanation
:
man mpstat
您将得到以下输出:
CPU Processor number. The keyword all indicates that statistics are calculated as averages among all processors.
%usr Show the percentage of CPU utilization that occurred while executing at the user level (application).
%nice Show the percentage of CPU utilization that occurred while executing at the user level with nice priority.
%sys Show the percentage of CPU utilization that occurred while executing at the system level (kernel). Note that this does not include time spent servicing hard‐ ware and software interrupts.
%iowait Show the percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.
%irq Show the percentage of time spent by the CPU or CPUs to service hardware interrupts.
%soft Show the percentage of time spent by the CPU or CPUs to service software interrupts.
%steal Show the percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another virtual processor.
%guest Show the percentage of time spent by the CPU or CPUs to run a virtual processor.
%gnice Show the percentage of time spent by the CPU or CPUs to run a niced guest.
%idle Show the percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.
答案2
我从未遇到过与 Linux 相关的术语“保留 CPU”。当然,对于某些虚拟机管理程序,利用率百分比数字的含义可能与裸机机器有不同的解释。我假设“保留”是指它正在做某事。
如果 %idle 是例如 1.0%,这意味着我正在使用 99.00% 的可用 CPU?
简短回答:是的
更长的答案:不一定。报告为 iowait 的某些时间可由 CPU 用于其他用途。
有更好的方法来查找此信息吗?
定义“更好”