dotfiles/.local/bin/scripts/diskcheck

37 lines
792 B
Plaintext
Raw Normal View History

2022-12-22 14:44:02 +00:00
#!/bin/bash
2023-11-04 18:08:39 +00:00
# troubleshoot disk issues and log results
2022-12-22 14:44:02 +00:00
# A more elaborate version of Troubleshoot.sh.
SUCCESS=0
E_DB=99 # Error code for missing entry.
declare -A address
date=$(date +%F)
hd_log="/tmp/${date}_HDs.log"
smartctl --scan | awk '{print $1}' > $hd_log
lspci | grep -i raid >> $hd_log
getArray () {
i=0
while read line # Read a line
do
array[i]=$line # Put it into the array
i=$(($i + 1))
done < $1
}
getArray $hd_log
for e in "${array[@]}"
do
if [[ $e =~ /dev/sd* || $e =~ /dev/hd* ]]
then
echo "smartctl -i -A $e" >> ${date}_Troubleshoot.log
smartctl -i -A $e >> ${date}_Troubleshoot.log # Run smartctl on all disks
fi
done
2023-11-04 18:08:39 +00:00
2022-12-22 14:44:02 +00:00
exit $? # In this case, exit code = 99, since that is function return.