Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

SMART drive Analysis


  • Please log in to reply
94 replies to this topic

#1 ptrex

ptrex

    Universalist

  • MVPs
  • 2,420 posts

Posted 16 June 2006 - 08:41 PM

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.

Attached File  SMART.au3   2.13KB   1669 downloads

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.

Attached File  SMART_WMI.au3   9.9KB   2343 downloads

Enjoy

Edited by ptrex, 14 September 2012 - 09:43 AM.








#2 ptrex

ptrex

    Universalist

  • MVPs
  • 2,420 posts

Posted 21 June 2006 - 10:01 AM

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

Plain Text         
#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, 21 June 2006 - 10:09 AM.


#3 Dizzy

Dizzy

    Polymath

  • Active Members
  • PipPipPipPip
  • 224 posts

Posted 18 September 2006 - 09:30 AM

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

#4 ptrex

ptrex

    Universalist

  • MVPs
  • 2,420 posts

Posted 18 September 2006 - 09:57 AM

@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 !!

#5 james3mg

james3mg

    I resent the title "Spammer!" ;-)

  • Active Members
  • PipPipPipPipPipPip
  • 730 posts

Posted 18 September 2006 - 01:00 PM

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, 18 September 2006 - 01:02 PM.

Posted ImagePosted Image"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

#6 logi

logi

    Wayfarer

  • Active Members
  • Pip
  • 61 posts

Posted 18 September 2006 - 01:05 PM

Works perfectly, great app!

#7 ptrex

ptrex

    Universalist

  • MVPs
  • 2,420 posts

Posted 18 September 2006 - 02:28 PM

@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

#8 logi

logi

    Wayfarer

  • Active Members
  • Pip
  • 61 posts

Posted 18 September 2006 - 03:24 PM

@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...



#9 james3mg

james3mg

    I resent the title "Spammer!" ;-)

  • Active Members
  • PipPipPipPipPipPip
  • 730 posts

Posted 20 September 2006 - 07:07 PM

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 :-)
Posted ImagePosted Image"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

#10 Emiel Wieldraaijer

Emiel Wieldraaijer

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 711 posts

Posted 04 July 2007 - 09:05 PM

@ptrex

I've got the same error as james3mg
Best regards,Emiel WieldraaijerPosted Image

#11 james3mg

james3mg

    I resent the title "Spammer!" ;-)

  • Active Members
  • PipPipPipPipPipPip
  • 730 posts

Posted 05 July 2007 - 08:11 PM

@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.
Posted ImagePosted Image"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

#12 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,321 posts

Posted 05 July 2007 - 08:34 PM

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



Great utility though :whistle:

Edited by martin, 05 July 2007 - 08:37 PM.

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.

#13 Emiel Wieldraaijer

Emiel Wieldraaijer

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 711 posts

Posted 07 July 2007 - 11:02 AM

and the strangest thing is .... the problem .. does not exist anymore.. on my computer... and i use XPPro instead of Vista

Emiel
Best regards,Emiel WieldraaijerPosted Image

#14 ptrex

ptrex

    Universalist

  • MVPs
  • 2,420 posts

Posted 07 July 2007 - 08:52 PM

@all

Good to see it"s still running.

The layout problem can easily be fixed by yourselve.
It is depending on the output of your HD.

Rgds

ptrex

#15 Hellsum

Hellsum

    Seeker

  • Active Members
  • 7 posts

Posted 21 September 2007 - 10:49 AM

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

#16 ptrex

ptrex

    Universalist

  • MVPs
  • 2,420 posts

Posted 21 September 2007 - 11:24 AM

@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

#17 ChrisL

ChrisL

    Mass Spanner!

  • Active Members
  • PipPipPipPipPipPip
  • 1,761 posts

Posted 03 December 2007 - 02:25 PM

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

Attached Files



#18 ptrex

ptrex

    Universalist

  • MVPs
  • 2,420 posts

Posted 03 December 2007 - 02:41 PM

@ChrisL

Don't mind at all !!

it is looking realy good now !! :)


regards

ptrex

#19 Emiel Wieldraaijer

Emiel Wieldraaijer

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 711 posts

Posted 02 January 2008 - 04:17 PM

Hi All,

I am wondering why the smart_wmi.au3 checks the floppy drive. Can this be disabled ?

Happy New Year

Emiel
Best regards,Emiel WieldraaijerPosted Image

#20 ptrex

ptrex

    Universalist

  • MVPs
  • 2,420 posts

Posted 02 January 2008 - 06:45 PM

@Emiel Wieldraaijer

Maybe you can use the version of ChrisL where the drive can be specified.

regards

ptrex




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users