User Tools

Site Tools


freebsd:zfshealthscript

This is an old revision of the document!


ZFS Health Scripts

Checkpool

  • Check all pools and email operator if errors detected
check_pool.sh
#!/bin/sh
 
RESULT="`zpool status | grep errors`"
ZPOOLSTATUS="`zpool status`"
HOSTNAME="`hostname`"
TMPFILE="/tmp/zfs_report"
#CHANGE ME
MAILTO="-@-"
#CHANGE ME
RESULT_GOOD="errors: No known data errors"
 
if [ "${RESULT}" = "${RESULT_GOOD}" ]
then
        echo "no errors"
        echo "no ZFS Errors on ${HOSTNAME}" > ${TMPFILE}
        echo "${ZPOOLSTATUS}" >> ${TMPFILE}
        #mail -s "ZFS pool Report" ${MAILTO} < ${TMPFILE}
else
        echo "errors detected"
        echo "no ZFS Errors on ${HOSTNAME}" > ${TMPFILE}
        echo "${ZPOOLSTATUS}" >> ${TMPFILE}
        mail -s "ERRORS DETECTED!!! ZFS pool Report" ${MAILTO} < ${TMPFILE}
fi

ZFS Scrub

zfsScrubOnSat.sh
#!/bin/sh
 
WEEKDAY="`date | cut -d " " -f1`"
 
if [ ${WEEKDAY} = "Sat" ]
then
        echo "It's Saturday Running Scrub"
        zpool scrub tank
else
        echo "It's not Saturday, exiting"
fi
freebsd/zfshealthscript.1457723686.txt.gz · Last modified: 2016/03/11 13:14 by tschulz