How to install dstat on Ubuntu 16.04

To install dstat on Ubuntu 16.04

dstat is a versatile tool for generating system resource statistics and replacement for vmstat, iostat, netstat, and ifstat. You can additionally monitor MySQL database activity, batter percentage info for laptop, number of dbus connections, fan speed, nfs utility, postfix, system temperature sensors, power usage, etc,., more & more. Dstat is packed with several powerful features and some of them are listed as follows.

dstat features

  • Combines vmstat, iostat, ifstat, netstat information and more
  • Shows stats in exactly the same timeframe
  • Enable/order counters as they make most sense during analysis/troubleshooting
  • Modular design
  • Written in python so easily extendable for the task at hand
  • Easy to extend, add your own counters (please contribute those)
  • Includes many external plugins to show how easy it is to add counters
  • Can summarize grouped block/network devices and give total numbers
  • Can show interrupts per device
  • Very accurate timeframes, no timeshifts when system is stressed
  • Shows exact units and limits conversion mistakes
  • Indicate different units with different colors
  • Show intermediate results when delay > 1
  • Allows to export CSV output, which can be imported in Gnumeric and Excel to make graphs

It is so simple to install dstat on Ubuntu 16.04, and this tutorial covers the ground on the same process.

Installing dstat

First, make sure you update your system by making use of the following command.

root@linuxhelp:~# apt-get update
Hit:1 http://in.archive.ubuntu.com/ubuntu xenial InRelease          
Hit:2 http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease
.
.
Fetched 5,469 kB in 20s (264 kB/s)                                                            
Reading package lists... Done

Once it is done, you shall install dstat by making use of the following command.

root@linuxhelp:~# apt-get install dstat
Reading package lists... Done
.
.
bingwallpaper
Reading package lists... Done

dstat has been installed. Here are some of its usages.


dstat Usage
Here is a small gist of the options used with dstat - cdngy
c : cpu : Total cpu usage
d : disk : Disk Utilization
n : net : Total Network usage
g : page : page stats
y : sys : system stats

After successful installation of dstat, simply fire dstat without any option, the application will get opened.

root@linuxhelp:~#dstat

To show detailed information about Memory (used, buffer, cache & free), Swap (used & free) & Virtual Memory (allocated, free, major page fault & minor page fault) usage, run the following command.

 root@linuxhelp:~#dstat --mem --swap &ndash vm

To show detailed information about each CPU (including cpu0, cpu1, etc) and total usage run the command given below. It displays each CPU (user time, system time, idle time, steal time & wait time) process activity.

root@linuxhelp:~#dstat -C 0,1,2,total

To show detailed information about disk utilization (read & write) and disk I/O (read & write) utilization for particular disk run the below command. If you want to check total disk utilization & I/O, use dstat --disk --io.

root@linuxhelp:~#dstat --disk --io -D sda

You can display detailed information about network utilization (data receive and data send) for particular Ethernet make sure you run the following command. If you want to show all the Ethernet utilization, use dstat &ndash net as follows.

root@linuxhelp:~# dstat --net -N ens33


You can also have detailed information about top CPU, top cputime (process using the most CPU time (in ms)), top disk I/O activity, top disk block I/O activity, top memory and top latency usage.

root@linuxhelp:~#dstat --top-cpu --top-cputime --top-io --top-bio --top-mem --top-latency


To show detailed information about (CPU, Disk, Memory, Process, Load & network) usage, which is very common for basic troubleshooting when server load is too high, make use of the following command.

root@linuxhelp:~#dstat --cpu --mem --proc --load --disk &ndash net

To show detailed information about tcp (listen, established, syn, time_wait, close), udp (listen, active) and socket (total, tcp, udp, raw, ip-fragments) usage, you need to run the following command.

root@linuxhelp:~#dstat --tcp --udp &ndash socket


Also, you can display statistic with every 5 seconds delay instead of default (1 sec delay) with any combination as per your requirement. The below combination shows about CPU and process statistic every 5 seconds.

root@linuxhelp:~#dstat --time --cpu --proc 5


By default, delay is 1 sec and count is unlimited and if you want to display statistic every 2 seconds delay with 10 counts on any combination as per your requirement. The below combination shows about cpu & process statistic every 2 seconds with 10 counts.

root@linuxhelp:~#dstat --time --cpu --proc 2 10


If you want to store the reports to file for further investigation, you can do by using the below format with any combination.

root@linuxhelp:~#dstat --output /opt/dstat-output.csv --cpu --mem --disk &ndash io


See the output.CSV file date.


With this, the installation and usage of dstat on Ubuntu 16.04 gets completed.

Tag : dstat Ubuntu
FAQ
Q
What are intermediate updates in dstat?
A
When invoking PCP-dstat with a delay greater than 1 second and without the --update option, it will show intermediate updates, ie. the first time a 1 second average, the second update a 2 second average, etc. until the delay has been reached.

So in case you specified a delay of 10, the 9 intermediate updates are NOT snapshots, they are averages over the time that passed since the last final update. The end result is that you get a 10 second average on a new line, just like with vmstat.
Q
How to enable raw socket in dstat?
A
For enable the raw socket in dstat, use the option of " --raw " with "dstat" command on the terminal.
Q
How to install dstat on ubuntu?
A
For the installation of "stat" on Ubuntu, use the following link as given below "https://www.linuxhelp.com/how-to-install-sysstat-on-parrotos-3-9/"
Q
How to install dstat on CentOS?
A
For the installation of dstat on CentOS, use the following link as given below "https://www.linuxhelp.com/how-to-monitor-system-statistics-using-dstat/".
Q
What is the main term of using the dstat?
A
PCP-dstat is a general performance analysis tool allowing you to view multiple system resources instantly, for example, you can compare disk usage in combination with interrupts from a disk controller, or compare the network bandwidth numbers directly with the disk throughput (in the same interval).

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