baumi's blog

baumi's personal blog … Linux, OS X, Windows, Random things, …

Bash cron script for monitoring SMART health

#!/bin/bash
echo >/tmp/smart
for disk in /dev/sd[a-h] ; do
   echo -e -n "\n\n$disk - " >> /tmp/smart
   smartctl -s on --all $disk | egrep "Power_On_Hours|Power_Cycle_Count|Reallocated_Sector_Ct|result" >> /tmp/smart 2>&1
done
cat /tmp/smart
cat /tmp/smart | /usr/bin/mail -E -s 'SMART Report' receiver@server.com

Comments are currently closed.