Check smartctl indicating disk failure (or pre-failure)

With several hard drives I don't want to have to run commands on them one at a time, and smartctl doesn't seem to have a built in way to run on all disks at once.

So just make these simple bash scripts (the first to run long tests and the second to print out the smartctl stats, make them executable with chmod +x smartctl_all_test.sh and run them!

Here's a script for quickly starting self-tests for many drives at once:

#!/bin/bash
for drive in `ls /dev/sd? /dev/nvme0n?`; do
  echo $drive;
  smartctl -t long $drive;
done
smartctl_all_test.sh

And another to see the most critical indications of failure (in my opinion)

#!/bin/bash
for drive in `ls /dev/sd? /dev/nvme0n?`; do
  echo $drive;
  smartctl -a $drive | grep 'Reallocated_Sector_Ct\|Reallocated_Event_Count\|Offline_Uncorrectable\|Error_Rate\|Power_On_Hours\|Wear_Leveling_Count\|Used_Rsvd_Blk_Cnt_Tot\|Available Spare\|Percentage Used\|Media and Data Integrity Errors';
  echo; echo;
done
smartctl_all_report.sh