summary and csv summary

This commit is contained in:
Sandino Araico Sanchez 2016-12-15 22:08:43 -06:00
parent 5321e0a852
commit df8cfd506a
3 changed files with 76 additions and 20 deletions

View file

@ -17,9 +17,9 @@ do
echo "$DISK:$SERIAL" \
>> $OUTPUT_DIR/disk.lst
mkdir -p $OUTPUT_DIR/disk
smartctl --all /dev/$DISK > $OUTPUT_DIR/disk/$SERIAL.smartctl-all
ln -sf $OUTPUT_DIR/disk/$SERIAL.smartctl-all \
$OUTPUT_DIR/disk/$DISK.smartctl-all
smartctl --all /dev/$DISK > $OUTPUT_DIR/disk/$SERIAL.smart-all
ln -sf $OUTPUT_DIR/disk/$SERIAL.smart-all \
$OUTPUT_DIR/disk/$DISK.smart-all
fi
done

View file

@ -5,22 +5,35 @@ if [[ -z $OUTPUT_DIR ]] ; then
fi
source test-variables
if [[ ! -f $OUTPUT_DIR/disk.lst ]] ; then
scan-hdd
if [[ "$1" != "skip-scan" ]] ; then
scan-hdd # Always rescan
fi
if [[ "$1" == "force" ]] ; then
rm -f $OUTPUT_DIR/disk/*.badblocks.result
fi
MAXWAIT=9
JOBS=0
echo -n "BEGIN: " >> $OUTPUT_DIR/badblocks.log
date >> $OUTPUT_DIR/badblocks.log
for DISK in `cat $OUTPUT_DIR/disk.lst \
| sed 's/#.*$//' \
| cut -d ':' -f 1`
do
JOBS=$(( JOBS + 1 ))
SERIAL=`cat $OUTPUT_DIR/disk.lst \
| grep $DISK \
| cut -d ':' -f 2`
if [[ -f $OUTPUT_DIR/disk/$SERIAL.badblocks.result ]] ; then
cat $OUTPUT_DIR/disk/$SERIAL.badblocks.result \
| sed 's/Process [0-9]\+/Test complete/'
cat $OUTPUT_DIR/disk/$SERIAL.badblocks.result \
| sed 's/Process [0-9]\+/Result found/' \
>> $OUTPUT_DIR/badblocks.log
continue
fi
JOBS=$(( JOBS + 1 ))
echo -n "Process $JOBS: Testing disk $DISK with badblocks ..."
echo -n "Process $JOBS : Disk $DISK : " >> $OUTPUT_DIR/badblocks.log
COUNT=0
TEST_PID=
wrapper-badblocks $DISK $SERIAL $JOBS &
@ -36,26 +49,58 @@ do
if [[ -f /run/$SERIAL.badblocks.pid ]] ; then
TEST_PID=`cat /run/$SERIAL.badblocks.pid`
echo " PID $TEST_PID"
echo " PID $TEST_PID" >> $OUTPUT_DIR/badblocks.log
break
fi
echo -n '.'
done
if [[ -z $TEST_PID ]] ; then
echo "${RED}Process not running.${OFF}"
echo "${RED}Process not running.${OFF}" \
>> $OUTPUT_DIR/badblocks.log
fi
done
JOBS_WAITING=$JOBS
JOBS_OLD=
JOBS_OLD=0
COUNT=0
NOTICE_INTERVAL=60
while (( $JOBS_WAITING > 0 )) ; do
sleep 1
JOBS_WAITING=`jobs -r | wc -l`
if [[ $JOBS_WAITING != $JOBS_OLD ]] ; then
#if (( $JOBS_WAITING > 0 )) ; then
# echo "$JOBS_WAITING jobs still running..."
#fi
JOBS_OLD=$JOBS_WAITING
JOBS_FINISHED=$(( JOBS - JOBS_WAITING ))
if (( $COUNT % $NOTICE_INTERVAL == 0 )) ; then
if [[ $JOBS_WAITING != $JOBS_OLD ]] ; then
echo "$JOBS_FINISHED jobs finished, $JOBS_WAITING jobs still running..."
JOBS_OLD=$JOBS_WAITING
fi
fi
COUNT=$(( COUNT + 1 ))
done
echo -n "END: " >> $OUTPUT_DIR/badblocks.log
date >> $OUTPUT_DIR/badblocks.log
echo >> $OUTPUT_DIR/badblocks.log
echo "=====> SUMMARY <====="
echo "DISK|SERIAL|RESULT|COMMENT" > $OUTPUT_DIR/badblocks.csv
for DISK in `cat $OUTPUT_DIR/disk.lst \
| sed 's/#.*$//' \
| cut -d ':' -f 1`
do
SERIAL=`cat $OUTPUT_DIR/disk.lst \
| grep $DISK \
| cut -d ':' -f 2`
#echo "looking for $OUTPUT_DIR/disk/$SERIAL.badblocks.csv"
if [[ -f $OUTPUT_DIR/disk/$SERIAL.badblocks.result ]] ; then
cat $OUTPUT_DIR/disk/$SERIAL.badblocks.result
fi
if [[ -f $OUTPUT_DIR/disk/$SERIAL.badblocks.csv ]] ; then
cat $OUTPUT_DIR/disk/$SERIAL.badblocks.csv \
>> $OUTPUT_DIR/badblocks.csv
fi
done
echo "=====> CSV SUMMARY <====="
cat $OUTPUT_DIR/badblocks.csv \
| sed "s/^\([^|]\+\)/${BLD}\1${OFF}/ ; s/OK/${GRN}OK${OFF}/ ; s/FAIL/${RED}FAIL${OFF}/ ; s/RESULT/${BLD}RESULT${OFF}/ " # ; s/|/ : /g"

View file

@ -40,17 +40,18 @@ if [[ $DISK_SERIAL != $SERIAL ]] ; then
exit 15
fi
#BLK_SIZE=`cat /sys/block/$DISK/queue/physical_block_size`
BLK_SIZE=`cat /sys/block/$DISK/queue/max_hw_sectors_kb`
#TPATTERN=0x55
TPATTERN=0xaa
LST_BLCK=20000000
BLK_SIZE=`cat /sys/block/$DISK/queue/physical_block_size`
MAX_SAME=`cat /sys/block/$DISK/queue/write_same_max_bytes`
CONCU=$(( MAX_SAME / ( BLK_SIZE / 2 ) ))
[[ $CONCU == 0 ]] && CONCU=65535
[[ $CONCU == 0 ]] && CONCU=32768
BEGIN=`date +%s`
badblocks -b $BLK_SIZE -c $CONCU -e 1 -t 0xaa \
badblocks -b $BLK_SIZE -c $CONCU -e 1 -t $TPATTERN \
-o $OUTPUT_DIR/disk/$SERIAL.badblocks \
-svw /dev/$DISK \
1000000 \
-svw /dev/$DISK $LST_BLCK \
2> $OUTPUT_DIR/disk/$SERIAL.badblocks.out &
TEST_PID=`jobs -p %+`
echo $TEST_PID > /run/$SERIAL.badblocks.pid
@ -83,16 +84,22 @@ if [[ -n $ERROR ]] ; then
>> $OUTPUT_DIR/disk/$SERIAL.badblocks.result
echo $RES_FAIL \
>> $OUTPUT_DIR/disk/$SERIAL.badblocks.result
echo "$DISK|$SERIAL|FAIL|$ERROR" \
> $OUTPUT_DIR/disk/$SERIAL.badblocks.csv
elif [[ -z $BADBLOCK ]] ; then
echo -n "disk $DISK $SERIAL tested in ${DURATION}s : " \
>> $OUTPUT_DIR/disk/$SERIAL.badblocks.result
echo $RES_OK \
>> $OUTPUT_DIR/disk/$SERIAL.badblocks.result
echo "$DISK|$SERIAL|OK|${DURATION}s" \
> $OUTPUT_DIR/disk/$SERIAL.badblocks.csv
else
echo -n "bad block $BADBLOCK found in disk $DISK $SERIAL : " \
echo -n "Bad block $BADBLOCK found in disk $DISK $SERIAL : " \
>> $OUTPUT_DIR/disk/$SERIAL.badblocks.result
echo $RES_FAIL \
>> $OUTPUT_DIR/disk/$SERIAL.badblocks.result
echo "$DISK|$SERIAL|FAIL|Bad block $BADBLOCK" \
> $OUTPUT_DIR/disk/$SERIAL.badblocks.csv
fi
ln -sf $OUTPUT_DIR/disk/$SERIAL.badblocks \
@ -103,10 +110,14 @@ ln -sf $OUTPUT_DIR/disk/$SERIAL.badblocks.out \
# $OUTPUT_DIR/disk/$DISK.badblocks.ret
ln -sf $OUTPUT_DIR/disk/$SERIAL.badblocks.result \
$OUTPUT_DIR/disk/$DISK.badblocks.result
ln -sf $OUTPUT_DIR/disk/$SERIAL.badblocks.csv \
$OUTPUT_DIR/disk/$DISK.badblocks.csv
if [[ -f $OUTPUT_DIR/disk/$SERIAL.smart.error ]] ; then
ln -sf $OUTPUT_DIR/disk/$SERIAL.smart.error \
$OUTPUT_DIR/disk/$DISK.smart.error
fi
cat $OUTPUT_DIR/disk/$SERIAL.badblocks.result
cat $OUTPUT_DIR/disk/$SERIAL.badblocks.result \
>> $OUTPUT_DIR/badblocks.log