Invoking dstat with no arguments will show CPU activity, disk I/O, network I/O, paging, interrupts, and context switches at one second intervals.
The following example shows the default dstat output:
$ dstat ----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system-- usr sys idl wai hiq siq| read writ| recv send| in out | int csw 1 2 97 0 0 0|5457B 55k| 0 0 | 0 0 |1702 3177 1 2 97 0 0 0| 0 0 | 15k 2580B| 0 0 |2166 4830 1 2 96 0 0 0| 0 36k|1970B 1015B| 0 0 |2122 4794
You can ignore the first line. Those values are the initial contents of the tables dstat mines. The subsequent lines show the activity during a time slice.
In this sample, the CPU is mostly idle, and there is little disk activity. The system is generating network traffic, but only a few packets a second.
There is no paging on this system. Linux only pages out memory to disk when the main memory is exhausted. Paging lets a system run more applications than it could run without paging, but disk access is thousands of times slower than memory access, so a computer will slow to a crawl if it needs to page.
If your system sees consistent paging activity, it needs more RAM or fewer applications.
A database application can cause intermittent paging when queries that require building large in-memory arrays are evaluated. It may be possible to rewrite these queries using the IN operation instead of a JOIN to reduce the memory requirement. (This is a more advanced SQL than what is covered in this book.)
Context switches (csw) happen with every system call (refer to the strace and ltrace discussion in Chapter 11, Tracing the Clues) and when a timeslice expires and another application is given access to the CPU. A system call happens whenever I/O is performed or a program resizes itself.
If the system is performing tens of thousands of context switches per second, it's a symptom of a potential problem.