CPU Usage Analyses: mpstat and procinfo

Definition of mpstat
mpstat is used to gather statistics and/or diagnose issues with CPU usage.

mpstat shows activities of each processor.

Performance Diagnosis
Technical articles
Definition of procinfo
procinfo provides system-wide information but provides information IRQ (interupt requests).  Some of the information provided by procinfo is similar to vmstat, but it also provides information on the number of interrupts that the CPU received for each device.

procinfo gathers this system data from the /proc directory and prints it nicely formatted on the standard output device.

How to run the mpstat command

mpstat [-P { cpu | ALL }  ] [ delay  [ count ] ]
-P { cpu | ALL }: This tells mpstat which CPU to monitor
delay: how long to wait between each sample
count: number of times to run

Output
mpstat output:
  • %usr: Shows the percentage of CPU utilization that occurred while executing at the user level (application).
  • %nice: Shows the percentage of CPU utilization that occurred while executing at the user level with nice priority.
  • %sys: Shows the percentage of CPU utilization that occurred while executing at the system level (kernel). Note that this does not include time spent servicing hardware and software interrupts.
  • %iowait: Shows the percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.
  • %irq: Shows the percentage of time spent by the CPU or CPUs to service hardware interrupts.
  • %soft: Shows the percentage of time spent by the CPU or CPUs to service software interrupts.
  • %steal: Shows the percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another virtual processor.
  • %guest: Shows the percentage of time spent by the CPU or CPUs to run a virtual processor.
  • %idle: Shows the percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.

How to run the procinfo command

procinfo [-f] [-d] [-D] [-n sec] [-F file]
 
Command-Line Options
  • -f: runs procinfo in full-screen mode
  • -d: displays statistics change between samples rather than totals
  • -D: displays statistics totals rather than rate of change
  • -n sec: number of seconds to pause between each sample
  • -F file: send output to a file

The meanings of the fields are as follows:
  • Load average:  The average number of jobs running, followed by the number of runnable processes and the total number of processes, followed by the PID of the last process run.
  • user: The amount of time spent running jobs in user space.
  • nice: The amount of time spent running niced jobs in user space.
  • system: The amount of time spent running in kernel space.
  • idle: The amount of time spent doing nothing.
  • steal: The amount of time spent the virtual CPU waiting for physical CPU.
  • uptime: The time that the system has been up. The above four should more or less add up to this one.
  • Interrupts: two rows of numbers for each IRQ channel (if your kernel is at version 1.0.5 or earlier, this is either a single number for all IRQ channels together).
Performance Diagnosis
Technical articles