久综合色-久综合网-玖草影视-玖草资源在线-亚洲黄色片子-亚洲黄色片在线观看

Hello! 歡迎來到小浪云!


如何尋找IO殺手進程


avatar
小浪云 2024-12-08 148

linux下可以通過iostat查看目前主機總的io使用情況,不過當通過top等命令查看時,發現cpu wait占多過多,想定位具體是哪些程序占用了io,本篇就通過一些常用的手段進行匯總下。

一、top下的wait狀狀

wa = I/O waiting ,wa指的是CPU等待磁盤寫入完成的時間,就是說前提是要進行IO操作,在進行IO操作的時候,CPU等待時間。如一個程序執行的最后,從系統空間到dst硬盤空間的時候,如果程序是阻塞的,那么這個時候cpu就要等待數據寫入磁盤才能完成寫操作了。所以這個時候cpu等待的時間就是wa。

所以wa狀態占比越高,證明IO越繁忙。

我們可以通過以下指令查看當前io的總終態:

[root@361way ~]# sar -u 2 5 Linux 2.6.32-431.29.2.el6.x86_64 (361way) 01/25/2015 _x86_64_ (1 CPU) 06:59:58 PM CPU %user %nice %system %iowait %steal %idle 07:00:00 PM all 1.00 0.00 0.50 0.00 0.00 98.50 07:00:02 PM all 5.05 0.00 1.52 1.01 0.00 92.42 07:00:04 PM all 0.50 0.00 0.50 0.00 0.00 98.99 07:00:06 PM all 0.00 0.00 0.00 0.00 0.00 100.00 07:00:08 PM all 0.50 0.00 0.00 0.50 0.00 98.99 Average: all 1.41 0.00 0.50 0.30 0.00 97.79 [root@361way ~]# vmstat 2 5 procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 0 98488 209916 218256 0 0 8 28 11 10 5 0 95 0 0 0 0 0 98480 209916 218256 0 0 0 0 155 198 0 0 100 0 0 0 0 0 98496 209916 218256 0 0 0 0 141 191 1 0 99 0 0 0 0 0 98496 209916 218256 0 0 0 0 142 189 0 1 99 0 0 0 0 0 98512 209916 218256 0 0 0 0 152 189 0 0 100 0 0 [root@361way ~]# iostat -x 1 2 Linux 2.6.32-431.29.2.el6.x86_64 (361way) 01/25/2015 _x86_64_ (1 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 4.71 0.00 0.42 0.24 0.00 94.63 Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util xvda 0.00 0.13 0.31 0.91 14.08 8.30 18.39 0.01 11.84 1.38 0.17 xvdb 0.00 2.12 0.05 3.90 1.52 48.10 12.57 0.05 11.84 0.57 0.22 avg-cpu: %user %nice %system %iowait %steal %idle 0.00 0.00 0.00 0.00 0.00 100.00 Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util xvda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 xvdb 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 
二、找出IO繁忙的進程

可以通過linux下最常用的兩個命令top、ps找出目前正在占用IO的進程。在進行下一步之前我了解一下D狀態,ps命令中查看的狀態有D、R、S、Z、T ,D狀態指不可中斷睡眠 (通常是在IO操作) 收到信號不喚醒和不可運行, 進程必須等待直到有中斷發生。

找出當前進程為D的狀態:

while true; do date; ps auxf | awk '{if($8=="D") print $0;}'; sleep 1; don 

上面的這個操作有一個缺點,就是一旦匹配到一個進程為D的,就開始重新執行下一個循環。而想查看所有當于D狀態的進程,可以將其改為如下:

watch -d -n 1 “(ps aux | awk ‘$8 ~ /D/ { print $0 }’)”

如下,是我在執行一個大文件的cp時,通過上面的指令查看到的結果:

如何尋找IO殺手進程

除此之外,還可以通過專用工具去查看,如iotop或latencytop。這里以iotop為例,執行后會顯示當前的讀寫速度及每個進程占用的速度。執行后可以按o僅顯示占用IO的進程:

[root@361way ~]# iotop --help Usage: /usr/sbin/iotop [OPTIONS] DISK READ and DISK WRITE are the block I/O bandwidth used during the sampling period. SWAPIN and IO are the percentages of time the thread spent respectively while swapping in and waiting on I/O more generally. PRIO is the I/O priority at which the thread is running (set using the ionice command). Controls: left and right arrows to change the sorting column, r to invert the sorting order, o to toggle the --only option, p to toggle the --processes option, a to toggle the --accumulated option, q to quit, any other key to force a refresh. Options: --version show program's version number and exit -h, --help show this help message and exit -o, --only only show processes or threads actually doing I/O -b, --batch non-interactive mode -n NUM, --iter=NUM number of iterations before ending [infinite] -d SEC, --delay=SEC delay between iterations [1 second] -p PID, --pid=PID processes/threads to monitor [all] -u USER, --user=USER users to monitor [all] -P, --processes only show processes, not all threads -a, --accumulated show accumulated I/O instead of bandwidth -k, --kilobytes use kilobytes instead of a human friendly unit -t, --time add a timestamp on each line (implies --batch) -q, --quiet suppress some lines of header (implies --batch) 

相關閱讀

主站蜘蛛池模板: 不卡一级aaa全黄毛片 | 三级黄色毛片网站 | 人久热欧美在线观看量量 | 视频一区二区在线 | 一区二区三区四区视频 | 男女牲高爱潮免费视频男女 | 国产精品亚洲综合久久 | 免费看一级欧美激情毛片 | 国产精品成人影院 | japanesehd国产在线无毒不卡 | 成人午夜视频一区二区国语 | 国产免费午夜a无码v视频 | 日本大黄网站 | 国产或人精品日本亚洲77美色 | 欧美成人久久久免费播放 | 欧美成人毛片一级在线 | 久久99网站 | 欧美视频一级 | 欧美视频三区 | 色射网| 美女一级视频 | 国产人做人爱视频精品 | 怡红院免费的全部视频国产a | 国产在线精品观看 | 国产性色| 国产三级做爰高清在线 | 日日摸夜夜搂人人要 | 亚洲欧美一级视频 | 成人午夜看片在线观看 | 免费在线亚洲视频 | 99精品久久久久久久免费看蜜月 | 亚洲一区二区精品 | 欧美成人午夜不卡在线视频 | 美国成人免费视频 | 青木玲中文字幕一区二区 | 特黄特黄aaaa级毛片免费看 | 国产精品免费一级在线观看 | 日韩欧美一区二区三区免费观看 | 中文国产成人精品久久久 | 欧美一级在线播放 | 91久久精品青青草原伊人 |