Linux system performance monitoring tools--htop and Dstat Introduction

Source: Internet
Author: User
Tags cpu usage

Directory

I. Introduction to the use of htop tools

Ii. Introduction to the use of Dstat tools

This blog post for Linux system introduced two commonly used system performance monitoring software basic use, for Linux system we generally want to monitor the object has process, CPU, memory, disk IO, swap, network card and so on.

(a) Introduction to the use of htop tools

Htop is a more user-friendly, more powerful interactive process viewer than top, and is a free, GPL-compliant, process viewer for Linux. can also be implemented in the monitoring interface to send a signal to a process, such as killing a process, etc., can also adjust the priority of a process and other functions. Let's start with a picture of the Htop runtime.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/47/wKioL1V4GLKjnxcfAAUS3UmN-lM641.jpg "title=" 1.png " alt= "Wkiol1v4glkjnxcfaaus3umn-lm641.jpg"/>

Htop installation is very simple, in the CentOS system as long as the configuration of Epel source, directly "Yum-y install Htop" can be, pay attention to the red box part, through these shortcuts we can easily grasp the basic use of htop, and now tidy up some of the commonly used Htip use method.

1.1. How to adjust the sorting standard of htop output

By default, Htop is a large-to-small arrangement with CPU usage, which can be done if you want to sort by memory usage, or by the size of shared memory, or by CPU time slices.

Press "F6" key, appear in the first picture, and then select the criteria you want to sort, I chose "mem%" here, and then enter to determine, such as the second picture in.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/4B/wKiom1V4F0SQVBZHAAU-IsXU430394.jpg "title=" 1.jpg " alt= "Wkiom1v4f0sqvbzhaau-isxu430394.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/4B/wKiom1V4F3DDxZNbAAUUAi-YB0E482.jpg "title=" 1.jpg " alt= "Wkiom1v4f3ddxznbaauuai-yb0e482.jpg"/>

1.2, how to monitor the specified process

Press the "F4" key, enable the filtering function, enter the name of the process you want to monitor in the input box, I will use Nginx as an example, as shown in.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/4B/wKiom1V4F56Ct9qFAAK3Wr_Vlco318.jpg "title=" 1.jpg " alt= "Wkiom1v4f56ct9qfaak3wr_vlco318.jpg"/>

This allows you to monitor the process you have specified, press ENTER again, press the "F5" key, and view the relationships between processes, as shown in:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/47/wKioL1V4GWPifRDAAAJkwpJxWFM638.jpg "title=" 1.jpg " alt= "Wkiol1v4gwpifrdaaajkwpjxwfm638.jpg"/>

It can be seen that 6 worker processes are forked by a master process. So how do we get back to the window when it's opened by default? After pressing "F4", note the tip at the bottom left, and then press "ESC" to return, just double-click.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/4B/wKiom1V4GM3AAffPAAM_uW9wq08741.jpg "title=" 1.jpg " alt= "Wkiom1v4gm3aaffpaam_uw9wq08741.jpg"/>

1.3. How to navigate to the specified process

The second filter method can also be used to locate the specified process, but the second method shows only the process you specify, if you just want to see the basic information of a process, such as the number of its PID, then do not use the filter to see the way. Directly with the "Search" function, the operation method for the main interface in the Htop Press "F3" (Directly Press "/" This button can also, that is, the key question), enter the input box you want to locate the process name, Nginx as an example, such as:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/47/wKioL1V4Go-hysq9AAgK03idjhI948.jpg "title=" 1.jpg " alt= "Wkiol1v4go-hysq9aagk03idjhi948.jpg"/> If you specify more than one process name, you can also intermittently press the "F3" key to find it.

1.4. Use Htop to adjust the nice value of the process

For example, I want to increase the priority of the Nginx master process, then we have to reduce the nice value of the master process, then first in the Htop interface to locate the Nginx master process, and then press "F7", by a nice value minus 1, if you want to increase the nice value, Then press the "F8" key. To add, the range of Nice values is ( -20,19), the smaller the value, the higher the priority of the process. The results are as follows:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/47/wKioL1V4Gr3T0TwqAAgFtR3RuMU969.jpg "title=" 1.jpg " alt= "wkiol1v4gr3t0twqaagftr3rumu969.jpg"/>1.5, using htop to transmit signals to the process

By Htop can send a signal to a process, such as you find a suspicious process, you can directly kill it, that is, send a "SIGKILL" signal to the process, if you want a process to restart, it can send "SIGHUP" signal, and so on. To Nginx, for example, first locate the Nginx, and then press the "F9" key, and then select the signal you want to send, enter. Looked carefully, a total of 32 signals.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/4B/wKiom1V4GTrj4ibsAAiUGOsv6Nk952.jpg "title=" 1.jpg " alt= "Wkiom1v4gtrj4ibsaaiugosv6nk952.jpg"/>htop Basic use is here, more functions need we in practice to dig.

(ii) Introduction to the use of Dstat tools

Dstat is a multi-purpose system resource statistics tool that can print out the status statistics of various resources such as CPU, memory, disk, process, network, memory page and so on, and has a very comprehensive system monitoring tool. Install directly on the CentOS system using "Yum-y install Dstat".

The syntax is:

Dstat [-AFV] [options:] [Delay [Count]]

-AFV: Three can be the first parameter, you can test the difference of each parameter

Option: Many options are available first

Delsy: is the specified acquisition frequency

Count: Number of acquisitions

Here are some common options:

-C,--cpu turn on monitoring status of the CPU

-D,--disk turn on disk monitoring

-G,--page open monitoring of page status

-N,--net turn on network monitoring

-Y,--sys open monitoring of system kernel activity, mainly the number of interrupts and context switches accepted by the system

-A,--all this option is equivalent to-cdgny these two options, is dstat default work options

-T,--time this option can also output the time of data acquisition

--TCP Open monitoring of TCP status, including processing of the number of States such as Listen,established,syn

--output file specifies that the monitoring output information is saved as CSV files

There are some plug-in related options, some plug-ins need to install themselves, but some can be used directly, here are some of the more commonly used:

--top-bio: Shows the process that consumes the most block-level IO

--TOP-CPU: Shows the process that consumes the most CPU

--top-io: Shows the process that accounts for the most IO

--top-mem: Shows the process that consumes most memory

Dstat has too many options, and there are only a handful of them that can be viewed by man dstat.

1.1, Dstat with default options output

[[email protected] software]# dstat----total-cpu-usage---- -dsk/total- -net/total-  ---paging-- ---system--usr sys idl wai hiq siq| read  writ|  recv  send|  in   out | int   csw   0   0  99   0   0   0|   13k 5050b|   0     0 |   0      6B|  37    45  0   0 100    0   0   0|   0     0 |   60B  826B|   0     0 |  21     30  0   0 100   0   0    0|   0     0 |  60b  346b|   0      0 |  16    31  0   0 100    0   0   0|   0     0 |   60B  346B|   0     0 |  16     30  0   1  99   0   0    0|   0     0 |  60B  346B|    0     0 |  17    29  0    0 100   0   0   0|   0      0 |  60B  346B|   0      0 |  18    35  0   0 100   0   0    0|   0     0 |  60b  346b|    0     0 |  15    27  0    0 100   0   0   0|   0      0 |  60B  346B|   0      0 |  17    32  0   0 100    0   0   0|   0     0 |   60B  346B|   0     0 |  19     31  1   1  99   0   0    0|   0    16k|  60b  346b|   0      0 |  99    97

When running Dstat directly, the default is to output monitoring information at the "-cndgy" option with a frequency of 1 seconds, which is now a simple explanation for the output above.

----Total-cpu-usage----: Represents a usage statistic for all CPUs in the system

USR sys IDL Wai hiq siq| : Indicates the percentage of CPU used by the user process, the proportion of CPU used by the kernel process, the percentage of CPU idle state, the CPU waiting IO time, the number of times the CPU accepts the hard interrupt, and the number of times the CPU accepts soft interrupts.

-dsk/total-: Represents the output of all disk status information in the system

Read writ: Indicates the amount of data on which all disks have read requests, and the amount of data that has been written on all disks;

-net/total-: Represents the status information for all network cards in the system

Recv Send: Indicates the amount of data received by all network cards, the amount of data sent by all network cards

---paging--: indicates memory page usage

--system--: Indicates open system-level monitoring, including interrupts and context switches

In: Number of interrupts generated per second

CS:: Number of context switches generated per second

1.2. Identify the processes that occupy the highest system resources

[[email protected] software]# dstat -t --top-cpu --top-io -- TOP-MEM----System---- -most-expensive- ----most-expensive---- --most-expensive-  date /time   |  cpu process   |     i/o  process      |  memory process10-06 18:46:38|sshd: [ email protected]|bash         51k 1503b|mysqld       95.0M10-06 18:46:39|                 |sshd: [email protected] 491b  532b|mysqld       95.0M10-06 18:46:40|                 |sshd: [email protected] 184b  228b| mysqld       95.0m10-06 18:46:41|dd            19| dd           73m   72m|mysqld       95.0M10-06 18:46:42|flush-8:0    0.5|bash         100m  100m|mysqld      95.0m10-06  18:46:43|                 |sshd: [email protected] 191B  244B|mysqld       95.0m10-06 18:46:44|                 |sshd: [email protected] 184B  228B|mysqld       95.0m10-06 18:46:45|sshd: [email protected]|sshd: [email protected] 184b   228B|mysqld      95.0M10-06 18:46:46|                 |sshd: [email protected] 191b  244b|mysqld       95.0m10-06 18:46:47|jbd2/sda2-8  0.5|sshd: [email  protected] 184b  228b|mysqld      95.0m10-06 18:46:48|                 |sshd: [ email protected] 191b  244b|mysqld      95.0m10-06  18:46:49|                |sshd :  [email protected] 184b  228b|mysqld      95.0m10-06  18:46:50|dd           6.5|dd            93m   92m|mysqld      95.0m10-06  18:46:51|dd           6.0|dd          7168k 8192k|mysqld      95.0m

This makes it easier to identify the highest resource-intensive processes in your system and is useful when looking for server performance bottlenecks.


This article is from the "focus on operations, and Linux Dances" blog, please be sure to keep this source http://zhaochj.blog.51cto.com/368705/1660575

Linux system performance monitoring tools--htop and Dstat Introduction

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.