Changeset 0fe982e


Ignore:
Timestamp:
07/31/13 09:03:27 (14 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
8c2bd1a, 4f9718b
Parents:
7d22135
Message:

Add email notification functionality to the automated snapshots

Location:
src-sh/lpreserver/backend
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src-sh/lpreserver/backend/functions.sh

    r7814c14 r0fe982e  
    1313DBDIR="/var/db/lpreserver" 
    1414if [ ! -d "$DBDIR" ] ; then mkdir -p ${DBDIR} ; fi 
     15CMDLOG="${DBDIR}/lp-lastcmdout" 
     16LOGDIR="/var/log" 
     17export DBDIR LOGDIR PROGDIR CMDLOG 
    1518 
    16 LOGDIR="/var/log" 
    17 export DBDIR LOGDIR PROGDIR 
     19MSGQUEUE="" 
     20export MSGQUEUE 
    1821 
    1922#Set our Options 
     
    5558  fi 
    5659  zdate=`date +%Y-%m-%d-%H-%M-%S` 
    57   zfs snapshot $flags ${1}@$2${zdate} 
     60  zfs snapshot $flags ${1}@$2${zdate} >${CMDLOG} 2>${CMDLOG} 
    5861  return $? 
    5962} 
     
    7073     flags="-r" 
    7174  fi 
    72   zfs destroy -r ${1}@${2} 
     75  zfs destroy -r ${1}@${2} >${CMDLOG} 2>${CMDLOG} 
    7376  return $? 
    7477} 
     
    125128   echo "`date`: $@" >> ${LOGDIR}/lpreserver.log  
    126129} 
     130 
     131# E-Mail a message to the set addresses 
     132# 1 = subject tag 
     133# 2 = Message 
     134email_msg() { 
     135   if [ -z "$EMAILADDY" ] ; then return ; fi 
     136   echo -e "$2"  | mail -s "Life-Preserver `hostname`: $1" $EMAILADDY 
     137} 
     138 
     139queue_msg() { 
     140  MSGQUEUE="$MSGQUEUE $@"  
     141} 
     142 
     143echo_queue_msg() { 
     144  echo -e "$MSGQUEUE" 
     145} 
  • src-sh/lpreserver/backend/runsnap.sh

    rca25b67 r0fe982e  
    2222if [ $? -ne 0 ] ; then 
    2323  echo_log "ERROR: Failed creating snapshot on ${DATASET}" 
     24  email_msg "Snapshot ERROR" "ERROR: Failed creating snapshot on ${DATASET} @ `date`\n\r`cat $CMDLOG`" 
     25else 
     26  queue_msg "Success creating snapshot on ${DATASET} @ `date`\n\r`cat $CMDLOG`" 
    2427fi 
    2528 
     
    5053      if [ $? -ne 0 ] ; then 
    5154        echo_log "ERROR: Failed pruning snapshot $snap on ${DATASET}" 
     55        email_msg "Snapshot ERROR" "ERROR: Failed pruning snapshot $snap on ${DATASET} @ `date`\n\r`cat $CMDLOG`" 
     56      else 
     57        queue_msg "Success pruning snapshot $snap on ${DATASET} @ `date`\n\r`cat $CMDLOG`" 
    5258      fi 
    53    fi 
     59    fi 
    5460done 
     61 
     62if [ "$EMAILMODE" = "ALL" ] ; then 
     63   email_msg "Automated Snapshot" "`echo_queue_msg`" 
     64fi 
Note: See TracChangeset for help on using the changeset viewer.