The Artificial Load Spike

Since I missed posting over the weekend I thought I'd share a little Linux one-liner that I found amusing. For those that don't know "load" in the Unix world often refers to the system load averages for one, five, or fifteen minutes. The system load average is the average number of processes in the "ready" state over the period in question. Processes in the "ready" state are normally waiting for a chance to use the CPU, but it also includes processes waiting for I/O, which the following one-liner takes advantage of to cause an artificial load spike:

for i in $(seq 1 10000) ; do (/usr/sbin/smartctl -A /dev/hda &) ; done

From the man page smartctl is a "Control and Monitor Utility for SMART Disks". The "-A" option tells it to print the vendor specific SMART attribute. It's best to run this on an optical drive rather than your main hard disk because if you run it on the hard disk your disk will end up getting thrashed for the next 45 minutes, making your system noticeably unresponsive. If you run it on an optical drive instead though it only takes a few minutes (on my relatively recent system; you may need to decrease the number of iterations), during which time the system still remains responsive, but your load average gets huge. I got it up to 870 load average over one minute. This means that by the traditional equation (utilization in percent = load average / number of cores * 100) my dual core system was running at about 43,500% utilization. So now I can say that Linux is still responsive at over forty thousand percent system load. ;-)

Date: 2009-04-27 23:03:54, 8 years and 302 days ago

Leave reply

No html allowed in reply

Notify me of follow-up comments via email.