Maurizio4pastebin

zfscheck.sh for FreeBSD

Nov 21st, 2011
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.67 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # Written by nka. Modified by Maurizio.
  4. # After debugging comment the next 2 lines, and the last one.
  5. #exec >>/var/log/zfscheck.log 2>&1
  6. #set -xu
  7. email=mail@example.com
  8. max_cap=80
  9.  
  10. if ! zpool status -x | grep 'all pools are healthy' > /dev/null 2>&1; then
  11.     { date; echo; hostname; echo; zpool status -xv; } | mail -s \
  12.     "Disk failure in: $(hostname)" $email
  13. else
  14.     cap=$(zpool list -H -o capacity | cut -d'%' -f1)
  15.     for line in ${cap}; do
  16.     if [ "$line" -gt $max_cap ]; then
  17.         { date; echo; hostname; echo; zpool list -v; } \
  18.         | mail -s "Disk capacity exceed $max_cap% in: $(hostname)" \
  19.         $email
  20.         break
  21.     fi
  22.     done
  23. fi
  24. #set +xu
Add Comment
Please, Sign In to add comment