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

JavaScript to dynamically load and delete tables

This article shares the specific code of JavaScri...

Use href to simply click on a link to jump to a specified place on the page

After clicking the a tag in the page, you want to ...

Summary of pitfalls in virtualbox centos7 nat+host-only networking

Table of contents 1. Problem Background 2. What a...

Analysis of slow insert cases caused by large transactions in MySQL

【question】 The INSERT statement is one of the mos...

How to replace all tags in html text

(?i) means do not match case. Replace all uppercas...

How to import and export Docker images

This article introduces the import and export of ...

Detailed explanation of the steps of using ElementUI in actual projects

Table of contents 1. Table self-sorting 2. Paging...

Getting Started Tutorial for Beginners ④: How to bind subdirectories

To understand what this means, we must first know ...

HTML table mouse drag sorting function

Effect picture: 1. Import files <script src=&q...

Implementing custom scroll bar with native js

This article example shares the specific code of ...