25 lines
564 B
Bash
Executable file
25 lines
564 B
Bash
Executable file
#!/bin/bash
|
|
|
|
if [[ -z $OUTPUT_DIR ]] ; then
|
|
source scan-dmidecode
|
|
fi
|
|
|
|
echo "#DEV:SERIAL" > $OUTPUT_DIR/disk.lst
|
|
for BLKDEV in /sys/block/sd*
|
|
do
|
|
DISK=`basename $BLKDEV`
|
|
SERIAL=`smartctl -i /dev/$DISK \
|
|
| grep -i 'serial number' \
|
|
| cut -d ':' -f 2 \
|
|
| sed 's/\s\+//' `
|
|
if [[ ! -z $SERIAL ]] ; then
|
|
echo "$DISK:$SERIAL"
|
|
echo "$DISK:$SERIAL" \
|
|
>> $OUTPUT_DIR/disk.lst
|
|
mkdir -p $OUTPUT_DIR/disk
|
|
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
|
|
|