Hard drive failure notification

Eric P
2017-10-13 00:24

 

cd /root
nano hd-monitor.sh
#!/usr/bin/perl
$to='some@yourown.com';
$from='hdfail@whatever.com';
my $command_output = ´/usr/sbin/smartctl -a /dev/sda1´;
if ($command_output =~ /PASSED/ && $? == 0) {
print "No issues with /dev/sda1";
}else{
´echo "Subject:HD Failure \n$command_output" | /usr/sbin/sendmail -f $from $to´;
}
sudo chmod +x /root/hd-monitor.sh
sudo crontab -e
0 3 * * * /root/hd-monitor.sh  > /tmp/hd-monitor.log
Tags: failure, Hard drive, notification, SMART
Average rating: 0 (0 Votes)

You cannot comment on this entry