IO 查看
阿新 • • 發佈:2017-05-04
ice eric doc res net sel 詳細 adl var
gddg:~ # lsof /dev/xvda2 |head COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME init 1 root cwd DIR 202,240962 / init 1 root rtd DIR 202,240962 / init 1 root txt REG 202,240784193218 /sbin/init init 1 root mem REG 202,2191148063 /lib64/libdl-2.11.1.so init 1 root mem REG 202,216614548057 /lib64/libc-2.11.1.so init 1 root mem REG 202,22363848114 /lib64/libsepol.so.1 init 1 root mem REG 202,21139048115 /lib64/libselinux.so.1 init 1 root mem REG 202,21497978050 /lib64/ld-2.11.1.so kthreadd 2 root cwd DIR 202,240962 /
然後可以通過 lsof -p $pid 查看詳情
gddg:~ # lsof -p 32597 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME bash 32597 root cwd DIR 202,2409616097 /root bash 32597 root rtd DIR 202,240962 / bash 32597 root txt REG 202,258401632203 /bin/bash bash 32597 root mem REG 202,22939368125 /lib64/libncurses.so.5.6 bash 32597 root mem REG 202,216614548057 /lib64/libc-2.11.1.so bash 32597 root mem REG 202,2191148063 /lib64/libdl-2.11.1.so bash 32597 root mem REG 202,22635688153 /lib64/libreadline.so.5.2 bash 32597 root mem REG 202,21497978050 /lib64/ld-2.11.1.so bash 32597 root mem REG 202,221701616498 /var/run/nscd/passwd bash 32597 root mem REG 202,2256324149503 /usr/lib/locale/en_US.utf8/LC_CTYPE bash 32597 root mem REG 202,254149490 /usr/lib/locale/en_US.utf8/LC_NUMERIC bash 32597 root mem REG 202,22454133112 /usr/lib/locale/en_US.utf8/LC_TIME bash 32597 root mem REG 202,21163682149504 /usr/lib/locale/en_US.utf8/LC_COLLATE bash 32597 root mem REG 202,2286133111 /usr/lib/locale/en_US.utf8/LC_MONETARY bash 32597 root mem REG 202,257149408 /usr/lib/locale/en_US.utf8/LC_MESSAGES/SYS_LC_MESSAGES bash 32597 root mem REG 202,234149428 /usr/lib/locale/en_US.utf8/LC_PAPER bash 32597 root mem REG 202,277149438 /usr/lib/locale/en_US.utf8/LC_NAME bash 32597 root mem REG 202,2155133108 /usr/lib/locale/en_US.utf8/LC_ADDRESS bash 32597 root mem REG 202,259149407 /usr/lib/locale/en_US.utf8/LC_TELEPHONE bash 32597 root mem REG 202,223149429 /usr/lib/locale/en_US.utf8/LC_MEASUREMENT bash 32597 root mem REG 202,226050149293 /usr/lib64/gconv/gconv-modules.cache
2. cat /proc/$pid/io
如果內核版本大於2.6.20,通過cat /proc/pid/io 便可以獲取進程的io信息。詳細解釋
gddg:~ # cat /proc/4140/io rchar: 197448798054// 讀出的總字節數,read()或者pread()中的長度參數總和(pagecache中統計而來,不代表實際磁盤的讀入) wchar: 209896059897// 寫入的總字節數,write()或者pwrite()中的長度參數總和 syscr: 6491904// read()或者pread()總的調用次數 syscw: 13633940// write()或者pwrite()總的調用次數 read_bytes: 49616125952// 實際從磁盤中讀取的字節總數 write_bytes: 14038130688// 實際寫入到磁盤中的字節總數 cancelled_write_bytes: 2473984// 由於截斷pagecache導致應該發生而沒有發生的寫入字節數
3. block_dump
通過echo 1 > /proc/sys/vm/block_dump ,來把 block 讀寫(WRITE/READ/DIRTY)狀況 dump 到日誌裏,通過 dmesg 命令來查看
IO 查看