Detailed example of Linux all-round system monitoring tool dstat

Detailed example of Linux all-round system monitoring tool dstat

All-round system monitoring tool dstat

dstat is a multi-functional product that can replace the vmstat, iostat, netstat and ifstat commands. dstat overcomes the limitations of these commands and adds some additional features, increases monitoring items, and becomes more flexible. dstat is a handy tool for monitoring system health and can be used for benchmarking and troubleshooting.

dstat allows you to see all system resources in real time. For example, you can compare disk utilization by counting the current status of IDE controllers, or compare disk throughput directly by network bandwidth values ​​(in the same time interval).

dstat will provide you with information about the options in a table format and clearly tell you in what range and units the output is displayed. This better avoids information confusion and false alarms. More importantly, it makes it easier for you to write plugins to collect the data information you want, extending it in ways that have never been possible before.

Dstat's default output is designed for real-time viewing by humans, but you can also export the details to a CSV file and import it into Gnumeric or Excel to generate a table.

characteristic

  • Combines information from vmstat, iostat, ifstat, netstat and more
  • Real-time display of statistics
  • When analyzing and troubleshooting, you can enable monitoring items and sort them
  • Modular design
  • Written in Python, it is more convenient to expand existing tasks
  • Easy to extend and add your counters (please contribute to this)
  • The many included extensions make it easy to add new monitoring items
  • Can group block devices/network devices and give the total number
  • Can display the current status of each device
  • Extremely accurate time accuracy, no delay in display even when the system is under high load
  • Display accurate units and limit conversion errors
  • Use different colors to show different units
  • The delay in displaying intermediate results is less than 1 second
  • Supports exporting CSV format reports and can be imported into Gnumeric and Excel to generate graphics

Installation Method

1. Under centos, you can yum -y instatll dstat

2. Download the rpm package for installation

wget http://packages.sw.be/dstat/dstat-0.7.2-1.el5.rfx.noarch.rpm

rpm -ivh dstat-0.7.2-1.el5.rfx.noarch.rpm

How to use

The basic usage of dstat is to enter the dstat command, and the output is as follows:

This is what the default output shows:

By default, there are five areas:

1. --total-cpu-usage----CPU usage

usr: the percentage of programs in user space;

sys: percentage of system space programs;

idel: idle percentage;

Wait: The percentage of time spent waiting for disk I/O;

hiq: number of hard interrupts;

siq: number of soft interrupts;

2. -dsk/total-disk statistics

read: total number of reads

writ: total number of writes

3. -net/total- Network statistics

recv: total number of network packets received

send: total number of network packets sent

4. ---paging-- Memory paging statistics

in: pagein

out: page out

Note: System paging activity. Paging refers to a memory management technique used to find system scenarios. A larger page indicates that the system is using a large amount of swap space. Usually, when the system has started using swap space, it means that your memory is not enough, or the memory is very fragmented. Ideally, the values ​​of page in and page out are 0 0.

5. --system--System information

int: number of interruptions

csw: context switch

Note: interrupt (int) and context switch (csw). This statistic is only meaningful when there is a baseline for comparison. A high statistic in this column usually indicates that a large number of processes are causing congestion and that the CPU needs attention. Your server will usually be running some programs, so this item will always show some values.

By default, dstat will refresh data every second, and keep refreshing and outputting data. Press Ctrl+C to exit "dstat";

dstat has many specific parameters, which can be viewed through the man dstat command.

Common parameters are as follows:

You can view all the parameters that dstat can use through dstat --list

  • -l : Display load statistics
  • -m: Display memory usage (including used, buffer, cache, free values)
  • -r : Display I/O statistics
  • -s: Display swap partition usage
  • -t : Display the current time on the first line
  • –fs : Display file system statistics (including total number of files and inodes value)
  • –nocolor : Do not display colors (sometimes useful)
  • --socket : Display network statistics
  • –tcp : Display common TCP statistics
  • –udp: Displays some dynamic data of the monitored UDP interface and its current usage

Of course, there are more than just these uses. dstat comes with some plugins that greatly expand its functionality. You can view some of their usage by looking in the /usr/share/dstat directory. The commonly used ones are:

  • -–disk-util: Displays the busy status of the disk at a certain time
  • -–freespace: Display current disk space usage
  • -–proc-count : Display the number of running programs
  • -–top-bio : Point out the process with the largest block I/O
  • -–top-cpu : Graphically display the processes that use the most CPU
  • -–top-io: Display the processes with the largest normal I/O
  • -–top-mem : Show processes that use the most memory

Application examples:

The default monitoring and report output interval of dstat is 3 seconds, and 10 results are output in the report.

# dstat 3 10

Check who is occupying all the memory:

# dstat -g -l -m -s --top-mem

Displays some data about CPU resource consumption:

# dstat -c -y -l --proc-count --top-cpu
How to output a csv file# dstat --output /tmp/sampleoutput.csv -cdn

Note: The output csv file can be opened with excel under windows and generate charts.

Summarize

The above is a detailed example of the Linux universal system monitoring tool dstat introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • How to use ss command instead of netstat in Linux operation and maintenance
  • Detailed explanation of Linux mpstat command usage
  • Linux performance debugging vmstat analysis
  • Linux stat function explanation (organization)
  • Detailed examples of viewing file attributes in Linux (ls, lsattr, file, stat)
  • Use netstat to view network status and port status in Linux
  • Detailed explanation of the use of stat function and stat command in Linux

<<:  MySQL data backup and restore sample code

>>:  Vue implements DingTalk's attendance calendar

Recommend

Analysis and description of network configuration files under Ubuntu system

I encountered a strange network problem today. I ...

ReactJs Basics Tutorial - Essential Edition

Table of contents 1. Introduction to ReactJS 2. U...

How to use JSX to implement Carousel components (front-end componentization)

Before we use JSX to build a component system, le...

HTML+CSS merge table border sample code

When we add borders to table and td tags, double ...

Detailed explanation of .bash_profile file in Linux system

Table of contents 1. Environment variable $PATH: ...

Common repair methods for MySQL master-slave replication disconnection

Table of contents 01 Problem Description 02 Solut...

Analysis and solution of data loss during Vue component value transfer

Preface In the previous article Two data types in...

Centos7.5 installs mysql5.7.24 binary package deployment

1. Environmental preparation: Operating system: C...

How to build and deploy Node project with Docker

Table of contents What is Docker Client-side Dock...

Summary of MySQL 8.0 Online DDL Quick Column Addition

Table of contents Problem Description Historical ...

Detailed explanation of basic concepts of HTML

What is HTML? HTML is a language used to describe...

Advanced Usage Examples of mv Command in Linux

Preface The mv command is the abbreviation of mov...

React State state and life cycle implementation method

1. Methods for implementing components:組件名稱首字母必須大...

Layui implements the login interface verification code

This article example shares the specific code of ...