X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=smart-megaraid.sh;h=35db0c90208edc902a7273952f75e5489f81ed21;hb=0aa0b98bc51cfecf5809fe9736616a02ae21d809;hp=2cdc0c29366b04e546cb84cef4bf3495bde7102e;hpb=1eb4414aa101c026dadd39a9c0ba19e7c2a594a8;p=gnt-info diff --git a/smart-megaraid.sh b/smart-megaraid.sh index 2cdc0c2..35db0c9 100755 --- a/smart-megaraid.sh +++ b/smart-megaraid.sh @@ -4,10 +4,13 @@ # smart-megaraid.sh '^# 1' # default without args # SMART="-t long" smart-megaraid.sh # execute smart command -pattern='(^# [1-2]|test remaining|Hours|Error|Serial|Model|Firmware)' +pattern='(^# [1-2]|test remaining|Hours|Error|Serial|Model|Firmware|Load|Reallocated|Pending|failure)' test ! -z "$1" && pattern=$* +did_megaraid=0 + megaraid() { + test $did_megaraid -eq 1 && return drive=$1 nr=0 while [ $nr -lt 8 ] ; do @@ -15,6 +18,7 @@ megaraid() { smartctl -d megaraid,$nr -a /dev/$drive > /dev/shm/smart.$drive.$nr nr=`expr $nr + 1` done + did_megaraid=1 } test -r /proc/mdstat && cat /proc/mdstat @@ -22,9 +26,9 @@ test -r /proc/mdstat && cat /proc/mdstat lsblk --noheadings --scsi -o name | while read drive ; do test ! -z "$SMART" && smartctl $SMART /dev/$drive > /dev/shm/smart.$drive-out smartctl -a /dev/$drive > /dev/shm/smart.$drive - if ! grep -q '^# 1' /dev/shm/smart.$drive ; then + if egrep -q '(PERC|MegaRaid|DELL)' /dev/shm/smart.$drive ; then megaraid $drive fi done -egrep "$pattern" /dev/shm/smart.* | grep -v -- '- *0$' | cut -d. -f2- | sed -e 's/:/\t/' +egrep -i "$pattern" /dev/shm/smart.* | grep -v -- '- *0$' | cut -d. -f2- | sed -e 's/:/\t/'