Changeset 8c2bd1a


Ignore:
Timestamp:
07/31/13 09:49:52 (13 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:
4c15f05
Parents:
0fe982e
Message:

Add functionality to the zfs monitor, it will now check / report on zpool status and low disk space

Location:
src-sh/lpreserver
Files:
3 edited

Legend:

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

    r0fe982e r8c2bd1a  
    3030  if [ -e "${DBDIR}/emaillevel" ] ; then 
    3131    export EMAILMODE="`cat ${DBDIR}/emaillevel`" 
     32  fi 
     33 
     34  if [ -e "${DBDIR}/duwarn" ] ; then 
     35    export DUWARN="`cat ${DBDIR}/duwarn`" 
     36  else 
     37    export DUWARN=85 
    3238  fi 
    3339 
  • src-sh/lpreserver/backend/zfsmon.sh

    rca25b67 r8c2bd1a  
    1010. ${PROGDIR}/backend/functions.sh 
    1111 
    12 # Placeholder for now, will be our ZFS monitoring stuff here 
     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 
     26zpool list  | grep -v "^NAME" > /tmp/.lPreserver-df.$$ 
     27while read line 
     28do 
     29   cap=`echo $line | awk '{print $5}' | cut -d '%' -f 1` 
     30   zpool=`echo $line | awk '{print $1}'` 
     31   if [ $(is_num "$cap") ] ; then 
     32      if [ $cap -gt $DUWARN ] ; then 
     33         queue_msg "Warning! ${zpool} is currently at ${cap}% capacity!"         
     34         haveMsg=1 
     35      fi 
     36   fi 
     37done< /tmp/.lPreserver-df.$$ 
     38rm /tmp/.lPreserver-df.$$ 
     39 
     40# Lets check free disk space on the pools 
     41if [ $haveMsg -eq 1 ] ; then 
     42   email_msg "zpool warning" "`echo_queue_msg`" 
     43fi 
     44 
  • src-sh/lpreserver/lpreserver

    r7814c14 r8c2bd1a  
    6565 
    6666Config options 
     67 
     68     duwarn - Set to a disk percentage [0-99] at which to warn of low disk space 
    6769 
    6870      email - Set the e-mail address to receive notifications 
     
    240242         title 
    241243         echo "      Recursive mode: $RECURMODE" 
    242          echo "E-Mail Notifications: $EMAILMODE" 
    243          echo "    E-Mail Addresses: $EMAILADDY" 
     244         echo "E-mail notifications: $EMAILMODE" 
     245         echo "    E-mail addresses: $EMAILADDY" 
     246         echo "  Disk space warn at: ${DUWARN}%" 
    244247         exit 0 
    245248         ;; 
     
    257260            email) echo "Setting email notification to: $3"  
    258261                   echo "$3" > ${DBDIR}/emails ;; 
     262           duwarn) if [ ! $(is_num "$3") ] ; then exit_err "Invalid number, must be 0-99"; fi 
     263                   echo "Setting disk warning capacity to: ${3}%"  
     264                   echo "$3" > ${DBDIR}/duwarn ;; 
    259265        recursive) case $3 in 
    260266                  OFF|Off|off)  echo "Recursive mode disabled"  
Note: See TracChangeset for help on using the changeset viewer.