smartmontools (smartctl)

#!/bin/bash

# ensure that this script is run by root
if [ $(id -u) -ne 0 ]; then
sudo $0
  exit
fi

apt-get install -y smartmontools --no-install-recommends
>

Show health from all SAS devices

for DISK in $(lsblk -S | grep sas | cut -d" " -f1); do
    smartctl -d scsi -H /dev/${DISK}
done

Check all discs

for SERVER in ceph{1..6}-stage.example.com; do
    for DISK in sd{a..z}; do
        echo ${SERVER} ${DISK}
        #ssh ${SERVER} sudo smartctl --smart=on -t short /dev/${DISK}
        ssh ${SERVER} sudo smartctl --smart=on -t offline /dev/${DISK}
        #ssh ${SERVER} sudo smartctl -a /dev/${DISK} | grep -i failure
    done
    echo
done

Enable SMART on device

sudo smartctl -s on /dev/sdb

Show device SMART Health status

sudo smartctl -H /dev/sda

Show device selftest log

smartctl -l selftest /dev/sdb

Get info from usb data

sudo smartctl -d sat -a /dev/sdb

Test

smartctl -t short /dev/sdb
smartctl -t offline /dev/sdb

Calculate total writen GB from a SSD

echo "Total GB written: $(echo "scale=3; $(sudo /usr/sbin/smartctl -A /dev/sda | grep "Total_LBAs_Written" | awk '{print $10}') * 512 / $((1024*1024*1024))" | bc)"

SAT pass-through Linux UAS blacklisting

lsusb  | grep Seagate
echo "0x0bc2:0xab28:u" | sudo  tee > /sys/module/usb_storage/parameters/quirks
smartctl -a /dev/sdd
smartctl -a -d sat  /dev/sdd

Links
https://www.smartmontools.org/wiki/Supported_USB-Devices