Bash 스크립트의 폴더에서 쓰고 읽은 총 데이터 추적

Bash 스크립트의 폴더에서 쓰고 읽은 총 데이터 추적

계산을 수행하는 bash 스크립트가 있습니다. 이 계산을 통해 최대 12GB의 큰 스크래치 파일이 생성되고 스크래치 폴더의 디스크 사용량은 약 30GB가 됩니다. 이 과정에서 총 얼마나 많은 데이터가 디스크에 기록되고, 총 얼마나 많은 데이터가 읽혀지는지 알고 싶습니다. 이는 디스크 IO 병목 현상을 이해하고 더 나은 스크래치 디스크 유형을 선택하는 데 도움이 됩니다.

질문: 특정 시간 간격 사이에 폴더에 기록된 데이터(MB 또는 GB)를 추적하세요. 또한 폴더에서 데이터를 읽는 사이의 시간 간격을 추적합니다.

내 스크립트의 현재 버전은 다음과 같습니다.

#!/bin/bash
# Running QM-JOB: helix HPC
    d="$1"  # .dal file
    m="$2"  # .mol file
    n="$3"  # number of CPU cores to be used for this calculation.
dir=$(pwd)
dt=$(date  +%Y-%m-%d:%H:%M:%S )
echo -e 'Job started @ '$dt'' >> /home/vayu/dalton/runlog.log
echo "-----------------------------------------------"
df -h /dev/md0
echo "-----------------------------------------------"

folder="<path/to/the/folder>" #Scratch folder

# start IO log on "scratch folder" (no idea how to implement this)
echo "-----------------------------------------------"

export OMP_NUM_THREADS=$n
source /opt/intel/parallel_studio_xe_2017.0.035/compilers_and_libraries_2017/linux/bin/compilervars.sh intel64
source /opt/intel/parallel_studio_xe_2017.0.035/compilers_and_libraries_2017/linux/mkl/bin/mklvars.sh intel64
source /opt/intel/parallel_studio_xe_2017.0.035/compilers_and_libraries_2017/linux/mpi/bin64/mpivars.sh intel64

./application_script "$d" "$m" "$n" "$folder"

    dt2=$(date '+%d/%m/%Y %H:%M:%S');

#stop "scratch folder" IO log
#print total data written in "scratch folder"
#print total data read from "scratch folder"

답변1

작업 전후에 /proc/self/io에서 I/O 통계를 읽고 "write_bytes" 및 "read_bytes" 줄에서 값을 뺄 수 있습니다. 자세한 내용은 "man proc"을 참조하세요. 단, 기기나 폴더에 따라 구분되지는 않습니다.

예는 다음과 같습니다.

#!/bin/bash
cat /proc/$$/io
dd if=/dev/zero of=/tmp/iotest bs=1M count=5
sync
cat /proc/$$/io
rm /tmp/iotest

관련 정보