X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=smart-megaraid.sh;h=35db0c90208edc902a7273952f75e5489f81ed21;hb=911e007b09c7af97fb501540fedcd8bf3a64d734;hp=449a24b17e93f7c336a2d955108580b5a3a0c5e0;hpb=fa340f461dd76a63ea3a374b3d2a851cd9009f54;p=gnt-info diff --git a/smart-megaraid.sh b/smart-megaraid.sh index 449a24b..35db0c9 100755 --- a/smart-megaraid.sh +++ b/smart-megaraid.sh @@ -1,26 +1,34 @@ #!/bin/sh -pattern='^# 1' -test ! -z "$1" && pattern=$1 +# Usage: +# 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|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 + test ! -z "$SMART" && smartctl -d megaraid,$nr $SMART /dev/$drive > /dev/shm/smart.$drive.$nr-out 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 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 -i "$pattern" /dev/shm/smart.* | grep -v -- '- *0$' | cut -d. -f2- | sed -e 's/:/\t/'