Jump to content

SMART drive Analysis


ptrex
 Share

Recommended Posts

SMART drive Analysis

For all of those who don't know what SMART is, let me explain :

What is S.M.A.R.T. technology for hard drives?

S.M.A.R.T. (Self-Monitoring, Analysis and Reporting Technology) is implemented into all of the modern hard disks. A special program inside the disk constantly keeps tracking the condition of a range of the vital parameters: driver, disk heads, surface state, electronics, etc. At the present time, S.M.A.R.T. technology is able to predict up to 70% of all hard disk problems! However, to use this information, you firstly have to retrieve it from the disk and analyze it. This is one of the Active SMART program's tasks

For this script I have used the freeware tool SMART.EXE from BeyondLogic.

It has a very small footprint and therefor a good combination with AutoIT.

Download it here SMART Tool

Furthermore I combined it with SQLite DB, to log all the analysis information.

In order to be able to see the trend of the drive's health over time.

Here is the script.

SMART.au3

For educational reasons I have used an in "Memory DB", meaning the data want be saved.

The output will be save to the SciTE console.

I hope that this helps you all to prevent loosing the valuable scripts as a cause of a crash.

Added a new version which in not depending on an external EXE file, and is able to retrieve remote data from a Harddisk.

SMART_WMI.au3

Enjoy

Edited by ptrex
Link to comment
Share on other sites

For those who are not fond of SQLite I have created a version that logs the details into the EVentViewer :

#include <Date.au3>

Dim $Path = "C:\_\Apps\AutoIT3\_Development\SMART\smart.exe"
Dim $sRecord, $sDataOut
Dim $Column1,$Column2,$Column3,$Column4,$Column5,$Column6,$Column7,$Column8
;Dim $hQuery, $iRval, $aResult, $iRows, $aRow, $iColumns

_Smart()
_PopulateColumns()
    
Func _Smart()
$Smart = Run($Path, "", @SW_HIDE, 2)
Local $sDataOut = ""
    Sleep(500)
    While 1
        $sDataOut &= StdOutRead($Smart)
        If @error = -1 Then ExitLoop
        $sRecord = stringsplit($sDataOut,@CRLF)
    WEnd
    Return $sRecord
EndFunc

Func _PopulateColumns()
    For $i = 27 to 59 Step 2
        $Column0 = _Now()
        $Column1 = Stringleft($sRecord[$i],4)
        $Column2 = stringmid($sRecord[$i],6,26)
        $Column3 = stringmid($sRecord[$i],33,10)
        $Column4 = stringmid($sRecord[$i],45,3)
        $Column5 = stringmid($sRecord[$i],51,3)
        $Column6 = stringmid($sRecord[$i],57,3)
        $Column7 = stringmid($sRecord[$i],62,9)
        $Column8 = stringmid($sRecord[$i],72,2)
        If $Column8 = "OK" Then
            Run("eventcreate /T Information /ID 100 /L Application /SO SMART /D " & _
            Chr(34) & "SMART Harddisk Status : "&$Column8 & _
            @CR&"ID"&"  "&"Attribute"&@Tab&@Tab&"Type"&@Tab&"Threshold"&@Tab&" Value"&" "&"Worst"&"   "&"Raw"& _
            @CR&$Column1&" "&$Column2&" "&$Column3&" "&$Column4&@Tab&$Column5&"    "&$Column6&" "&$Column7&Chr(34), "", @SW_HIDE, 2)
        Else
            Run("eventcreate /T Error /ID 999 /L Application /D " & _
            Chr(34) & "SMART Harddisk Status : "&$Column8 & _
            @CR&"ID"&"  "&"Attribute"&@Tab&@Tab&"Type"&@Tab&"Threshold"&@Tab&" Value"&" "&"Worst"&"   "&"Raw"& _
            @CR&$Column1&" "&$Column2&" "&$Column3&" "&$Column4&@Tab&$Column5&"    "&$Column6&" "&$Column7&Chr(34), "", @SW_HIDE, 2)
        Endif   
    Next
EndFunc

You can schedule the script in a Job and run it every day. If some parameters will by higher than the Threshold value, a RED ALERT will be logged in the Event Viewer.

Otherwise an normal event will be logged.

Enjoy !!

Edited by ptrex
Link to comment
Share on other sites

  • 2 months later...

Hi ptrex,

i get following error in scite :

\Autoit\Smart Analysis\smart.au3 (63) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$Column1 = Stringleft($sRecord[$i],4)

$Column1 = Stringleft(^ ERROR

I'm using version 3.2.0.1

Any ideas?

Greets

Dizzy

Link to comment
Share on other sites

@Dizzy

Hello, sorry for the Errors, but this version is outdated.

I have added a new version which is not depending on an external EXE or DLL file.

You can also run this to retrieve remote Hard Disk Data from a PC or Server.

See first post.

Enjoy !!

Link to comment
Share on other sites

When I run your newest version which is not dependant on an external .exe file, I receive the following error three times:

We intercepted a COM Error! 

err.description is:
err.windescription is:
err.number is:         80041003
err.lastdllerror is:           0
err.scriptline is:         30 (second time this number is 37, third time this number is 42)
err.source is:
err.helpfile is:
err.helpcontext is:

Then I get an AutoIt Error:

Line 67 (File ...): 
Dim $Temp[17] = [$strVendorSpecific[5] > $strVendorSpecific2[3],$strVendorSpecific[17] > $strVendorSpecific2[15]]
Dim $Temp[17] = [$strVendorSpecific^ ERROR

Error: Subscript used with non-Array variable.

After which the script ends.

Not being too familiar with COM functions or use myself, I'm not sure if this is reporting a SMART error on my drive, or a problem with the script on the OS I'm using on this machine (Windows Vista RC1)

Can you tell me how to interpert these messages, pretty please? :)

Thanks

Edit: Fixed those stupid double-linebreaks I always seem to get...

Edited by james3mg
"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

@james3mg

I am sure it has something to with "Windows Vista RC1" release. Because I ran this on XP and 2000 with not problems !!

As you can see some of them are have no errors reported.

Nevertheless the code is not finished yet, but it should run without errors.

Regards

ptrex

Link to comment
Share on other sites

@james3mg

I am sure it has something to with "Windows Vista RC1" release. Because I ran this on XP and 2000 with not problems !!

As you can see some of them are have no errors reported.

Nevertheless the code is not finished yet, but it should run without errors.

Regards

ptrex

he fixed it already:

Edit: Fixed those stupid double-linebreaks I always seem to get...

Link to comment
Share on other sites

he fixed it already:

No, unfortunately not...My Edit was just fixing the extra lines I always end up getting in my forum posts, and I marked what I edited as a courtesy, since it's noted that I edited my post below the post itself. I'll try again in future Vista releases and keep you posted, or come January, lots of people might be complaining :-)
"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

  • 9 months later...

@ptrex

I've got the same error as james3mg

Note that, though I haven't reported back until now, once I installed Vista Business (retail), I'm not getting those errors anymore, though I'm thinking I'll probably change the output function to format the data into a TreeView control ... the MsgBox leaves the data looking nasty and unreadable, at least on my machine.
"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

The columns are not aligned correctly when I try this. (XP SP1)

Great utility though :whistle:

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Link to comment
Share on other sites

  • 2 months later...

Hi,

I found your script usefull, and I used it in various way in my scripts, It worked perfectly on my desktop PC.

When Ive tryd to use it on my Notebook, or my friend Desktop, I get allways the same error:

C:\HDscript\HD1.au3 (67) : ==> Subscript used with non-Array variable.:

Dim $Temp[17] = [$strVendorSpecific[5] > $strVendorSpecific2[3],$strVendorSpecific[17] > $strVendorSpecific2[15]]

Dim $Temp[17] = [$strVendorSpecific^ ERROR

None of those computers have Vista, working desktop, notebook and notworking desktop have XP sp2.

How can I fix that?

thx in advance

Link to comment
Share on other sites

@Hellsum

The main reason might be the the HD is not compliant with the S.M.A.R.T protocol.

And does not expose the SMART data to the OS.

In my first post there is a link to a commandline tool.

Thry to run this to check of there is data returned.

regards

ptrex

Link to comment
Share on other sites

  • 2 months later...

Ptrex

I have modified your excellent WMI script a little I hope you don't mind. I've made it use a 2d array rather than a message box and simplified some of the creation of the data also adding in the column where the data type is to indicated if it is a predictive failure value or advisory and also the ability to specify the drive you wish to analyze if required.

Chris

SMART_WMI.au3

Link to comment
Share on other sites

  • 5 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...