As a CPU monitor, vmstat is superior to iostat in that its one-line-per-report output is easier to scan as it scrolls. vmstat also gives you general information about memory use, paging, and ordinary disk I/O at a glance. The following example can help you identify situations in which a program has run away or is too CPU intensive to run in a multiuser environment.
$ vmstat 2 procs memory page faults cpu ----- ----------- ------------------------ ------------ ----------- r b avm fre re pi po fr sr cy in sy cs us sy id wa 1 0 22478 1677 0 0 0 0 0 0 188 1380 157 57 32 0 10 1 0 22506 1609 0 0 0 0 0 0 214 1476 186 48 37 0 16 0 0 22498 1582 0 0 0 0 0 0 248 1470 226 55 36 0 9 2 0 22534 1465 0 0 0 0 0 0 238 903 239 77 23 0 0 2 0 22534 1445 0 0 0 0 0 0 209 1142 205 72 28 0 0 2 0 22534 1426 0 0 0 0 0 0 189 1220 212 74 26 0 0 3 0 22534 1410 0 0 0 0 0 0 255 1704 268 70 30 0 0 2 1 22557 1365 0 0 0 0 0 0 383 977 216 72 28 0 0 2 0 22541 1356 0 0 0 0 0 0 237 1418 209 63 33 0 4 1 0 22524 1350 0 0 0 0 0 0 241 1348 179 52 32 0 16 1 0 22546 1293 0 0 0 0 0 0 217 1473 180 51 35 0 14
This output shows the effect of introducing a program in a tight loop to a busy multiuser system. The first three reports (the summary has been removed) show the system balanced at 50-55% user, 30-35% system, and 10-15% I/O wait. When the looping program begins, all available CPU cycles are consumed. Since the looping program does no I/O, it can absorb all of the cycles previously unused because of I/O wait. Worse, it represents a process that is always ready to take over the CPU when a useful process relinquishes it. Since the looping program has a priority equal to that of all other foreground processes, it will not necessarily have to give up the CPU when another process becomes dispatchable. The program runs for about 10 seconds (five reports), and then the activity reported by vmstat returns to a more normal pattern.