使用sar -u查看cpu使用率情况

本文介绍如何使用sar命令查看Linux系统的CPU利用率,并解释了各项指标的含义,如%user、%system、%iowait等,帮助读者理解系统性能瓶颈。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[root@abc ~]# man sar

      -u [ ALL ]
              Report CPU utilization. The ALL keyword indicates that all the CPU fields should be displayed.  The report may show the following fields:

              %user
                     Percentage of CPU utilization that occurred while executing at the user level (application). Note that this field includes time spent running virtual processors.

              %usr
                     Percentage of CPU utilization that occurred while executing at the user level (application). Note that this field does NOT include time spent running  virtual  proces-
                     sors.

              %nice
                     Percentage of CPU utilization that occurred while executing at the user level with nice priority.

              %system
                     Percentage  of  CPU  utilization  that  occurred while executing at the system level (kernel). Note that this field includes time spent servicing hardware and software interrupts.

              %sys
                     Percentage of CPU utilization that occurred while executing at the system level (kernel). Note that this field does NOT include time spent servicing hardware or  soft-ware interrupts.

              %iowait
                     Percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.

              %steal
                     Percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another virtual processor.

              %irq
                     Percentage of time spent by the CPU or CPUs to service hardware interrupts.

              %soft
                     Percentage of time spent by the CPU or CPUs to service software interrupts.

              %guest
                     Percentage of time spent by the CPU or CPUs to run a virtual processor.

              %idle
                     Percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.

              Note: On SMP machines a processor that does not have any activity at all (0.00 for every field) is a disabled (offline) processor.

[root@abc ~]# sar -u ALL 1 10
Linux 2.6.32-642.el6.x86_64 (abc) 	06/06/2018 	_x86_64_	(4 CPU)


01:56:08 PM     CPU      %usr     %nice      %sys    %iowait   %steal      %irq     %soft    %guest     %idle
01:56:09 PM     all      0.00      0.00      0.25      0.00      0.00      0.00      0.00      0.00     99.75
01:56:10 PM     all      0.25      0.00      0.25      0.00      0.00      0.00      0.00      0.00     99.50
01:56:11 PM     all      0.00      0.00      0.25      0.00      0.00      0.00      0.00      0.00     99.75
01:56:12 PM     all      0.00      0.00      0.25      0.00      0.00      0.00      0.00      0.00     99.75
01:56:13 PM     all      0.25      0.00      0.50      0.00      0.00      0.00      0.00      0.00     99.25
01:56:14 PM     all      0.00      0.00      0.25      0.00      0.00      0.00      0.00      0.00     99.75
01:56:15 PM     all      0.00      0.00      0.25      0.25      0.00      0.00      0.00      0.00     99.50
01:56:16 PM     all      0.00      0.00      0.25      0.00      0.00      0.00      0.00      0.00     99.75
01:56:17 PM     all      0.00      0.00      0.50      0.00      0.00      0.00      0.00      0.00     99.50
01:56:18 PM     all      0.00      0.00      0.25      0.00      0.00      0.00      0.00      0.00     99.75
Average:        all      0.05      0.00      0.30      0.03      0.00      0.00      0.00      0.00     99.62
[root@abc ~]# 
Spending time in %user is expected behavior, as this is where all non-system tasks are accounted for. 
If cycles are actively being spent in %system then much of the execution time is being spent in lower-level code. 
If %iowait is high then it indicates processes are actively waiting due to disk accesses being a bottleneck on the system.

注意上面的 %iowait列

来源于:https://access.redhat.com/articles/325783

How to analyze and interpret sar data.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值