答案1
使用下一个脚本查看谁读/写磁盘:
#!/bin/sh
dmesg -c >/dev/null 2>&1
echo 1 > /proc/sys/vm/block_dump
# Timeout
sleep 60
# Disable block dumping
echo 0 > /proc/sys/vm/block_dump
# Header
printf "%10s %15s %10s %10s %10s\n" CONUT COMMAND PID ACTION DEVICE
# Hide the eyes child! It gets ugly from here on
IFS="
"
for line in $(dmesg | awk '{if ( $3 ~ "READ" || $3 ~ "WRITE" ) { print $2 " " $3 " " $7}}'| sort |uniq -c |sort -nr );
do
num=$(echo $line | awk '{print $1}')
command=$(echo $line | awk '{ print $2 }' | sed -re 's/\([[:digit:]]+\)://')
pid=$(echo $line| awk -F'[()]' '{ print $2 }')
action=$(echo $line | awk '{ print $3 }')
device=$(echo $line | awk '{ print $4 }')
printf "%10s %15s %10s %10s %10s\n" "$num" "$command" "$pid" "$action" "$device"
done
# EOF
注意:根据操作系统和 dmesg 输出,您可能必须更改“for line in”行中的字段”