Skip to content

Latest commit

 

History

History
67 lines (51 loc) · 1.87 KB

cpu-load.md

File metadata and controls

67 lines (51 loc) · 1.87 KB

CPU Metrics

CPU Load

Recall: Linux Process State

From man 1 ps:

D    uninterruptible sleep (usually IO)
R    running or runnable (on run queue)
S    interruptible sleep (waiting for an event to complete)
T    stopped, either by a job control signal or because it is being traced
Z    defunct ("zombie") process, terminated but not reaped by its parent

Task CL1: CPU Load

Open 3 terminals (ssh connections).

  1. What is the Load Average metric? Use the Linux Process States and man 5 proc (search for loadavg)
(term 1) root:~# man 5 proc
(term 1) root:~# cat /proc/loadavg
46.26 12.59 4.39 1/106 7023
  1. Start the disk stress script (NOTE: Do not run this on your own laptop !!!):
(term 1) root:~# bash linux-metrics/scripts/disk/writer.sh
  1. Run the following command and look at the Load values for about a minute until ldavg-1 stabilizes:
(term 2) root:~# sar -q 1 100
  • What is the writing speed of our script
  • What is the current Load Average? Why? Which processes contribute to this number?
(term 2) root:~# top
  • What are CPU %user, %sy, %IO-wait and %idle?
  1. While the previous script is running, start a single CPU stress:
(term 3) root:~# stress -c 1 -t 3600

Wait another minute, and answer the above questions above.

  1. Stop all scripts

Discussion

  • Why are processes waiting for IO included in the Load Average?
  • Assuming we have 1 CPU core and Load of 5, is our CPU core on 100% utilization?
  • How can we know if load is going up or down?
  • Does a load average of 70 indicate a problem?

Tools

  • Most tools use /proc/loadavg to fetch Load Average and run queue information.
  • To get a percentage over a specific interval of time, you can use:
    • sar -q <interval> <count>
      • -q queue length and load averages
    • or simply uptime