Dstat – A Resourceful Tool to Monitor Linux Server Performance in Real-Time

Some of the popular and frequently used system resource generating tools available on the Linux platform include vmstat, netstat, iostat, ifstat and mpstat. They are used for reporting statistics from different system components such as virtual memory, network connections and interfaces, CPU, input/output devices and more.

As a system administrator, you may be looking for that one tool that can give your a good amount of the information provided by above tools, even more, a single and powerful tool that has additional features and capabilities, then look no further than dstat.

Suggested Read: 20 Command Line Tools to Monitor Linux Performance

dstat is a powerful, flexible and versatile tool for generating Linux system resource statistics, that is a replacement for all the tools mentioned above. It comes with extra features, counters and it is highly extensible, users with Python knowledge can build their own plugins.

Features of dstat:

  1. Joins information from vmstat, netstat, iostat, ifstat and mpstat tools
  2. Displays statistics simultaneously
  3. Orders counters and highly-extensible
  4. Supports summarizing of grouped block/network devices
  5. Displays interrupts per device
  6. Works on accurate timeframes, no timeshifts when a system is stressed
  7. Supports colored output, it indicates different units in different colors
  8. Shows exact units and limits conversion mistakes as much as possible
  9. Supports exporting of CSV output to Gnumeric and Excel documents

How to Install dstat in Linux Systems

dstat is available to install from default repositories on most Linux distributions, you can install and use it for monitoring a Linux system in the process of performance tuning tests or troubleshooting exercises.

# yum install dstat             [On RedHat/CentOS and Fedora]
$ sudo apt-get install dstat    [On Debian, Ubuntu and Linux Mint]

It works in real-time, outputting selective information in columns, including the magnitude and units for stats displayed after every one second, by default.

Note: The dstat output is aimed specifically for human interpretation, not as input for other tools to process.

Below is an output seen after running the dstat command without any options and arguments (similar to using -cdngy (default) options or -a option).

$ dstat 
Dstat - Linux Performance Statistics Monitoring
Dstat – Linux Performance Statistics Monitoring

The output above indicates:

  1. CPU stats: cpu usage by a user (usr) processes, system (sys) processes, as well as the number of idle (idl) and waiting (wai) processes, hard interrupt (hiq) and soft interrupt (siq).
  2. Disk stats: total number of read (read) and write (writ) operations on disks.
  3. Network stats: total amount of bytes received (recv) and sent (send) on network interfaces.
  4. Paging stats: number of times information is copied into (in) and moved out (out) of memory.
  5. System stats: number of interrupts (int) and context switches (csw).

To display information provided by vmstat, use the -v or --vmstat option:

$ dstat --vmstat
Dstat - Linux Process and Memory Monitoring
Dstat – Linux Process and Memory Monitoring

In the image above, dstat displays:

  1. Process stats: number of running (run), blocked (blk) and new (new) spawned processes.
  2. Memory stats: amount of used (used), buffered (buff), cached (cach) and free (free) memory.

I already explained at the last three sections (paging, disk and system stats) in the previous example.

Suggested Read: Sysstat – All-in-One System Performance and Usage Activity Monitoring Tool For Linux

Let us dive into some advanced dstat system monitoring commands. In the next example, we want to monitor a single program that is using the most CPU and consuming the most amount of memory.

The options in the command are:

  1. -c – cpu usage
  2. --top-cpu – process using most CPU
  3. -dn – disk and network stats
  4. --top-mem – process consuming the most memory
$ dstat -c --top-cpu -dn --top-mem
Dstat - Monitor Processes by CPU and Memory Usage
Dstat – Monitor Processes by CPU and Memory Usage

Additionally, you can also store the output of dstat in a .csv file for analysis at a latter time by enabling the --output option as in the example below.

0Here, we are displaying the time, cpu, mem, system load stats with a one second delay between 5 updates (counts).

$ dstat --time --cpu --mem --load --output report.csv 1 5 
Dstat - Monitor Linux CPU Memory and Load
Dstat – Monitor Linux CPU Memory and Load

There are several internal (such as options used in previous example) and external dstat plugins you can use with dstat, to view a list of all available plugins, run the command below:

$ dstat --list
List of Dstat Plugins
List of Dstat Plugins

It reads plugins from the paths below, therefore, add external plugins in these directories:

~/.dstat/
(path of binary)/plugins/
/usr/share/dstat/
/usr/local/share/dstat/

For more usage information, look through the dstat man page or visit the homepage at: http://dag.wiee.rs/home-made/dstat/.

Suggested Read: Collectl: An Advanced All-in-One Performance Monitoring Tool for Linux

dstat is a versatile, all-in-one system resources statistics generating tool, it combines information from several other tools such as vmstat, mpstat, iostat, netstat and ifstat.

I hope this review will be helpful to you, most importantly, you can share with us any suggestions, supplementary ideas to improve the article and also give us feedback about your experience using of dstat through the comment section below.

If you read this far, tweet to the author to show them you care. Tweet a thanks
Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

2 thoughts on “Dstat – A Resourceful Tool to Monitor Linux Server Performance in Real-Time”

  1. In the screenshot for command “dstat –vmstat” there are 1.4 new processes. I’m surprised looking at non-integer amounts. Also, I can’t understand why there are 0 running processes most of the time.

    Reply
  2. Great post you have here, Aaron. Did you know that if you manage your server with RunCloud, these stats are available for you without having to install anything. We developed RunCloud which will configure your server to the best configuration so you can focus only on things that matters.

    Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.