mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-25 00:50:15 +08:00
Merge pull request #587 from KayGuoWhu/master
翻译完成 Linux mpstat Command – Reports Processors Related Statistics
This commit is contained in:
commit
d2828579c3
@ -1,113 +0,0 @@
|
|||||||
[翻译中] by KayGuoWhu
|
|
||||||
Linux mpstat Command – Reports Processors Related Statistics
|
|
||||||
================================================================================
|
|
||||||
Generally today computer is using multiple processors. Or maybe 1 physical processor with 4 cores inside. On server side, more processors or cores means more power. But the other side, application also more power consumption. You may find a situation when your cpu utilization is high but you feel that you don’t running anything. On Linux system, you can monitor this activity using **mpstat**.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### What is mpstat ###
|
|
||||||
|
|
||||||
**mpstat** is used to monitor cpu utilization on your system. It will be more usefull if your system has multiple processors. The first processors will signed as CPU 0. The second one will be signed CPU 1 and so on. From its manual page, mpstat is described as :
|
|
||||||
|
|
||||||
> The mpstat command writes to standard output activities for each available processor, processor 0 being the first one. Global average activities among all processors are also reported. The mpstat command can be used both on SMP and UP machines, but in the latter, only global average activities will be printed. If no activity has been selected, then the default report is the CPU utilization report
|
|
||||||
|
|
||||||
### How to run mpstat ###
|
|
||||||
|
|
||||||
Just type **mpstat** on your console to run mpstat.
|
|
||||||
|
|
||||||
$ mpstat
|
|
||||||
|
|
||||||
Linux 3.2.0-57-generic (USERNB01) 12/12/2013 _x86_64_ (2 CPU)
|
|
||||||
|
|
||||||
03:29:29 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
|
|
||||||
03:29:29 PM all 6.30 0.06 1.94 3.75 0.00 0.06 0.00 0.00 87.88
|
|
||||||
|
|
||||||
If you found an error such as : **command not found** or similar you may not install mpstat in your system.
|
|
||||||
|
|
||||||
If you are using **CentOS, RedHat or Fedora**, run this command to install mpstat
|
|
||||||
|
|
||||||
# yum install sysstat
|
|
||||||
|
|
||||||
If you are using **Debian, Ubuntu or its derivative**, run this command to install mpstat
|
|
||||||
|
|
||||||
# apt-get install sysstat
|
|
||||||
|
|
||||||
And here’s how to read the information above.
|
|
||||||
|
|
||||||
- **03:29:29 PM** : means the time that mpstat was run
|
|
||||||
- **all** : means All CPUs
|
|
||||||
- **%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)
|
|
||||||
- **%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
|
|
||||||
- **%idle** : show the percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O equest
|
|
||||||
|
|
||||||
### Print CPU utilization per processors ###
|
|
||||||
|
|
||||||
As you can see above, our system has 2 CPUs. If you want, you can use -P parameter followed by CPU number to see specific CPU utilization.
|
|
||||||
|
|
||||||
$ mpstat -P 0
|
|
||||||
|
|
||||||
Linux 3.2.0-57-generic (USERNB01) 12/12/2013 _x86_64_ (2 CPU)
|
|
||||||
|
|
||||||
03:54:00 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
|
|
||||||
03:54:00 PM 0 3.82 0.01 1.16 3.88 0.00 0.06 0.00 0.00 91.06
|
|
||||||
|
|
||||||
$ mpstat -P 1
|
|
||||||
Linux 3.2.0-57-generic (USERNB01) 12/12/2013 _x86_64_ (2 CPU)
|
|
||||||
|
|
||||||
03:53:58 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
|
|
||||||
03:53:58 PM 1 16.52 0.20 4.48 0.46 0.00 0.04 0.00 0.00 78.30
|
|
||||||
|
|
||||||
### Print all CPU Utilization ###
|
|
||||||
|
|
||||||
You can also print every CPU utilization of processors in a single page. Just use **-P ALL** parameter to do it
|
|
||||||
|
|
||||||
$ mpstat -P ALL
|
|
||||||
|
|
||||||
Linux 3.2.0-57-generic (USERNB01) 12/12/2013 _x86_64_ (2 CPU)
|
|
||||||
|
|
||||||
04:07:36 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
|
|
||||||
04:07:36 PM all 6.02 0.04 1.72 2.99 0.00 0.05 0.00 0.00 89.17
|
|
||||||
04:07:36 PM 0 3.84 0.01 1.15 3.72 0.00 0.06 0.00 0.00 91.21
|
|
||||||
04:07:36 PM 1 13.55 0.15 3.66 0.46 0.00 0.03 0.00 0.00 82.15
|
|
||||||
|
|
||||||
### Print CPU utilization using intervals ###
|
|
||||||
|
|
||||||
You may want to see the CPU utilization movement. To do this, you can use intervals. Here’s an example.
|
|
||||||
|
|
||||||
$ mpstat 3 4
|
|
||||||
|
|
||||||
Linux 3.2.0-57-generic (USERNB01) 12/12/2013 _x86_64_ (2 CPU)
|
|
||||||
|
|
||||||
04:27:11 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
|
|
||||||
04:27:14 PM all 0.67 0.00 0.34 0.00 0.00 0.00 0.00 0.00 98.99
|
|
||||||
04:27:17 PM all 1.17 0.00 0.33 1.33 0.00 0.00 0.00 0.00 97.17
|
|
||||||
04:27:20 PM all 0.84 0.00 0.17 0.00 0.00 0.00 0.00 0.00 98.99
|
|
||||||
04:27:23 PM all 1.00 0.00 0.17 1.51 0.00 0.00 0.00 0.00 97.32
|
|
||||||
Average: all 0.92 0.00 0.25 0.71 0.00 0.00 0.00 0.00 98.12
|
|
||||||
|
|
||||||
The above command is to show you **4 reports** about CPU utilization with **3 seconds intervals**
|
|
||||||
|
|
||||||
### Print mpstat version ###
|
|
||||||
|
|
||||||
Finally, to print mstat version, use -V parameter
|
|
||||||
|
|
||||||
$ mpstat -V
|
|
||||||
|
|
||||||
sysstat version 10.0.3
|
|
||||||
(C) Sebastien Godard (sysstat orange.
|
|
||||||
|
|
||||||
That’s a quick usage of mpstat command in Linux system. You may see msptat manual page by typing **man mpstat** to explore more detail.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: http://linoxide.com/linux-command/linux-mpstat-command/
|
|
||||||
|
|
||||||
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
|
@ -0,0 +1,111 @@
|
|||||||
|
Linux mpstat 命令- 报告处理器的相关统计信息
|
||||||
|
================================================================================
|
||||||
|
现在的计算机一般都使用着多处理器,或者可能是一个内部拥有四个核心的物理处理器。在服务器端,更多的处理器或核心意味着更大的能耗。但在另一方面应用程序也需要更多的能耗。你可能会想到这样一个场景:当你的cpu利用率很高时你却感觉自己根本没有运行任何程序。在Linux系统上,你可以使用 **mpstate** 来监控这样的活动。
|
||||||
|

|
||||||
|
|
||||||
|
### 什么是mpstat ###
|
||||||
|
|
||||||
|
**mpstat** 用于监控你的系统上cpu的利用率。如果你的系统有多个处理器,它会发挥更大的作用。
|
||||||
|
第一个处理器会被标记为CPU 0。第二个会被标记为CPU 2,以此类推。在操作手册中,如下描述mpstat:
|
||||||
|
|
||||||
|
> mpstat命令把每个可用的处理器的状态写到标准输出,处理器0是第一个。所有处理器的全局平均状态也会被报告。mpstat命令可以用于SMP和UP的机器上,但是在UP机器上,只有全局平均状态会被打印出来。如果没有活动被选择,默认报告CPU的利用率
|
||||||
|
|
||||||
|
### 如何运行mpstat ###
|
||||||
|
|
||||||
|
只需在你的终端输入 **mpstat** 就可以运行mpstat.
|
||||||
|
|
||||||
|
$ mpstat
|
||||||
|
|
||||||
|
Linux 3.2.0-57-generic (USERNB01) 12/12/2013 _x86_64_ (2 CPU)
|
||||||
|
|
||||||
|
03:29:29 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
|
||||||
|
03:29:29 PM all 6.30 0.06 1.94 3.75 0.00 0.06 0.00 0.00 87.88
|
||||||
|
|
||||||
|
如果你发现譬如 **命令找不到**或者类似于你没有安装mpstate的错误。
|
||||||
|
|
||||||
|
如果你使用的是 **CentOS, RedHat or Fedora**,运行下列命令来安装mpstat
|
||||||
|
|
||||||
|
# yum install sysstat
|
||||||
|
|
||||||
|
如果你使用的是 **Debian, Ubuntu or 它的衍生版**, 运行下列命令来安装mpstat
|
||||||
|
|
||||||
|
# apt-get install sysstat
|
||||||
|
|
||||||
|
这里是如何理解上面显示出来的信息。
|
||||||
|
|
||||||
|
- **03:29:29 PM** : 指mpstat运行的时间
|
||||||
|
- **all** : 指所有CPU
|
||||||
|
- **%usr** : 显示在用户级别执行(应用程序)时CPU利用率的百分比
|
||||||
|
- **%nice** :显示在拥有nice优先级的用户级别执行时CPU利用率的百分比
|
||||||
|
- **%sys** : 现实在系统级别执行(内核)时CPU利用率的百分比
|
||||||
|
- **%iowait** : 显示在系统有未完成的磁盘I/O请求期间CPU空闲时间的百分比
|
||||||
|
- **%irq** : 显示CPU服务硬件中断所花费时间的百分比
|
||||||
|
- **%soft** : 显示CPU服务软件中断所花费时间的百分比
|
||||||
|
- **%steal** : 显示虚拟机管理器在服务另一个虚拟处理器时虚拟CPU处在非自愿等待下花费时间的百分比
|
||||||
|
- **%guest** : 显示运行虚拟处理器时CPU花费时间的百分比
|
||||||
|
- **%idle** : 显示CPU空闲和系统没有未完成的磁盘I/O请求情况下的时间百分比
|
||||||
|
|
||||||
|
### 打印每个处理器的CPU利用率 ###
|
||||||
|
|
||||||
|
正如上面所说,我们的系统有两个CPU。如果你想要,你可以使用参数 -P 然后紧跟CPU编号得到指定CPU的利用率。
|
||||||
|
|
||||||
|
$ mpstat -P 0
|
||||||
|
|
||||||
|
Linux 3.2.0-57-generic (USERNB01) 12/12/2013 _x86_64_ (2 CPU)
|
||||||
|
|
||||||
|
03:54:00 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
|
||||||
|
03:54:00 PM 0 3.82 0.01 1.16 3.88 0.00 0.06 0.00 0.00 91.06
|
||||||
|
|
||||||
|
$ mpstat -P 1
|
||||||
|
Linux 3.2.0-57-generic (USERNB01) 12/12/2013 _x86_64_ (2 CPU)
|
||||||
|
|
||||||
|
03:53:58 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
|
||||||
|
03:53:58 PM 1 16.52 0.20 4.48 0.46 0.00 0.04 0.00 0.00 78.30
|
||||||
|
|
||||||
|
### 打印所有CPU的利用率 ###
|
||||||
|
|
||||||
|
你也可以在一页里打印每个处理器的CPU利用率,只需使用 **-P ALL** 参数来指定。
|
||||||
|
|
||||||
|
$ mpstat -P ALL
|
||||||
|
|
||||||
|
Linux 3.2.0-57-generic (USERNB01) 12/12/2013 _x86_64_ (2 CPU)
|
||||||
|
|
||||||
|
04:07:36 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
|
||||||
|
04:07:36 PM all 6.02 0.04 1.72 2.99 0.00 0.05 0.00 0.00 89.17
|
||||||
|
04:07:36 PM 0 3.84 0.01 1.15 3.72 0.00 0.06 0.00 0.00 91.21
|
||||||
|
04:07:36 PM 1 13.55 0.15 3.66 0.46 0.00 0.03 0.00 0.00 82.15
|
||||||
|
|
||||||
|
### 使用间隔打印CPU利用率 ###
|
||||||
|
|
||||||
|
如果你想观察CPU的利用率变化,你可以使用间隔,这里是一个例子。
|
||||||
|
|
||||||
|
$ mpstat 3 4
|
||||||
|
|
||||||
|
Linux 3.2.0-57-generic (USERNB01) 12/12/2013 _x86_64_ (2 CPU)
|
||||||
|
|
||||||
|
04:27:11 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
|
||||||
|
04:27:14 PM all 0.67 0.00 0.34 0.00 0.00 0.00 0.00 0.00 98.99
|
||||||
|
04:27:17 PM all 1.17 0.00 0.33 1.33 0.00 0.00 0.00 0.00 97.17
|
||||||
|
04:27:20 PM all 0.84 0.00 0.17 0.00 0.00 0.00 0.00 0.00 98.99
|
||||||
|
04:27:23 PM all 1.00 0.00 0.17 1.51 0.00 0.00 0.00 0.00 97.32
|
||||||
|
Average: all 0.92 0.00 0.25 0.71 0.00 0.00 0.00 0.00 98.12
|
||||||
|
|
||||||
|
上面的命令会**每隔3秒**显示CPU利用的**4个报告**。
|
||||||
|
|
||||||
|
### 打印mpstat的版本 ###
|
||||||
|
|
||||||
|
最后,为了打印mpstat的版本,使用参数 -V
|
||||||
|
|
||||||
|
$ mpstat -V
|
||||||
|
|
||||||
|
sysstat version 10.0.3
|
||||||
|
(C) Sebastien Godard (sysstat orange.
|
||||||
|
|
||||||
|
这就是在linux系统上快速使用mpstat的方法。想要了解更多细节,可以输入 **man mpstat**来查看mpstat的手册。
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: http://linoxide.com/linux-command/linux-mpstat-command/
|
||||||
|
|
||||||
|
译者:[KayGuoWhu](https://github.com/KayGuoWhu) 校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user