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