#!/bin/bash
# ---------------------------------------------------------------------------
# drive-info.sh
# gather info about drive errors and power cycle counts, outputting the drives sd name and slot
# Copyright 2021, Mike McPhee <mmcphee@45drives.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.############
for i in `ls /dev | grep -i sd | grep -v '[0-9]$' | awk '{print $1}'`; do
        echo -e "\nDevice: " $i && \
        echo -n "Slot: " && \
        ls -l /dev/disk/by-vdev/ | grep -wi $i | awk '{print $9}' && \
        smartctl -x /dev/$i | grep -i 'power_cycle_count\|offline_uncorrectable\|current_pending_sector'
done
