Re: md devices: Suggestion for in place time and checksum within the RAID

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Keld Simonsen schrieb:
Interesting! I would like to see your scripts....
I did not realize how OLD that script was until I saw it today, I could not leave it that way, here is a revised and less embarrassing version, easy to extent to bang you with emails on a raid error too, but southpark is on TV now:

#!/bin/sh
HEALTHFILE="/tmp/healthcheck.mdstat"
HARDDRIVES="/dev/sda /dev/sdb /dev/sdc /dev/sdd"
SENDEMAILCOMMAND="/usr/local/sbin/sendEmail.pl <commandline-here>"
[ -f ${HEALTHFILE}.1 ] && /bin/rm -f ${HEALTHFILE}.1
[ -f ${HEALTHFILE}.0 ] && /bin/mv ${HEALTHFILE}.0 ${HEALTHFILE}.1
/usr/bin/touch ${HEALTHFILE}.1
/bin/cat /proc/mdstat > ${HEALTHFILE}.0
/usr/bin/diff ${HEALTHFILE}.0 ${HEALTHFILE}.1 > /dev/null
if [ $? == 1 ] ; then
  ${SENDEMAILCOMMAND} -u "RAID Status" < ${HEALTHFILE}.0
fi

HEALTHFILE="/var/log/healthcheck.smartctl"
[ -f ${HEALTHFILE}.1 ] && /bin/rm -f ${HEALTHFILE}.1
[ -f ${HEALTHFILE}.0 ] && /bin/mv ${HEALTHFILE}.0 ${HEALTHFILE}.1
/usr/bin/touch ${HEALTHFILE}.1
echo "SMART info:"> ${HEALTHFILE}.0
EMAILSUBJECT="SMART Status, Reallocated Sector Count"
for X in ${HARDDRIVES} ; do
Y="`/usr/local/sbin/smartctl --all ${X} | /bin/grep -i Reallocated_Sector_Ct`"
  if [ "${Y}" != "" ] ; then
    /bin/echo "${X}     ${Y}">> ${HEALTHFILE}.0
if [ "`/usr/local/sbin/smartctl --all ${X} | /bin/grep -o 'No Errors Logged'`" == "No Errors Logged" ] ; then
      /bin/echo "${X}    No Errors Logged">> ${HEALTHFILE}.0
    else
      EMAILSUBJECT="SMART ERRORS LOGGED, Reallocated Sector Count"
      [ -f ${HEALTHFILE}.1 ] && /bin/rm -f ${HEALTHFILE}.1
      /usr/bin/touch ${HEALTHFILE}.1
/bin/echo "------------------------------------------------------------------------">> ${HEALTHFILE}.0
      /bin/echo "${X}">> ${HEALTHFILE}.0
/usr/local/sbin/smartctl --all ${X} | /bin/grep -i -A 999 "SMART Error Log" >> ${HEALTHFILE}.0 /bin/echo "------------------------------------------------------------------------">> ${HEALTHFILE}.0
    fi
  fi
done
/usr/bin/diff ${HEALTHFILE}.0 ${HEALTHFILE}.1 > /dev/null
if [ $? == 1 ] ; then
  ${SENDEMAILCOMMAND} -u "${EMAILSUBJECT}" < ${HEALTHFILE}.0
fi

regards,

Joachim Otahal
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux