X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=smart-megaraid.sh;h=1e976f4f86a4e1328bb788ec3835fb3258a6bfe1;hb=985e9c8ea3e02f40bffeca33275e0db76d1f3ea4;hp=8113f5846fa733693951f46dfff99e6a3a47f34e;hpb=01d6bd55fe58f933d06a9c67c3cc7fb35cd780ae;p=gnt-info diff --git a/smart-megaraid.sh b/smart-megaraid.sh index 8113f58..1e976f4 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' -test ! -z "$1" && pattern=$1 +pattern='(^# [1-2]|test remaining|Hours|Error|Serial|Model|Firmware|Load)' +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,11 +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 -grep "$pattern" /dev/shm/smart.* | cut -d. -f2- | sed -e 's/:/\t/' - - +egrep "$pattern" /dev/shm/smart.* | grep -v -- '- *0$' | cut -d. -f2- | sed -e 's/:/\t/'