Linux offers a variety of commands that supply information about disk and system activities as well as system and resource statistics. One of the most beneficial commands is dstat. It delivers a broad range of detailed statistics on system activities.
If dstat is not yet installed on your Linux system, you can use a command to install it provided you have root access:
For Redhat and similar distributions, use:
For Ubuntu, Debian, and related distributions, use:
Disk activity includes not just how full your disks are, but how busy they are as they are being read and written to by various commands that are being run. If you want to see just the disk read and write stats, use the -d option. Your output should look something like this:
Notice that the output includes one column for disk reads and another for disk writes.
Were you to use the dstat command with no options, the output would include a lot more details than you might expect and would look more like what you see below.
Notice that this output includes stats usage, disk read and write, network activity, paging and system stats. The output from using dstat without options is the same as using dstat with the “cdngy” options (dstat -cdngy).
To get eight lines of this information in 2-second intervals, add the numeric arguments as shown in this command:
Note that the dstat command doesn’t always come with a man page. However, you can get a list of the command’s options and what each option represents using the dstat –help command.
The cdngy arguments (as you can tell from the output above) represent cpu, disk, network, paging and system stats. To display used and free memory with dstat, use a command like this:
To display top CPU usages, you could use a command like this:
With the dstat -c (CPU) option, dstat displays CPU stats. In the example below, we’re asking for two-second intervals and six reports.
One key to becoming adept at evaluating system performance is to run commands like these periodically — even when you don’t see the need to question how well a system is running. If you come to know what normal performance looks like for a server, you will have a much easier time spotting problems.
The commands included in this post display some of the most useful dstat command options, but check the options list for others that will help you see the details that you most need to see. The dstat command provides a vast range of options for viewing system and resource stats.