2016-12-12 16:34:29 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-12-14 22:57:46 -06:00
|
|
|
if [[ -z $OUTPUT_DIR ]] ; then
|
2016-12-12 16:34:29 -06:00
|
|
|
source scan-dmidecode
|
|
|
|
fi
|
|
|
|
|
2016-12-13 18:31:14 -06:00
|
|
|
echo "#DEV:SERIAL" > $OUTPUT_DIR/disk.lst
|
|
|
|
for BLKDEV in /sys/block/sd*
|
2016-12-12 16:34:29 -06:00
|
|
|
do
|
2016-12-13 18:31:14 -06:00
|
|
|
DISK=`basename $BLKDEV`
|
|
|
|
SERIAL=`smartctl -i /dev/$DISK \
|
2016-12-12 18:41:53 -06:00
|
|
|
| grep -i 'serial number' \
|
|
|
|
| cut -d ':' -f 2 \
|
2016-12-13 18:31:14 -06:00
|
|
|
| sed 's/\s\+//' `
|
2016-12-14 22:57:46 -06:00
|
|
|
if [[ ! -z $SERIAL ]] ; then
|
2016-12-13 19:31:58 -06:00
|
|
|
echo "$DISK:$SERIAL"
|
2016-12-13 18:31:14 -06:00
|
|
|
echo "$DISK:$SERIAL" \
|
|
|
|
>> $OUTPUT_DIR/disk.lst
|
2016-12-13 19:31:58 -06:00
|
|
|
mkdir -p $OUTPUT_DIR/disk
|
2016-12-15 22:08:43 -06:00
|
|
|
smartctl --all /dev/$DISK > $OUTPUT_DIR/disk/$SERIAL.smart-all
|
|
|
|
ln -sf $OUTPUT_DIR/disk/$SERIAL.smart-all \
|
|
|
|
$OUTPUT_DIR/disk/$DISK.smart-all
|
2016-12-13 18:31:14 -06:00
|
|
|
fi
|
2016-12-12 16:34:29 -06:00
|
|
|
done
|
2016-12-12 16:35:27 -06:00
|
|
|
|