Script to log drive SMART parameters...

Discussion in 'TiVo Series 1 - UK' started by Ian_m, Sep 15, 2006.

  1. Ian_m

    Ian_m Active Member

    1,518
    0
    Jan 9, 2001
    Southampton,...
    My year old 300GB TiVo drive is reallocating sectors (on its way out ??) and to keep tabs on I have written this simple script to output reallocated sectors, power on hours and power cycles to a log file that can be viewed from TiVoWeb LOGS tab.

    Save this as /var/hack/etc/smart.sh.

    Code:
    date >> /var/log/smart.log
    /var/hack/bin/smartctl -a /dev/hda > /var/hack/smartrpt.txt
    echo "Drive hda" >> /var/log/smart.log
    grep "Reallocated" /var/hack/smartrpt.txt >> /var/log/smart.log
    grep "Power_On" /var/hack/smartrpt.txt >> /var/log/smart.log
    grep "Power_Cycle" /var/hack/smartrpt.txt >> /var/log/smart.log
    /var/hack/bin/smartctl -a /dev/hdb > /var/hack/smartrpt.txt
    echo "Drive hdb" >> /var/log/smart.log
    grep "Reallocated" /var/hack/smartrpt.txt >> /var/log/smart.log
    grep "Power_On" /var/hack/smartrpt.txt >> /var/log/smart.log
    grep "Power_Cycle" /var/hack/smartrpt.txt >> /var/log/smart.log
    rm -f /var/hack/smartrpt.txt
    echo >> /var/log/smart.log
    It needs latest version of SMARTCTL in /var/hack/bin.

    Then use CRON to schedule once a day. I put the following line in my corntab file.

    Code:
    30 4 * * 0-6 /var/hack/etc/smart.sh
    It produces the output below

    Code:
    Fri Sep 15 04:30:06 localtime 2006
    Drive hda
    5 Reallocated_Sector_Ct 0x0033 100 100 036 Old_age - 8
    9 Power_On_Hours 0x0032 091 091 000 Old_age - 8227
    12 Power_Cycle_Count 0x0032 100 100 020 Old_age - 28
    Drive hdb
    5 Reallocated_Sector_Ct 0x0033 100 100 036 Old_age - 0
    9 Power_On_Hours 0x0032 092 092 000 Old_age - 7054
    12 Power_Cycle_Count 0x0032 100 100 020 Old_age - 28
    Please feel free to code better, use or variables for paths and files would be nice, but I wanted something quicky that worked.
     

Share This Page