Use Dstat for Linux Comprehensive Performance Diagnosis

Source: Internet
Author: User

Use Dstat for Linux Comprehensive Performance Diagnosis

Performance testing, evaluation, and optimization have always been the focus of system management and maintenance personnel. When we analyze a production application, obtaining basic data such as CPU, memory, IO, network throughput, and process load is crucial for subsequent performance evaluation and optimization.

As the most widely used server operating system, Linux has developed many native performance testing tools to cope with various performance problems. From top, vmstat, iostat to mpstat, you can analyze the main performance of the operating system in detail.

In the face of more and more complex analysis, we often need a comprehensive global performance tool in practice. In a tool, all data is collected and presented together. This article describes dstat performance analysis tools based on open-source architecture.

1. Dstat download and Installation

Dstat is an open source software developed by a free and open group. It can be downloaded from the author's website at http://dag.wiee.rs/home-made/dstat /.

Depending on the operating system version, Dstat provides different versions of the installation RPM or installation packages in other formats. The author's system is Red Hat 6.5, so select the appropriate version for installation.

[Root @ xxx-MIGPC-DB uploads] # uname-

Linux xxx-MIGPC-DB 2.6.32-358. el6.x86 _ 64 #1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64 x86_64 x86_64 GNU/Linux

[Root @ xxx-MIGPC-DB uploads] # ls-l

Total 164

-Rw-r -- 1 root 164276 Dec 3 dstat-0.7.2-1.el6.rfx.noarch.rpm

It is easy to install Dstat. You can directly install Dstat using the rpm tool.

[Root @ xxx-MIGPC-DB uploads] # rpm-ivh 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%]

[Root @ xxx-MIGPC-DB uploads] # rpm-qa | grep dstat

Dstat-0.7.2-1.el6.rfx.noarch

2. Dstat usage

From the official channel, we can find the official dstat html format instructions. In practice, we can use the help parameter to display function parameters.

[Root @ xxx-MIGPC-DB uploads] # dstat -- help

Usage: dstat [-afv] [options ..] [delay [count]

Versatile tool for generating system resource statistics

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

-- Aio enable aio stats

-- Fs, -- filesystem enable fs stats

-- Ipc enable ipc stats

-- Lock enable lock stats

-- Raw enable raw stats

-- Socket enable socket stats

-- Tcp enable tcp stats

-- Udp enable udp stats

-- Unix enable unix stats

-- Vm enable vm stats

-- Plugin-name enable plugins by plugin name (see manual)

-- List all available plugins

-A, -- all equals-cdngy (default)

-F, -- full automatically expand-C,-D,-I,-N and-S lists

-V, -- vmstat equals-pmgdsc-D total

-- Float force float values on screen

-- Integer force integer values on screen

-- Bw, -- blackonwhite change colors for white background terminal

-- Nocolor disable colors (implies -- noupdate)

-- Noheaders disable repetitive headers

-- Noupdate disable intermediate updates

-- Output file write CSV output to file

Delay is the delay in seconds between each update (default: 1)

Count is the number of updates to display before exiting (default: unlimited)

From the parameter type, we can see that Dstat provides comprehensive monitoring support for the operating system, including CPU, memory, disk and network. For different monitoring needs, you only need to enter different control parameters to perform continuous monitoring in a result set.

By default, the Dstat monitoring behavior is as follows:

[Root @ xxx-MIGPC-DB uploads] # dstat

You did not select any stats, using-cdngy by default.

---- Total-cpu-usage -----dsk/total--net/total---- paging -- --- system --

Usr sys idl wai hiq siq | read writ | recv send | in out | int csw

1 0 98 0 0 0 | 1395B 41k | 0 0 | 0 11B | 410 2134

25 0 75 0 0 0 | 0 0 | 60B limit B | 0 0 | 2058 2057

25 0 75 0 0 0 | 0 32k | 401B 635B | 0 0 | 2112 2128

26 0 75 0 0 0 | 0 0 | 60B 170B | 0 0 | 2075 2067

25 1 75 0 0 0 | 0 0 | 303B 170B | 0 0 | 2069 2091

25 0 75 0 0 0 | 0 64k | 120B 170B | 0 0 | 2042 2052

25 0 75 0 0 0 | 0 0 | 60B 170B | 0 0 | 2121 2102

25 0 75 0 0 0 | 0 0 | 60B 170B | 0 0 | 2055 2075

25 1 74 0 0 0 | 0 32k | 120B 170B | 0 0 | 2091 2094

By default, the cdngy parameter is used to monitor CPU, disk, network, memory paging, and system statistics.

To monitor a single item, you only need to enter a single parameter.

[Root @ xxx-MIGPC-DB dev] # dstat-c

---- Total-cpu-usage ----

Usr sys idl wai hiq siq

1 0 98 0 0 0

16 1 83 0 0 0

16 1 83 0 0 0

17 2 78 4 0 0

16 1 83 0 0 0

If you need to display the time, you can use the-t parameter to specify.

[Root @ xxx-MIGPC-DB dev] # dstat-a-t

---- Total-cpu-usage -----dsk/total--net/total---- paging -- --- system -- ---- system ----

Usr sys idl wai hiq siq | read writ | recv send | in out | int csw | time

1 0 98 0 0 0 | 1403B 41k | 0 0 | 0 11B | 410 2134 | 03-12 10:18:34

16 1 80 3 0 0 | 0 2280k | 53 k 99k | 0 0 | 2855 3135 | 03-12 10:18:35

16 1 83 0 0 0 | 0 32k | 53 k 100k | 0 0 | 2539 2842 | 03-12 10:18:36

16 1 83 0 0 0 | 0 0 | 53 k 98k | 0 0 | 2504 2799 | 03-12 10:18:37

By default, data is collected every second. If you want to specify a time interval and the number of samples similar to vmstat, you can directly enter a parameter later.

[Root @ xxx-MIGPC-DB dev] # dstat-at 3 10

---- Total-cpu-usage -----dsk/total--net/total---- paging -- --- system -- ---- system ----

Usr sys idl wai hiq siq | read writ | recv send | in out | int csw | time

1 0 98 0 0 0 | 1404B 41k | 0 0 | 0 11B | 410 2134 | 03-12 10:24:42

16 1 83 0 0 0 | 0 11k | 54 k 97k | 0 0 | 2513 2828 | 03-12 10:24:45

17 1 83 0 0 0 | 0 19k | 53 k 96k | 0 0 | 2493 2807 | 03-12 10:24:48

17 1 82 0 0 0 | 0 16k | 47 k 93k | 0 0 | 2460 2727 | 03-12 10:24:51

17 1 82 0 0 0 | 0 17k | 45 k 92k | 0 0 | 2423 2683 | 03-12 10:24:54

From experience, we recommend that you use the-cdlmnpsy parameter to fully display the entire system.

[Root @ xxx-MIGPC-DB dev] # dstat-cdlmnpsy

---- Total-cpu-usage -----dsk/total---- load-avg --- ------ memory-usage ------net/total---- procs --- ---- swap --- system --

Usr sys idl wai hiq siq | read writ | 1 m 5 m 15 m | used buff cach free | recv send | run blk new | used free | int csw

1 0 98 0 0 0 | 1404B 41k | 0.12 0.19 0.18 | 1458 M 125 M 13.6G 611M | 0 0 | 0.0 0 0.4 | 286 M 7730M | 410 2134

17 1 82 0 0 0 | 0 32k | 0.19 0.21 0.18 | 1458 M 125 M 13.6G 611M | 51 k 98k | 0 0 0 | 286 M 7730M | 2540 2828

16 1 83 0 0 0 | 0 0 | 0.19 0.21 0.18 | 1458 M 125 M 13.6G 611M | 57 k 103k | 0 0 0 | 286 M 7730M | 2530 2862

17 1 82 0 0 0 | 0 0 | 0.19 0.21 0.18 | 1458 M 125 M 13.6G 611M | 52 k 96k | 0 0 0 | 286 M 7730M | 2498 2810

Dstat also supports exporting collection results to csv files.

[Root @ xxx-MIGPC-DB ~] # Dstat-c -- output res.csv

---- Total-cpu-usage ----

Usr sys idl wai hiq siq

1 0 98 0 0 0

18 1 82 0 0 0

17 1 82 0 0 0

17 1 82 0 0 0

18 1 82 0 0 0

16 1 83 0 0 0

16 1 83 0 0 0

16 1 83 0 0 0

15 1 84 0 0 0

17 1 83 0 0 0

[Root @ xxx-MIGPC-DB ~] # Ls-l | grep res.csv

-Rw-r -- 1 root 1955 Dec 3 10:28 res.csv

Csv is still a relatively regular type.

3. Conclusion

When we perform comprehensive monitoring on the operating system, Dstat is of practical value as an open-source tool.

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.