Linux CPU usage from SAR -u

How to calculate total Linux CPU usage from SAR -u report?

  • Post author:
  • Post category:Linux
  • Post last modified:September 1, 2024
  • Reading time:9 mins read

The sar -u command in Linux gives detailed information on Linux CPU usage. Here’s a breakdown of the representation of each column in the output.

%user: user-level CPU.

When a program is running at the user level, the CPU utilization percentage is being measured. During this period, user processes and programs are executed.

%nice: priority level.

The CPU usage percentage happened while the application was running at the user level and had good priority. Processes manage their priorities by using pleasant values.

%system: system level.

The percentage of CPU utilization that occurred while executing at the system level (kernel level).

This includes time spent on executing system calls and handling interrupts.

%iowait: wait time.

The CPU or CPUs were idle for a certain percentage of time while the system had an outstanding disk I/O request. High iowait values might suggest that the system frequently waits on disk operations..

%steal: steal time.

The virtual CPU or CPUs spent a percentage of time waiting involuntarily while the hypervisor was servicing another virtual processor in virtualized environments where resources are shared among multiple virtual machines.

%idle: System idle process.

The CPU or CPUs were idle and the system did not have an outstanding disk I/O request for a certain percentage of time. High idle values indicate that the CPU has been underutilizing

$ sar -u 1 3
Linux 5.4.0-72-generic (hostname) 08/05/2024 _x86_64_ (4 CPU)

12:00:01 AM CPU %user %nice %system %iowait %steal %idle
12:00:02 AM all 3.00 0.00 1.00 0.50 0.00 95.50
12:00:03 AM all 4.00 0.00 2.00 0.00 0.00 94.00
12:00:04 AM all 2.00 0.00 1.50 0.00 0.00 96.50
Average: all 3.00 0.00 1.50 0.17 0.00 95.33

Explanation:

Timestamp (12:00:01 AM):

The time at which the data was collected.

CPU (all):

  • The CPU field indicates that the data is aggregated across all CPUs.
  • If you have multiple CPUs, sar can report individual CPU stats.

%user (3.00): user-level CPU.

  • At this time, 3% of the CPU’s time was spent executing user-level processes.
  • The percentage of CPU utilization that occurred while being executed at the user level (application).

%nice (0.00): priority level.

  • No time was spent on processes with altered priority levels.
  • The percentage of CPU utilization that occurred while executing at the user level with nice priority was measured.

%system (1.00): system level.

  • 1% of the CPU’s time was spent executing system-level processes.
  • The percentage of CPU utilization that occurs while executing at the system level (kernel) is measured.

%iowait (0.50): wait time.

  • 0.5% of the CPU’s time was spent waiting for I/O operations to complete.
  • The percentage of time during which the system had an outstanding disk I/O request while the CPU or CPUs were idle.

%steal (0.00): steal time.

  • No time was stolen by the hypervisor.
  • The percentage of time the CPU was idle while waiting for hypervisor operations

%idle (95.50): System idle process.

  • 95.5% of the CPU’s time was idle, indicating low CPU usage at that moment.
  • The percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request was observed.

Average:

  • The average values of all the collected data points during the period of the sar run.

see also

ubuntu.com

techlinux.in

I’m a DevOps engineer with 8 years of experience in automation and cloud infrastructure. I’m passionate about optimizing software delivery and love sharing practical DevOps tips.Outside of work, I enjoy hiking, cooking, and contributing to open-source projects.Thanks for visiting my blog