Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

dstat

📅 2021-Feb-14 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ dstat ⬩ 📚 Archive

dstat is a good utility to get a runtime view of statistics of system resources like CPU, disk and network.

$ sudo apt install dstat
$ dstat

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
  3   4  81  12   0|  16k 1135k|   0     0 |   0     0 |9497  1088
  1   1   0  98   0|   0   364k| 218B 1428B|   0     0 |  10k 2520
  3  10   0  87   0|   0   880k| 367B  338B|   0     0 |  10k 2805

We can see that by default, it prints out CPU (-c), disk (-d), network (-n), page (-g) and system (-y) stats. Individual stats of each of these can obtained by using those commandline options. For example, dstat -d to view disk statistics only.

Also, note that the first report (i.e., the first line) is the total or average of that stat from the time the system was booted.

$ dstat 9

The delay argument can be used to the right of other commandline options, like dstat -d 9 for example.

$ dstat 9 20
$ dstat --output joe.csv 1 3

Note that the --output and other options have to be placed before the delay and count arguments.

References: