CPU Usage Analyses: sar

Definition of sar
The System Activity Report (sar) reports data that has already been gathered by two commands, sa1 and sa2, which are part of /etc/cron.d/systat. They are run as cron jobs. The output from these jobs are stored in /var/log/sa. The following setting in /etc/sysconfig/sysstat indicates that output should be saved for 28 days:
HISTORY=28

If the cron jobs are not running, sar will not have any historical data to report.


Performance Diagnosis
Technical articles
Simple sar command
The sar command without arguments will show statistics related to CPU usage from the system in real time. The columns displayed are:
  • %user
  • %nice
  • %system
  • %iowait
  • %idle
See below for definitions.

This command samples CPU 3 times at 1second intervals.
sar 1 3

sar for CPU Analyses
The sar command structure is:
sar [options] [delay [count]]

The CPU-related options are:
  • -P { cpu  | ALL }   Report per-processor statistics for the specified processor or processors. Specifying the ALL keyword reports statistics for each individual processor, and globally for all processors. Note that processor 0 is the first processor.
  • -q: Report queue length and load averages.
  • -u: report CPU utilization
  • -w: Report task creation and system switching activity.

The CPU-related column headings are:
  • %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 processors.
  • %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 software 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.
  • runq-sz: Run queue length (number of tasks waiting for run time).
  • plist-sz: Number of tasks in the task list.
  • ldavg-1:    System load average for the last minute. The load average is calculated as the average number of runnable or running tasks (R state), and the number of tasks in uninterruptible sleep (D state) over the specified interval.
  • ldavg-5:  System load average for the past 5 minutes.
  • ldavg-15: System load average for the past 15 minutes.
  • proc/s: Total number of tasks created per second. (use -w to see this)
  • cswch/s: Total number of context switches per second. (use -w to see this)


Suggestions for Future Learning
This information will be in the second edition of UNIX For Application Support Staff . The ETA for the second edition is December 1, 2016.



Performance Diagnosis
Technical articles