dstat Tool to Monitor Processor, Memory, Network Performance on Linux Server

One of system administrator main job is to monitor server performance, such as processor, memory, network, and system utilization. The servers should always in its best performance and should be available when needed. To monitor all of those components in Linux system, we already know iostat (monitor system input output), vmstat (monitor memory utilization) and ifstat (monitor network usage). What if you can have 1 tool which has those 3 functions above and even more? We can do it using dstat tool.

What is dstat

Dstats is a versatile resource statistic tool. This tool combines the ability of iostat, vmstat, netstat, and ifstat. Dstat allow us to monitor the server resources in real-time. When you need to gather those information real-time, dstat will fit your need.

Features

But dstat is not only combination of iostat, vmstat, netstat and ifstat. Here’s a list of what dstat can do.

  • 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

How to install dstat

Dstat is supported by most major Linux distribution such as RedHat, CentOS and Debian. Dstat is available in .rpm and .deb packages. Generally, here’s the step if you want to install dstat using package.

1. Choose appropriate package for your Linux. You can choose it from dstat download page.
If .rpm based, install it using

# rpm -ivh .rpm

Installation with rpm

Figure 1 dstat installation on CentOS 5.9

If .deb based, install it using

# dpkg -i .deb

Installation with deb

Figure 2 dstat installation on Debian

2. Type dstat to run it.

Using source file

But if you prefer to use the source file, you can freely download it from dstat download link.
With this source file, what you need is extract it. Then go to the folder you extracted and type ./dstat to run it. No installation is required.

dstat default view

Figure 3 Run dstat

Customize dstat output

When you run dstat without any options, it will using -cdngy options which the result can be seen on the picture above.

The -cdngy paramater are represent :

  • c : cpu stats (total cpu usage)
  • d : disk stats (disk/total)
  • n : network stats (net/total)
  • g : page stats (paging)
  • y : system stats (system)

But of course you can use another options to custom dstat output. Here’s some samples :

Show information about cpu, memory, eth0 activity and system resources related to time

$ dstat -tcmsn -N eth0

dstat sample 1

Show information about cpu, disk (sda1) utilization and system load

$ dstat -cdl -D sda1

dstat sample 2

Show information about top cpu, top latency and top memory

$ dstat --top-cpu-adv --top-latency --top-mem

dstat sample 3

Using delay for statistics

Since dstat means to show real-time statistic, it will capture process each second and dstat will display it. The delay between each updates is 1 second by default. When you want to extend the delay, you can put a number at the end of dstat command.

Let say you want to display statistic every 5 seconds about network and tcp activity. Then the command will be like this.

$ dstat -tn -N eth0 --tcp 5

dstat with delay

As you can see on time column, dstat will print the stats every 5 seconds.

Using count for statistics

When you type dstat on your console with or without parameters, it will display unlimited number of stats update. To stop the update, we must press Ctrl-C button. If you want to limit the updates result, we can use count.

To use count, delay must be used first. From the example above, we want to limit the number of stats updates to 10 with delay every 2 second. The command will be like this.

$ dstat -tn eth0 --tcp 2 10

dstat with count

Conclusion

Dstat output is not intended as an input to be processed by another tools. Dstat is intended for humans to interpret real-time data as easy as possible. This article are not cover all dstat features. Since dstat has a lot of features, you may want to read its manual page by typing man dstat or dstat -h to view dstat available options.

Category: MONITORING, OPEN SOURCE TOOLS

Comments (2)

Trackback URL | Comments RSS Feed

  1. Stuart says:

    Pretty cool tool thanks.

    By the way, I noticed that if I start this whilst my mysqldump is taking place it causes a connection issue:
    mysqldump: Got error: 2003: Can't connect to MySQL server on 'xxxxxxx' (110) when trying to connect

    However if you run dstat and then run the dump you are fine. I made sure to run this several times just to double check it was not something else.

  2. Pungki Arianto says:

    Hi Stuart,

    I am so sorry for late reply.

    I tried to simulate the situation you had. Since I don't have a large database in MySQL, I am using database from https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2

    I import it into MySQL. Then I run mysqldump employees_db > employees_backup.sql

    Then I run dstat without any parameter in another console. But I didn't get any error message as you got. Do you run it with specific options?

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.