source: src-sh/lpreserver/backend/zfsmon.sh @ 44bdd65

releng/10.0.1releng/10.0.2releng/10.0.3releng/10.1
Last change on this file since 44bdd65 was 44bdd65, checked in by Kris Moore <kris@…>, 10 months ago

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.

  • Property mode set to 100755
File size: 1.3 KB
Line 
1#!/bin/sh
2# Do the cron snapshot
3######################################################################
4
5# Set our vars
6PROGDIR="/usr/local/share/lpreserver"
7
8# Source our functions
9. /usr/local/share/pcbsd/scripts/functions.sh
10. ${PROGDIR}/backend/functions.sh
11
12# Lets do a health-check on the zpool
13ZSTATUS="`zpool status -x`"
14if [ "$ZSTATUS" != "all pools are healthy" ] ; then
15  email_msg "zpool issue" "The zpool command reports an issue on the system:\n\r $ZSTATUS"
16  echo "$ZSTATUS" > $DBDIR/zpool-alert
17else
18  # Cleanup any old alert files
19  if [ -d "${DBDIR}/zpool-alert" ] ; then rm ${DBDIR}/zpool-alert; fi
20fi
21
22if [ "$EMAILMODE" = "ERROR" ] ; then exit 0 ; fi
23
24haveMsg=0
25
26# Remove the old du alert flag
27if [ -e "${DBDIR}/zpool-alert-du" ] ; then rm ${DBDIR}/zpool-alert-du ; fi
28
29# Do the disk-space check
30for zpool in `zpool list -H | awk '{print $1}'`
31do
32  poolCap="`zpool list -H -o capacity $zpool | cut -d '%' -f 1`"
33
34  if [ $poolCap -gt $DUWARN ] ; then
35     queue_msg "Warning! ${zpool} is currently at ${poolCap}% capacity!"
36     echo "$poolCap" > $DBDIR/zpool-alert-du
37     haveMsg=1
38  fi
39
40  # See if we can do any auto-cleanup of this pool
41  if [ $poolCap -gt 85 ] ; then do_pool_cleanup "$zpool"; fi
42
43done
44
45# Lets check free disk space on the pools
46if [ $haveMsg -eq 1 ] ; then
47   email_msg "zpool warning" "`echo_queue_msg`"
48fi
49
Note: See TracBrowser for help on using the repository browser.