Hello everyone ！ I am a Sean！
Last time when it comes to iostat, Today, I'm going to talk about a command that looks like it iotop, The function is similar ,iotop It is used to monitor the disk I/O Usage status tools .
iotop（ Monitoring disks I/O Usage status tools ）
iotop command It is used to monitor the disk I/O In use top Class tools .iotop Have and top alike UI, These include PID、 user 、I/O、 Process and other relevant information .Linux Under the IO Statistical tools such as iostat,nmon Most of them can only count per Reading and writing of the device , If you want to know how each process works IO It's more troublesome , Use iotop Commands can be easily viewed .
iotop Use Python Written in language , requirement Python2.5（ And above ） and Linux kernel2.6.20（ And above ）.iotop Provide source code and rpm package , It can be downloaded from its official home page .
CentOS You can install ：
yum install iotop
-o： It only shows that there is io Process of operation -b： Batch display , No interaction , Mainly used to record to file . -n NUM： Show NUM Time , Mainly used in non interactive mode . -d SEC： interval SEC Once per second . -p PID： The process of monitoring pid. -u USER： Process users monitored .
iotop Common shortcut key
Left and right arrows ： Change the order , By default, press IO Sort . r： Change the sort order . o： It only shows that there is IO Output process . p： process / Thread display mode switch . a： Show cumulative usage q： sign out .
iotop Default display information iotop -t Add timestamp column iotop -d 2 -n 3 2s Refresh 1 Time , Refresh the information three times and finish iotop -u root Show only root Under the user process io Information iotop -a Display information in a cumulative manner , Data from iotop Command to start the calculation iotop -b > iotop.txt Non interactive mode , You can use redirection to record information continuously for a period of time iotop -k With kB Unit displays read / write data information iotop -q Column names are printed only on the first iteration iotop -qq Column names never print iotop -qqq Don't print I/O Abstract
Default display information
Total DISK READ Total DISK WRITE On the one hand, it represents the total read-write bandwidth between the process and the kernel thread , On the other hand, it also represents the kernel block device subsystem . Actual DISK READ Actual DISK WRITE Represents the kernel block device subsystem and the underlying hardware （HDD、SSD wait ） The corresponding actual disk I/O bandwidth .
TID Thread number or process number PRIO Thread runtime I/O priority USER The user the process belongs to DISK READ The amount of data read during the refresh interval DISK WRITE The amount of data written during the refresh interval SWAPIN Exchange usage per process IO Of each process I/O utilization , Contains disks and switches COMMAND Process name
Add timestamp column
With kB Unit displays read / write data information
Data viewing skills
Actually iotop The message displayed by the command is very obvious , Be clear at a glance , I usually use it to locate which process has occupied the disk IO, Last time iostat We can only see the disk of the system initially IO Whether the bottleneck has been reached , But it doesn't have to be a bottleneck , It's the result of some weird process , It can be used iotop Continuously observe the process level of IO situation , You can quickly find out which guy is making a monkey out of .
Mind map summary
Today's sharing is here ！ Thank you for reading ！ It's not easy to code words , If this article helps you , Do me a favor ~ ha-ha .
The mind map will be shared after the end of the performance monitoring command series , Welcome to the official account “ The programmer Sean”.