이 낙서 (myio.sh) 플레이 자유롭게 :
#!/bin/bash
TEMPFILE=$(tempfile) # create temp file for results
trap "rm $TEMPFILE; exit 1" SIGINT # cleanup after Ctrl+C
SECONDS=0 # reset timer
[email protected] & # execute command in background
IO=/proc/$!/io # io data of command
while [ -e $IO ]; do
cat $IO > "$TEMPFILE" # "copy" data
sed 's/.*/& Bytes/' "$TEMPFILE" | column -t
echo
sleep 1
done
S=$SECONDS # save timer
echo -e "\nPerformace after $S seconds:"
while IFS=" " read string value; do
echo $string $(($value/1024/1024/$S)) MByte/s
done < "$TEMPFILE" | column -t
rm "$TEMPFILE" # remove temp file
구문 : ./myio.sh <your command>
예 : 루트로
./myio.sh dd if=/dev/zero of=/dev/null bs=1G count=4096
- :
./myio.sh dd if=/dev/sda1 of=/dev/null bs=1M count=4096
마지막 예제에서 dd의 of=
을 변경하십시오. 알고있는 경우에만 변경하십시오.
이 간단한 스크립트를 사용하면 이미 실행중인 프로세스와 IO를 볼 수 있습니다.
구문 : pio.sh PID
#!/bin/bash
[ "$1" == "" ] && echo "Error: Missing PID" && exit 1
IO=/proc/$1/io # io data of PID
[ ! -e "$IO" ] && echo "Error: PID does not exist" && exit 2
I=3 # interval in seconds
SECONDS=0 # reset timer
echo "Watching command $(cat /proc/$1/comm) with PID $1"
IFS=" " read rchar wchar syscr syscw rbytes wbytes cwbytes < <(cut -d " " -f2 $IO | tr "\n" " ")
while [ -e $IO ]; do
IFS=" " read rchart wchart syscrt syscwt rbytest wbytest cwbytest < <(cut -d " " -f2 $IO | tr "\n" " ")
S=$SECONDS
[ $S -eq 0 ] && continue
cat << EOF
rchar: $((($rchart-$rchar)/1024/1024/$S)) MByte/s
wchar: $((($wchart-$wchar)/1024/1024/$S)) MByte/s
syscr: $((($syscrt-$syscr)/1024/1024/$S)) MByte/s
syscw: $((($syscwt-$syscw)/1024/1024/$S)) MByte/s
read_bytes: $((($rbytest-$rbytes)/1024/1024/$S)) MByte/s
write_bytes: $((($wbytest-$wbytest)/1024/1024/$S)) MByte/s
cancelled_write_bytes: $((($cwbytest-$cwbytes)/1024/1024/$S)) MByte/s
EOF
echo
sleep $I
done
각 값은 평균이 어떤'/ proc 디렉토리//io' 및 http://stackoverflow.com/a/3634088/3776858 –
Cyrus