Another Smart Reporting Script. That Logs.

Status
Not open for further replies.

Motorhead

Dabbler
Joined
Dec 18, 2015
Messages
16
Thought this might be helpful. I noticed after the fact, SMART reporting scripts already exist, but thought what the heck i'll post this up anyway.

This script automatically finds ada devices attached to the system and runs smart reports against them, one at a time. It then will output the summary to a log, and email the log.

It's written in bash, since that shell exists in my install of 9.3. However, I'm not sure if bash is packaged with older versions of FreeNAS.

Anyway, all you have to do is modify the variables to suit your needs. You can store the script where ever, I store all my scripts in a SystemUtils directory on a seperate volume used for the system dataset and jails. Lastly, just set up a cron job pointing to the script and your good to go. I set the script to run in conjunction with my smart tests.

SmartReport.sh
  • I've attached the script to this thread, just unzip and drop it on your box. Then cater it to your needs.
  • If you want to set up a shortcut, drop this alias line in the ~/.cshrc. Obviously modify the path.
    • alias SmartReport '/mnt/System_0/SystemUtils/SmartSummary/SmartReport.sh'

Code:
#!/bin/bash
#
# Created By: Motorhead 2016/02/04

# Set up script environment
LOGPATH=/mnt/System_0/SystemUtils/SmartSummary/log
DATE=`date +%Y%m%d.%H%M`
LOG=smart.out
DAYS=365        #Number of days to retain logs
EMAIL=email@gmail.com

# Find and remove old logs
find ${LOGPATH}/${LOG}* -mtime +${DAYS} -exec rm {} \; > /dev/null 2>&1

# Find and Store all SATA Devices
DEVICELIST=($( camcontrol devlist | grep -o 'ada[0-9]' ))

# Loop through each device found in ${DEVICELIST}
for DEVICE in ${DEVICELIST[*]}; do
        FILE=${LOGPATH}/${LOG}.${DEVICE}.${DATE}
        echo "Smart Report: ${DEVICE}" > ${FILE}
        echo "Date: ${DATE}" >> ${FILE}
        echo "" >> ${FILE}
        # Log Smart Summary.
        smartctl -i -H -A -l error /dev/${LIST} >> ${FILE}
        # Email Report
        cat ${FILE} | mail -s "FREENAS: INFO - ${LIST} - SMART Report" ${EMAIL}
done
 

Attachments

  • SmartSummary.zip
    1 KB · Views: 196
Last edited:
Status
Not open for further replies.
Top