Ignore:
Timestamp:
02/20/14 10:36:15 (18 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, enter/10, releng/10.0.1, releng/10.0.2, releng/10.0.3, releng/10.1, releng/10.1.1, releng/10.1.2
Children:
4f9718b
Parents:
e07f550
Message:

Add new functionality to Life-Preserver, now when the ZFS monitor runs,
check if disk-space is getting low on the Life-Preserver managed zpools.

If it is getting low, auto-prune the oldest snapshot to free up some additional
space.

File:
1 edited

Legend:

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

    r59f014c4 r44bdd65  
    608608 
    609609} 
     610 
     611## Function to remove the oldest life-preserver snapshot on the target 
     612## zpool, used by zfsmon.sh when the disk space gets low 
     613do_pool_cleanup() 
     614{ 
     615  # Is this zpool managed by life-preserver? 
     616  grep -q "${PROGDIR}/backend/runsnap.sh ${1} " /etc/crontab 
     617  if [ $? -ne 0 ] ; then return ; fi 
     618 
     619  # Before we start pruning, check if any replication is running 
     620  local pidFile="${DBDIR}/.reptask-`echo ${1} | sed 's|/|-|g'`" 
     621  if [ -e "${pidFile}" ] ; then 
     622     pgrep -F ${pidFile} >/dev/null 2>/dev/null 
     623     if [ $? -eq 0 ] ; then return; fi 
     624  fi 
     625 
     626  # Get the list of snapshots for this zpool 
     627  snapList=$(snaplist "${1}") 
     628 
     629  # Do any pruning 
     630  for snap in $snapList 
     631  do 
     632     # Only remove snapshots which are auto-created by life-preserver 
     633     cur="`echo $snap | cut -d '-' -f 1`" 
     634     if [ "$cur" != "auto" ] ; then continue; fi 
     635 
     636     echo_log "Pruning old snapshot: $snap" 
     637     rmZFSSnap "${1}" "$snap" 
     638     if [ $? -ne 0 ] ; then 
     639       haveMsg=1 
     640       echo_log "ERROR: (Low Disk Space) Failed pruning snapshot $snap on ${1}" 
     641       queue_msg "ERROR: (Low Disk Space) Failed pruning snapshot $snap on ${1} @ `date` \n\r`cat $CMDLOG`" 
     642     else 
     643       queue_msg "(Low Disk Space) Auto-pruned snapshot: $snap on ${1} @ `date`\n\r`cat $CMDLOG`" 
     644       haveMsg=1 
     645     fi 
     646 
     647     # We only prune a single snapshot at this time, so lets end 
     648     break 
     649  done 
     650 
     651  return 0 
     652} 
Note: See TracChangeset for help on using the changeset viewer.