Closed Captioning Closed captioning available on our YouTube channel
video

Linux tip: How to use the dstat command

In today’s Linux tip, we’re going to look at the dstat command that provides important information on system resources — notably CPU usage, disk activity, network traffic, paging and system internals (interrupts and context switches).

Similar
Comments
Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In today’s Linux tip, we’re going to look at the dstat command that provides important information on system resources – notably CPU usage, disk activity, network traffic, paging and system internals (interrupts and context switches).
In this first command, we’re going to display the information that dstat provides by default, but we’re asking only to see only three 2-second intervals. If you just type “dstat”, the command will continue until you stop it with a ^c.
$ dstat 2 3
You did not select any stats, using -cdngy by default.
--total-cpu-usage-- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai stl| read writ| recv send| in out | int csw
0 0 100 0 0|6565B 9658B| 0 0 | 0 0 | 43 60
20 30 50 0 0| 0 0 | 205B 809B| 0 0 | 420 269
21 30 49 0 0| 0 0 | 270B 346B| 0 0 | 430 329
So, what does this show us? The first line of output shows a summary of activity since the system booted. The next two lines are showing current activity.
The first section shows us CPU activity. The system has been idle a lot of the time and is now spending some time running system and user tasks.
The next section is disk reads and writes – nothing now. We also see network activity (sending and receiving packets). No paging (stores and retrieves data from secondary storage) is going on. And on the right we see system interrupts and context switches.
This system is obviously not very busy.
If your system has more than one CPU, you can view the activity on each CPU separately and the combination of the two CPUs with a command like this:
$ dstat -C 0,1,total
You did not select any stats, using -cdngy by default.
Terminal width too small, trimming output.
-----cpu0-usage----------cpu1-usage-------total-cpu-usage-- -dsk/total->
usr sys idl wai stl:usr sys idl wai stl:usr sys idl wai stl| read writ>
0 0 100 0 0: 0 0 100 0 0: 0 0 100 0 0|6547B 9640B>
1 1 98 0 0: 38 62 0 0 0: 20 31 49 0 0| 0 0 >
0 0 100 0 0: 38 62 0 0 0: 19 32 50 0 0| 0 0 >
As you can see, we’ve got CPU0, CPU1 and the totals showing. The > at the end of each line indicates that the command output is being truncated. Stretch your terminal window to make it wider and you will see the other fields as well.
Closing: That’s your 2-minute Linux tip for today. If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and NetworkWorld.com.