#!/bin/bash
date > /root/badsectortest.txt
badblocks /dev/sda -v &>> /root/badsectortest.txt
hoursworkhdd=`smartctl --all /dev/sda | grep Power_On_Hours | awk '{print $10}'`
dayworkhdd=`expr $hoursworkhdd / 24`
yesworkhdd=`expr $dayworkhdd / 366`
echo -e "Hours working hdd:" >> /root/badsectortest.txt
echo -e $hoursworkhdd >> /root/badsectortest.txt
echo -e "Days working hdd:" >> /root/badsectortest.txt
echo -e $dayworkhdd >> /root/badsectortest.txt
echo -e "Years working hdd:" >> /root/badsectortest.txt
echo -e $yesworkhdd >> /root/badsectortest.txt
date >> /root/badsectortest.txt
cat /root/badsectortest.txt | /usr/bin/mail -s "badsector - `date`" soban@soban.pl
