Dstat Monitoring Tool

Monitoring Linux systems 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. Under Ubuntu, you can issue the sudo apt-get install dstat command. If your distribution doesn't contain dstat, then you can manually download the package from the web site address below. Make sure you match the package to your system!



Installing dstat on a CentOS 6 Server


"dstat" can be downloaded from Download Dstat

Either manually download the package to your system, or use the "wget" command to retrieve the package. In the example below, we issue the following command:

wget http://dag.wieers.com/packages/dstat/dstat-0.7.2-1.el6.rfx.noarch.rpm

Once the package is downloaded successfully, we can then issue the relevant rpm install command:

rpm -ihv dstat-0.7.2-1.el6.rfx.noarch.rpm


[root@centos tmp]# wget http://dag.wieers.com/packages/dstat/dstat-0.7.2-1.el6.rfx.noarch.rpm
--2013-02-12 20:56:08-- http://dag.wieers.com/packages/dstat/dstat-0.7.2-1.el6.rfx.noarch.rpm
Resolving dag.wieers.com... 188.40.111.73
Connecting to dag.wieers.com|188.40.111.73|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://dag.wieers.com/rpm/packages/dstat/dstat-0.7.2-1.el6.rfx.noarch.rpm [following]
--2013-02-12 20:56:08-- http://dag.wieers.com/rpm/packages/dstat/dstat-0.7.2-1.el6.rfx.noarch.rpm
Connecting to dag.wieers.com|188.40.111.73|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://packages.sw.be/dstat/dstat-0.7.2-1.el6.rfx.noarch.rpm [following]
--2013-02-12 20:56:08-- http://packages.sw.be/dstat/dstat-0.7.2-1.el6.rfx.noarch.rpm
Resolving packages.sw.be... 78.46.17.228
Connecting to packages.sw.be|78.46.17.228|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://pkgs.repoforge.org/dstat/dstat-0.7.2-1.el6.rfx.noarch.rpm [following]
--2013-02-12 20:56:08-- http://pkgs.repoforge.org/dstat/dstat-0.7.2-1.el6.rfx.noarch.rpm
Resolving pkgs.repoforge.org... 78.46.17.228
Connecting to pkgs.repoforge.org|78.46.17.228|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://rpmforge.sw.be/redhat/el6/en/i386/extras/RPMS/dstat-0.7.2-1.el6.rfx.noarch.rpm [following]
--2013-02-12 20:56:09-- http://rpmforge.sw.be/redhat/el6/en/i386/extras/RPMS/dstat-0.7.2-1.el6.rfx.noarch.rpm
Resolving rpmforge.sw.be... 78.46.17.228
Connecting to rpmforge.sw.be|78.46.17.228|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://tree.repoforge.org/redhat/el6/en/i386/extras/RPMS/dstat-0.7.2-1.el6.rfx.noarch.rpm [following]
--2013-02-12 20:56:09-- http://tree.repoforge.org/redhat/el6/en/i386/extras/RPMS/dstat-0.7.2-1.el6.rfx.noarch.rpm
Resolving tree.repoforge.org... 78.46.17.228
Connecting to tree.repoforge.org|78.46.17.228|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://apt.sw.be/redhat/el6/en/i386/extras/RPMS/dstat-0.7.2-1.el6.rfx.noarch.rpm [following]
--2013-02-12 20:56:09-- http://apt.sw.be/redhat/el6/en/i386/extras/RPMS/dstat-0.7.2-1.el6.rfx.noarch.rpm
Resolving apt.sw.be... 193.1.193.67
Connecting to apt.sw.be|193.1.193.67|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 164276 (160K) [application/x-redhat-package-manager]
Saving to: “dstat-0.7.2-1.el6.rfx.noarch.rpm”

100%[======================================>] 164,276 777K/s in 0.2s

2013-02-12 20:56:10 (777 KB/s) - “dstat-0.7.2-1.el6.rfx.noarch.rpm” saved [164276/164276]

[root@centos tmp]# rpm -ihv dstat-0.7.2-1.el6.rfx.noarch.rpm
warning: dstat-0.7.2-1.el6.rfx.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY
Preparing... ########################################### [100%]
1:dstat ########################################### [100%]


Now dstat should be installed and ready to display your systems performance stats.

In its simplest form dstat can be invoked by issuing the command: dstat



Example of dstat default output


dstat monitoring tool default view

You can tailor the output screen very simply by starting dstat with various parameters.

Start dstat with CPU, Disk and Network, you would use the parameters "-cdn"

dstat -cdn


Other Options


dstat 5 10

This would give 10 updates with an aggregated frequency of 5 seconds.
We can specify the options CPU, Disk and Network with: dstat -cdn 5 10.
This again would give us 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

This option can be used in conjunction with a cron entry to execute your command at a given time. You could even arrange for the output to be emailed to yourself for viewing.

Example output from csv file:


"Host:","john-desktop",,,,"User:","john"
"Cmdline:","dstat --output /tmp/myoutput_stats.csv -cdn",,,,"Date:","12 Feb 2013 21:33:26 GMT"

"total cpu usage",,,,,,"dsk/total",,"net/total",
"usr","sys","idl","wai","hiq","siq","read","writ","recv","send"
29.807,20.017,46.786,3.292,0.0,0.097,241982.888,194196.809,0.0,0.0
3.0,1.0,96.0,0.0,0.0,0.0,0.0,0.0,6606.0,0.0
3.0,1.0,96.0,0.0,0.0,0.0,0.0,0.0,92.0,0.0
2.020,2.020,95.960,0.0,0.0,0.0,0.0,0.0,670.0,462.0
3.960,0.990,95.050,0.0,0.0,0.0,0.0,0.0,6756.0,66.0
2.0,3.0,92.0,3.0,0.0,0.0,0.0,49152.0,0.0,0.0
3.0,2.0,94.0,1.0,0.0,0.0,0.0,0.0,208.0,0.0
2.0,2.0,96.0,0.0,0.0,0.0,0.0,0.0,6422.0,0.0
3.960,0.990,95.050,0.0,0.0,0.0,0.0,0.0,0.0,0.0
3.030,1.010,95.960,0.0,0.0,0.0,0.0,0.0,542.0,66.0
2.970,0.990,96.040,0.0,0.0,0.0,0.0,0.0,0.0,0.0
4.040,1.010,93.939,1.010,0.0,0.0,0.0,12288.0,0.0,0.0
2.0,2.0,96.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
3.922,1.961,94.118,0.0,0.0,0.0,0.0,0.0,208.0,0.0
2.020,1.010,96.970,0.0,0.0,0.0,0.0,0.0,328.0,42.0


Other options available to dstat:


Dstat 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


For a full list of all the options available, issue the command: dstat --help