3 ######################################################################
6 # the SCSI devices to measure
7 scsidevs=${scsidevs:-"/dev/sde /dev/sdh"}
9 # result file prefix. date/time+hostname makes unique
10 # NB ensure the path exists if it includes subdirs
11 rslt=${rslt:-"/tmp/sgpdd_survey_`date +%F@%R`_`uname -n`"}
13 # what to do (read or write)
16 # total size per device (MBytes)
17 # NB bigger than device cache is good
20 # record size (KBytes)
24 # Concurrent regions per device
28 # threads to share between concurrent regions per device
29 # NB survey skips over #thr < #regions and #thr/#regions > SG_MAX_QUEUE
33 #####################################################################
34 # leave the rest of this alone unless you know what you're doing...
36 # sgp_dd's idea of disk sector size (Bytes)
38 # and max # threads one instance will spawn
41 # map given device names into SG device names
44 for d in $scsidevs; do
45 devs[$i]=`sg_map | awk "{if ($ 2 == \"$d\") print $ 1}"`
46 if [ -z "$devs[$i]" ]; then
47 echo "Can't find SG device for $d"
60 if [ "$1" = "-n" ]; then
65 echo $minusn "$*" >> $rsltf
69 for ((rsz=$rszlo;rsz<=$rszhi;rsz*=2)); do
70 for ((crg=$crglo;crg<=$crghi;crg*=2)); do
71 for ((thr=$thrlo;thr<=$thrhi;thr*=2)); do
72 if ((thr < crg || thr/crg > SG_MAX_QUEUE)); then
77 blocks=$((size*((1024*1024)/bs)/crg))
79 # show computed parameters
80 actual_rsz=$((bpt*bs/1024))
81 actual_size=$((bs*count*crg/1024))
82 str=`printf 'total_size %8dK rsz %4d crg %5d thr %5d ' \
83 $((actual_size*ndevs)) $actual_rsz $((crg*ndevs)) $((thr*ndevs))`
84 echo "==============> $str" >> $workf
85 print_summary -n "$str"
86 freemem=`awk < /proc/meminfo '/^MemTotal:/ {printf "%d\n", $2}'`
87 if (((actual_rsz*thr/crg + 64)*crg*ndevs > freemem)); then
88 print_summary "ENOMEM"
92 for action in $actions; do
93 print_summary -n "$action "
94 echo "=====> $action" >> $workf
98 for ((i=0;i<ndevs;i++)); do
100 if [ $action = read ]; then
109 for ((j=0;j<crg;j++)); do
110 sgp_dd 2> ${tmpf}_${i}_${j} \
111 $inf $outf ${skip}=$((1024+j*blocks)) \
112 thr=$((thr/crg)) count=$count bs=$bs bpt=$bpt time=1&
117 # collect/check individual stats
120 for ((i=0;i<ndevs;i++)); do
121 for ((j=0;j<crg;j++)); do
122 rtmp=${tmpf}_${i}_${j}
123 if grep 'time to transfer data' $rtmp > /dev/null 2>&1; then
127 cat ${rtmp} >> $workf
131 if ((ok != ndevs*crg)); then
132 print_summary -n "$((ndevs*crg - ok)) failed "
134 # compute MB/sec from elapsed
135 bw=`awk "BEGIN {printf \"%7.2f MB/s\", $actual_size * $ndevs / (( $t1 - $t0 ) * 1024); exit}"`
136 # compute MB/sec from nregions*slowest
138 '/time to transfer data/ {mb=$8/1.048576; if (n == 0 || mb < min) min = mb; n++}\
139 END {printf "%5d x %6.2f = %7.2f MB/s", n, min, min * n}'`
140 print_summary -n "$bw $check "