Dstat Monitoring Tool

Monitoring Linux with dstat


Monitoring with dstat - The Versatile Resource Statistics Tool

Dstat is an alternative replacement tool for vmstat, iostat, netstat and ifstat. Dstat is a feature rich monitoring tool that is often used for tuning and benchmarking a systems performance. dstat is available in many distributions standard repositories.

Installing dstat

dstat should be available on most popular Linux distributions, directly from the standard repositories.

To install dstat on a Debian/Ubuntu/Mint system, issue the command: sudo apt install dstat

To install dstat on a openSUSE system, issue the command: zypper install dstat

To install dstat on a RHEL 8 or CentOS 8 system, you will need to install the package that provides the dstat program. An example installation can be found below on a RHEL 8 system.

RHEL 8 - CentOS 8 Install

To install dstat onto a RHEL based system, we first need to locate the package that provides the program dstat. The command for this is: "dnf provides dstat". The package needed will be identified and can then be installed.


root@rhel08a ~]# dnf provides dstat
pcp-system-tools-5.1.1-4.el8_3.x86_64 : Performance Co-Pilot (PCP) System and Monitoring Tools
Repo        : rhel-8-for-x86_64-appstream-rpms
Matched from:
Provide    : dstat = 5.1.1-4.el8_3

From the above output we can see that dstat is provided as part of the package "pcp-system-tools"

To install this package we can issue the command: "dnf install pcp-system-tools-5.1.1-4.el8_3.x86_64" or "dnf install pcp-system-tools" for the latest version.


root@rhel08a ~]# dnf install pcp-system-tools-5.1.1-4.el8_3.x86_64
Updating Subscription Management repositories.
Last metadata expiration check: 0:05:43 ago on Sun 25 Apr 2021 10:45:01 BST.
Dependencies resolved.
==========================================================================================================
 Package              Arch    Version                              Repository                         Size
==========================================================================================================
Installing:
 pcp-system-tools     x86_64  5.1.1-3.el8                          rhel-8-for-x86_64-appstream-rpms  191 k
Installing dependencies:
 libuv                x86_64  1:1.38.0-2.el8                       rhel-8-for-x86_64-appstream-rpms  152 k
 pcp                  x86_64  5.1.1-3.el8                          rhel-8-for-x86_64-appstream-rpms  1.2 M
 pcp-conf             x86_64  5.1.1-3.el8                          rhel-8-for-x86_64-appstream-rpms   50 k
 pcp-libs             x86_64  5.1.1-3.el8                          rhel-8-for-x86_64-appstream-rpms  536 k
 pcp-selinux          x86_64  5.1.1-3.el8                          rhel-8-for-x86_64-appstream-rpms   47 k
 python3-pcp          x86_64  5.1.1-3.el8                          rhel-8-for-x86_64-appstream-rpms  167 k
 python3-pip          noarch  9.0.3-18.el8                         rhel-8-for-x86_64-appstream-rpms   20 k
 python3-setuptools   noarch  39.2.0-6.el8                         rhel-8-for-x86_64-baseos-rpms     163 k
 python36             x86_64  3.6.8-2.module+el8.1.0+3334+5cb623d7 rhel-8-for-x86_64-appstream-rpms   19 k
Enabling module streams:
 python36                     3.6                                                                         

Transaction Summary
==========================================================================================================
Install  10 Packages

Total download size: 2.5 M
Installed size: 7.3 M
Is this ok [y/N]: Downloading Packages:
(1/10): python36-3.6.8-2.module+el8.1.0+3334+5c  31 kB/s |  19 kB     00:00    
(2/10): python3-setuptools-39.2.0-6.el8.noarch. 234 kB/s | 163 kB     00:00    
(3/10): libuv-1.38.0-2.el8.x86_64.rpm           570 kB/s | 152 kB     00:00    
(4/10): pcp-system-tools-5.1.1-3.el8.x86_64.rpm 172 kB/s | 191 kB     00:01    
(5/10): pcp-conf-5.1.1-3.el8.x86_64.rpm          35 kB/s |  50 kB     00:01    
(6/10): python3-pip-9.0.3-18.el8.noarch.rpm      98 kB/s |  20 kB     00:00    
(7/10): pcp-5.1.1-3.el8.x86_64.rpm              445 kB/s | 1.2 MB     00:02    
(8/10): pcp-selinux-5.1.1-3.el8.x86_64.rpm       41 kB/s |  47 kB     00:01    
(9/10): python3-pcp-5.1.1-3.el8.x86_64.rpm      123 kB/s | 167 kB     00:01    
(10/10): pcp-libs-5.1.1-3.el8.x86_64.rpm        328 kB/s | 536 kB     00:01    
--------------------------------------------------------------------------------
Total                                           586 kB/s | 2.5 MB     00:04     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Installing       : libuv-1:1.38.0-2.el8.x86_64                           1/10 
  Installing       : pcp-selinux-5.1.1-3.el8.x86_64                        2/10 
  Running scriptlet: pcp-selinux-5.1.1-3.el8.x86_64                        2/10 
  Installing       : pcp-conf-5.1.1-3.el8.x86_64                           3/10 
  Installing       : pcp-libs-5.1.1-3.el8.x86_64                           4/10 
  Running scriptlet: pcp-5.1.1-3.el8.x86_64                                5/10 
  Installing       : pcp-5.1.1-3.el8.x86_64                                5/10 
  Running scriptlet: pcp-5.1.1-3.el8.x86_64                                5/10 
  Installing       : python3-setuptools-39.2.0-6.el8.noarch                6/10 
  Installing       : python3-pip-9.0.3-18.el8.noarch                       7/10 
  Installing       : python36-3.6.8-2.module+el8.1.0+3334+5cb623d7.x86_    8/10 
  Running scriptlet: python36-3.6.8-2.module+el8.1.0+3334+5cb623d7.x86_    8/10 
  Installing       : python3-pcp-5.1.1-3.el8.x86_64                        9/10 
  Installing       : pcp-system-tools-5.1.1-3.el8.x86_64                  10/10 
  Running scriptlet: pcp-system-tools-5.1.1-3.el8.x86_64                  10/10 
  Verifying        : python3-setuptools-39.2.0-6.el8.noarch                1/10 
  Verifying        : python36-3.6.8-2.module+el8.1.0+3334+5cb623d7.x86_    2/10 
  Verifying        : pcp-5.1.1-3.el8.x86_64                                3/10 
  Verifying        : libuv-1:1.38.0-2.el8.x86_64                           4/10 
  Verifying        : pcp-conf-5.1.1-3.el8.x86_64                           5/10 
  Verifying        : pcp-system-tools-5.1.1-3.el8.x86_64                   6/10 
  Verifying        : python3-pip-9.0.3-18.el8.noarch                       7/10 
  Verifying        : pcp-selinux-5.1.1-3.el8.x86_64                        8/10 
  Verifying        : python3-pcp-5.1.1-3.el8.x86_64                        9/10 
  Verifying        : pcp-libs-5.1.1-3.el8.x86_64                          10/10 
Installed products updated.

Installed:
  libuv-1:1.38.0-2.el8.x86_64                                                   
  pcp-5.1.1-3.el8.x86_64                                                        
  pcp-conf-5.1.1-3.el8.x86_64                                                   
  pcp-libs-5.1.1-3.el8.x86_64                                                   
  pcp-selinux-5.1.1-3.el8.x86_64                                                
  pcp-system-tools-5.1.1-3.el8.x86_64                                           
  python3-pcp-5.1.1-3.el8.x86_64                                                
  python3-pip-9.0.3-18.el8.noarch                                               
  python3-setuptools-39.2.0-6.el8.noarch                                        
  python36-3.6.8-2.module+el8.1.0+3334+5cb623d7.x86_64                          

Complete!

Now that the package has been installed, you can start "dstat" by typing "dsat" at the command line.

Linux dstat

Custom Start-Up

You can tailor the start up of your dstat session by specifying various parameters.

To start dstat with CPU, Disk and Network, you would specify the following "-cdn".

Command Issued: "dstat -cdn"

Linux dstat startup parameters

You can also specify how many updates and frequency you want to use. This is very similar to "vmstat" command.

Example: "dstat -cdn 5 10" will give you 10 updates with a aggregated frequency of 5 seconds between output.

dstat - output to a file

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

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

Example output from csv file:


"Host:","rhel08a",,,,"User:","root"
"Cmdline:","dstat --output /tmp/myoutput_stats.csv -cdn",,,,"Date:","25 Apr 2021 11:43:30 BST"
"total usage",,,,,"dsk/total",,"net/total",
"total usage:usr","total usage:sys","total usage:idl","total usage:wai","total usage:stl","dsk/total:read","dsk/total:writ","net/total:recv","net/total:send"
0,0.499,99.886,0,0,0,1.998,51.941,0
0,0,99.459,0,0,0,48.980,0,0
0.500,0,100.007,0,0,0,0,52.003,0
0,0.500,99.033,0,0,0,0,0,0
0,0,99.948,0,0.500,0,0,51.973,0
0,0,99.523,0,0,0,0,0,0
0,0.500,99.996,0,0,0,0,51.998,0
0,0,100.003,0,0,0,0,0,0
0,0,98.997,0,0,0,0,51.998,0
0,0,99.971,0,0,0,0,0,0
0,0.500,99.527,0,0,0,0,52.014,0
0.500,0,100.001,0,0,0,0,213.002,0

Getting Help with dstat

For a full overview of all the commands and options available, you can issue the commands: "dstat -help".