Сбор статистики SMART

  1. #!/bin/sh
  2.  
  3. EMAIL="admin@srv-home.local"
  4. DEVICES="/dev/ad4 /dev/ad6"
  5. SMARTCTL=`whereis smartctl | awk '{print $2}'`
  6.  
  7. if [ -z "${DEVICES}" ]; then
  8.   echo '$DEVICES is empty'
  9. elif [ ! -x "${SMARTCTL}" ]; then
  10.   echo "smartctl not found"
  11. else
  12.   if [ -f /tmp/daily.sendsmart ]; then
  13.     rm -f /tmp/daily.sendsmart
  14.   fi
  15.  
  16.   for devs in $DEVICES; do
  17.     touch /tmp/daily.sendsmart
  18.     $SMARTCTL -a $devs > /tmp/daily.sendsmart
  19.     cat /tmp/daily.sendsmart | mail -s "S.M.A.R.T. $devs" $EMAIL
  20.     rm -f /tmp/daily.sendsmart
  21.     sleep 10
  22.   done
  23. fi