Monitoring your hard disk health is a very important thing. You do not want to wake up one day, turn on your computer and suddenly your hard disk has crash and all your valuable data has gone with the wind. At that time crying would not get your data back. Like some people always say, prevention is better than cure. Apart from backing up your data regularly, monitoring the health of your hard disk is an essential task. It is to make sure any symptoms of bad sector or any failure can be detected earlier and steps to take care of it can be done sooner. One of the tool that can be used to do the job mentioned before is smartmontools. According to yum description, smartmontools are "Tools for monitoring SMART capable hard disks".
To install smartmontools on fedora:
# yum install smartmontools
Make sure your hard disk is smart capable
# smartctl -i /dev/sda
smartctl version 5.37 [i386-redhat-linux-gnu] Copyright (C) 2002-6 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF INFORMATION SECTION ===
Model Family: Western Digital Caviar SE (Serial ATA) family
Device Model: WDC WD800JD-60LSA5
Serial Number: WD-WMAM9MA75547
Firmware Version: 10.01E03
User Capacity: 80,026,361,856 bytes
Device is: In smartctl database [for details use: -P show]
ATA Version is: 7
ATA Standard is: Exact ATA specification draft version not indicated
Local Time is: Tue Jul 22 10:05:31 2008 MYT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
Smart support is available for this hard disk and enabled
To monitor your hard disk health
# smartctl -H /dev/sda
smartctl version 5.37 [i386-redhat-linux-gnu] Copyright (C) 2002-6 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
To run test on your hard disk
# smartctl -t short /dev/sda
To see the selftest logs of smartctl
# smartctl -l selftest /dev/sda
See all options for smartctl
# smartctl -h
Manual for smartctl
# man smartctl
To install smartmontools on fedora:
# yum install smartmontools
Make sure your hard disk is smart capable
# smartctl -i /dev/sda
smartctl version 5.37 [i386-redhat-linux-gnu] Copyright (C) 2002-6 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF INFORMATION SECTION ===
Model Family: Western Digital Caviar SE (Serial ATA) family
Device Model: WDC WD800JD-60LSA5
Serial Number: WD-WMAM9MA75547
Firmware Version: 10.01E03
User Capacity: 80,026,361,856 bytes
Device is: In smartctl database [for details use: -P show]
ATA Version is: 7
ATA Standard is: Exact ATA specification draft version not indicated
Local Time is: Tue Jul 22 10:05:31 2008 MYT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
Smart support is available for this hard disk and enabled
To monitor your hard disk health
# smartctl -H /dev/sda
smartctl version 5.37 [i386-redhat-linux-gnu] Copyright (C) 2002-6 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
To run test on your hard disk
# smartctl -t short /dev/sda
To see the selftest logs of smartctl
# smartctl -l selftest /dev/sda
See all options for smartctl
# smartctl -h
Manual for smartctl
# man smartctl
1 comments:
##To monitor Hard Drive temperature
#!/bin/bash
LOG=/usr/bin/logger
FLAG=0
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
STATE_DEPENDENT=4
crit="No"
null="NULL"
ok="Yes"
Hostname=`hostname`
# Check "smartctl" package is installed or not, if not then it will install the package and set the FLAG=1
if [ ! -f /usr/sbin/smartctl ];then
{
yum -y install smartmontools
FLAG=1
}
fi
if [ $FLAG -eq "1" ];then
{
# If the FLAG set, after that we verify that "smartctl" exists or not, if not then script will exit with error log to /var/log/message.
if [ ! -f /usr/sbin/smartctl ];then
{
$LOG "smartmontools is not installed in the server, please install it"
exit
}
fi
}
fi
# Checking 3 types of harddisk type
TWASTATUS=`smartctl -a -d 3ware,0 /dev/twa0 | grep "/dev/twa0 failed" | wc -l`
TWESTATUS=`smartctl -a -d 3ware,0 /dev/twe0 | grep "/dev/twe0 failed" | wc -l`
SDASTATUS=`smartctl -a /dev/sda | grep "/dev/sda failed" | wc -l`
SDBSTATUS=`smartctl -a /dev/sdb | grep "/dev/sdb failed" | wc -l`
if [ $TWASTATUS -eq "0" ];then
{
#echo "TWASTATUS"
VOL=`smartctl -a -d 3ware,0 /dev/twa0 | grep "Temperature_Celsius" | awk '{print $10}' | head -1`
}
elif [ $TWESTATUS -eq "0" ];then
{
#echo "TWESTATUS"
VOL=`smartctl -a -d 3ware,0 /dev/twe0 | grep "Temperature_Celsius" | awk '{print $10}' | head -1`
}
elif [ $SDASTATUS -eq "0" ];then
{
#echo "SDASTATUS"
SDA=`smartctl -a /dev/sda | grep "Temperature_Celsius" | awk '{print $10}' | wc -l`
if [ $SDA -eq "0" ];then
{
VOL=`smartctl -a /dev/sda | grep "Current Drive Temperature:" | awk '{print $4}' | head -1`
}
else
{
VOL=`smartctl -a /dev/sda | grep "Temperature_Celsius" | awk '{print $10}' | head -1`
}
fi
}
elif [ $SDBSTATUS -eq "0" ];then
{
#echo "SDBSTATUS"
SDB=`smartctl -a /dev/sdb | grep "Temperature_Celsius" | awk '{print $10}' | wc -l`
if [ $SDB -eq "0" ];then
{
VOL=`smartctl -a /dev/sdb | grep "Current Drive Temperature:" | awk '{print $4}' | head -1`
}
else
{
VOL=`smartctl -a /dev/sdb | grep "Temperature_Celsius" | awk '{print $10}' | head -1`
}
fi
}
fi
#echo $VOL
if [ $VOL -gt "35" ];then
{
$LOG "Warning:- Disk Temprature: $VOL °C"
echo "WARNING - $Hostname - Disk Temprature: $VOL°C"
mail -s "WARNING - $Hostname - Disk Temprature: $VOL°C" monitoring@your-domain.com < /dev/null
exit $STATE_WARNING;
}
elif [ $VOL -gt "45" ];then
{
$LOG "Critical:- Disk Temprature: $VOL °C"
echo "CRITICAL - $Hostname - Disk Temprature: $VOL°C"
mail -s "CRITICAL - $Hostname - Disk Temprature: $VOL°C" sms-monitoring@your-domain.com < /dev/null
exit $STATE_CRITICAL;
}
else
{
echo "OK - $Hostname - Disk Temprature: $VOL°C"
mail -s "OK - $Hostname - Disk Temprature: $VOL°C" monitoring@your-domain.com < /dev/null
exit $STATE_OK;
}
fi
Post a Comment