5+ “dstat” Command Usage Examples in Linux

«
»

This tutorial explains Linux “dstat” command, options and its usage with examples.

dstat – versatile tool for generating system resource statistics

Description :

advertisement

Dstat is a versatile replacement for vmstat, iostat and ifstat. Dstat overcomes some of the limitations and adds some extra features.

Dstat allows you to view all of your system resources instantly, you can eg. compare disk usage in combination with interrupts from your IDE controller, or compare the network bandwidth numbers directly with the disk throughput (in the same interval).

Dstat also cleverly gives you the most detailed information in columns and clearly indicates in what magnitude and unit the output is displayed. Less confusion, less mistakes, more efficient.

Dstat is unique in letting you aggregate block device throughput for a certain diskset or network bandwidth for a group of interfaces, ie. you can see the throughput for all the block devices that make up a single filesystem or storage system.

Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
advertisement

Dstat allows its data to be directly written to a CSV file to be imported and used by OpenOffice, Gnumeric or Excel to create graphs.

Usage :

dstat [-afv] [options..] [delay [count]]

Options :

-c, –cpu
enable cpu stats
-C 0,3,total
include cpu0, cpu3 and total
-d, –disk
enable disk stats
-D total,hda
include hda and total
-g, –page
enable page stats
-i, –int
enable interrupt stats
-I 5,eth2
include int5 and interrupt used by eth2
-l, –load
enable load stats
-m, –mem
enable memory stats
-n, –net
enable network stats
-N eth1,total
include eth1 and total
-p, –proc
enable process stats
-r, –io
enable io stats (I/O requests completed)
-s, –swap
enable swap stats
-S swap1,total
include swap1 and total
-t, –time
enable time/date output
-T, –epoch
enable time counter (seconds since epoch)
-y, –sys
enable system stats
-a, –all
equals -cdngy (default)
-f, –full
expand -C, -D, -I, -N and -S discovery lists
-v, –vmstat
equals -pmgdsc -D total

advertisement

Examples :

1. Give 5 updates with frequency of 1 second

$ dstat 1 5
You did not select any stats, using -cdngy by default.
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw 
  3   1  95   1   0   0|  70k   22k|   0     0 | 958B 4050B| 103   409 
  1   1  98   0   0   0|   0     0 |   0     0 |   0     0 |  45   207 
  2   0  98   0   0   0|   0     0 |   0     0 |   0     0 |  48   234 
  2   1  97   0   0   0|   0     0 |   0     0 |   0     0 |  56   238 
  2   0  98   0   0   0|   0     0 |   0     0 |   0     0 |  56   219 
  3   1  96   0   0   0|   0     0 |   0     0 |   0     0 |  61   260

2. Give 1 update with frequency of 5 seconds

$ dstat 5 1
You did not select any stats, using -cdngy by default.
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw 
  3   1  95   1   0   0|  70k   22k|   0     0 | 957B 4046B| 103   408 
  0   0 100   0   0   0|   0  2458B|   0     0 |   0     0 |  42   198

3. Give cpu, disk and network informations’ 10 updates at a frequency of 5 seconds

advertisement
$ dstat -cdn 5 10
----total-cpu-usage---- -dsk/total- -net/total-
usr sys idl wai hiq siq| read  writ| recv  send
  3   1  95   1   0   0|  70k   22k|   0     0 
  1   1  98   0   0   0|   0     0 |   0     0 
  1   1  98   0   0   0|   0  2458B|   0     0 
  1   1  98   0   0   0|   0  2458B|   0     0 
  1   1  98   0   0   0|   0     0 |   0     0 
  1   1  99   0   0   0|   0  2458B|   0     0 
  1   1  98   0   0   0|   0  4915B|   0     0 
  1   1  98   0   0   0|   0     0 |  92B   61B
  1   1  98   0   0   0|   0  2458B|  12B   12B
  1   1  99   0   0   0|   0  2458B| 119B   30B
  1   1  98   0   0   0|   0  2458B|  37B    0

4. To send the output to a csv file for later use we can issue the following command:

dstat --output /tmp/myoutput_stats.csv -cdn

Contents of csv file :

advertisement
$ cat myoutput_stats.csv 
"Dstat 0.7.2 CSV output"
"Author:","Dag Wieers <[email protected]>",,,,"URL:","http://dag.wieers.com/home-made/dstat/"
"Host:","ubuntu",,,,"User:","abc"
"Cmdline:","dstat --output /tmp/myoutput_stats.csv -cdn",,,,"Date:","06 Jul 2014 01:11:11 IST"
 
"total cpu usage",,,,,,"dsk/total",,"net/total",
"usr","sys","idl","wai","hiq","siq","read","writ","recv","send"
3.013,1.170,94.847,0.945,0.000,0.025,70983.248,22217.353,0.0,0.0
2.020,1.010,96.970,0.0,0.0,0.0,0.0,0.0,276.0,152.0
1.010,0.0,98.990,0.0,0.0,0.0,0.0,0.0,137.0,0.0
2.020,1.010,96.970,0.0,0.0,0.0,0.0,0.0,184.0,0.0
0.0,2.0,98.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
1.020,0.0,98.980,0.0,0.0,0.0,0.0,0.0,0.0,0.0
1.0,2.0,97.0,0.0,0.0,0.0,0.0,28672.0,0.0,0.0

5. Give 5 updates about cpu, disk, network and system at time intervals of 1 second along-with time

$ dstat -cdnyt 1 5
----total-cpu-usage---- -dsk/total- -net/total- ---system-- ----system----
usr sys idl wai hiq siq| read  writ| recv  send| int   csw |     time     
  3   1  95   1   0   0|  69k   22k|   0     0 | 103   405 |06-07 01:13:47
  2   1  97   0   0   0|   0     0 | 184B    0 |  43   187 |06-07 01:13:48
  2   1  97   0   0   0|   0     0 | 249B    0 |  60   262 |06-07 01:13:49
  2   0  98   0   0   0|   0     0 |   0     0 |  58   257 |06-07 01:13:50
  3   0  97   0   0   0|   0     0 |   0     0 |  57   213 |06-07 01:13:51
  2   1  97   0   0   0|   0     0 |   0     0 |  61   253 |06-07 01:13:52

6. Order of options matters as in the same order the statistics are shown

$ dstat -mrtyp 1 5
------memory-usage----- --io/total- ----system---- ---system-- ---procs---
 used  buff  cach  free| read  writ|     time     | int   csw |run blk new
 504M 14.2M  340M  130M|2.89  0.69 |06-07 01:17:34| 102   404 |  0   0 0.3
 504M 14.2M  340M  130M|   0     0 |06-07 01:17:35|  45   221 |  0   0   0
 504M 14.2M  340M  130M|   0     0 |06-07 01:17:36|  53   243 |  0   0   0
 504M 14.2M  340M  130M|   0     0 |06-07 01:17:37|  58   253 |  0   0   0
 504M 14.2M  340M  130M|   0  5.00 |06-07 01:17:38|  60   223 |  0   0   0
 504M 14.2M  340M  130M|   0     0 |06-07 01:17:39|  67   276 |1.0   0   0
$ dstat -typmr 1 5
----system---- ---system-- ---procs--- ------memory-usage----- --io/total-
     time     | int   csw |run blk new| used  buff  cach  free| read  writ
06-07 01:17:44| 102   404 |  0   0 0.3| 504M 14.2M  340M  130M|2.89  0.69 
06-07 01:17:45|  55   204 |  0   0   0| 504M 14.2M  340M  130M|   0     0 
06-07 01:17:46|  47   237 |  0   0   0| 504M 14.2M  340M  130M|   0     0 
06-07 01:17:47|  54   230 |  0   0   0| 504M 14.2M  340M  130M|   0     0 
06-07 01:17:48|  45   193 |  0   0   0| 504M 14.2M  340M  130M|   0     0 
06-07 01:17:49|  50   239 |  0   0   0| 504M 14.2M  340M  130M|   0     0

7. Usage of -a option

$ dstat -at 1 5
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system-- ----system----
usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw |     time     
  3   1  95   1   0   0|  68k   21k|   0     0 | 929B 3926B| 102   400 |06-07 01:30:33
  3   1  96   0   0   0|   0     0 |   0     0 |   0     0 | 134   290 |06-07 01:30:34
  8   0  92   0   0   0|   0     0 |   0     0 |   0     0 | 126   291 |06-07 01:30:35
  7   1  92   0   0   0|   0     0 |   0     0 |   0     0 | 246   442 |06-07 01:30:36
  5   2  93   0   0   0|   0     0 |   0     0 |   0     0 | 143   309 |06-07 01:30:37
  5   0  95   0   0   0|   0     0 |   0     0 |   0     0 | 127   303 |06-07 01:30:38

8. Usage of -v option

$ dstat -vt 1 5
---procs--- ------memory-usage----- ---paging-- -dsk/total- ---system-- ----total-cpu-usage---- ----system----
run blk new| used  buff  cach  free|  in   out | read  writ| int   csw |usr sys idl wai hiq siq|     time     
  0   0 0.3| 504M 14.4M  341M  129M| 929B 3923B|  68k   21k| 102   400 |  3   1  95   1   0   0|06-07 01:31:16
  0   0   0| 504M 14.4M  341M  129M|   0     0 |   0     0 |  55   232 |  2   1  97   0   0   0|06-07 01:31:17
  0   0   0| 504M 14.4M  341M  129M|   0     0 |   0     0 |  63   245 |  4   0  96   0   0   0|06-07 01:31:18
  0   0   0| 504M 14.4M  341M  129M|   0     0 |   0     0 |  62   245 |  4   0  96   0   0   0|06-07 01:31:19
1.0   0   0| 504M 14.4M  341M  129M|   0     0 |   0     0 |  57   212 |  3   1  96   0   0   0|06-07 01:31:20
  0   0   0| 504M 14.4M  341M  129M|   0     0 |   0     0 |  55   213 |  5   1  94   0   0   0|06-07 01:31:21

9. Usage of -f option

$ dstat -aft 1 5
-------cpu0-usage------ --dsk/fd0-----dsk/sda-- --net/eth0- ---paging-- ---system-- ----system----
usr sys idl wai hiq siq| read  writ: read  writ| recv  send|  in   out | int   csw |     time     
  3   1  95   1   0   0|   0     0 :  68k   21k|   0     0 | 928B 3920B| 102   400 |06-07 01:31:53
  1   1  98   0   0   0|   0     0 :   0     0 |   0     0 |   0     0 |  51   235 |06-07 01:31:54
  2   1  97   0   0   0|   0     0 :   0     0 |   0     0 |   0     0 |  78   291 |06-07 01:31:55
  3   1  96   0   0   0|   0     0 :   0     0 |   0     0 |   0     0 |  54   236 |06-07 01:31:56
  2   1  97   0   0   0|   0     0 :   0     0 |   0     0 |   0     0 |  53   204 |06-07 01:31:57
  4   0  96   0   0   0|   0     0 :   0    16k|   0     0 |   0     0 |  56   226 |06-07 01:31:58
$ dstat -at 1 5
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system-- ----system----
usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw |     time     
  3   1  95   1   0   0|  68k   21k|   0     0 | 928B 3920B| 102   400 |06-07 01:32:01
  4   2  94   0   0   0|   0     0 | 184B    0 |   0     0 |  61   292 |06-07 01:32:02
  3   2  95   0   0   0|   0     0 |   0     0 |   0     0 |  59   214 |06-07 01:32:03
  4   0  96   0   0   0|   0    24k| 184B    0 |   0     0 |  56   235 |06-07 01:32:04
  4   1  95   0   0   0|   0     0 |   0     0 |   0     0 |  56   208 |06-07 01:32:05
  3   0  97   0   0   0|   0     0 |   0     0 |   0     0 |  58   224 |06-07 01:32:06

Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.