dstat
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
If .rpm based, install it using
# rpm -ivh .rpm
Figure 1 dstat installation on CentOS 5.9
If .deb based, install it using
# dpkg -i .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.
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.
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
Show information about cpu, disk (sda1) utilization and system load
$ dstat -cdl -D sda1
Show information about top cpu, top latency and top memory
$ dstat --top-cpu-adv --top-latency --top-mem
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
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
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.
Comments
Post a Comment