source: src-sh/lpreserver/backend/zfsmon.sh @ 4c15f05

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2releng/10.0.3releng/10.1
Last change on this file since 4c15f05 was 4c15f05, checked in by Kris Moore <kris@…>, 17 months ago

Set alert flag when disk usage warning is thrown

  • 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
29zpool list  | grep -v "^NAME" > /tmp/.lPreserver-df.$$
30while read line
31do
32   cap=`echo $line | awk '{print $5}' | cut -d '%' -f 1`
33   zpool=`echo $line | awk '{print $1}'`
34   if [ $(is_num "$cap") ] ; then
35      if [ $cap -gt $DUWARN ] ; then
36         queue_msg "Warning! ${zpool} is currently at ${cap}% capacity!"       
37         echo "$cap" > $DBDIR/zpool-alert-du
38         haveMsg=1
39      fi
40   fi
41done< /tmp/.lPreserver-df.$$
42rm /tmp/.lPreserver-df.$$
43
44# Lets check free disk space on the pools
45if [ $haveMsg -eq 1 ] ; then
46   email_msg "zpool warning" "`echo_queue_msg`"
47fi
48
Note: See TracBrowser for help on using the repository browser.