ripdad

MiniSMART v0.2

11 posts in this topic

#1 ·  Posted (edited)

I couldn't resist making a S.M.A.R.T. script using WMIC. It gave me something to do over the holidays.

1) This will only give SMART data for the main drive. (ie: C:\)

2) It will most likely Not give data on Raided or USB drives.

3) It only shows pertinent data columns and ignores all others.

4) It should be good enough for a quick glance and an example how to parse WMIC output.

Download:  _MiniSmart v0.2.au3

 

WD_80GB.png

 

Edited by ripdad
1 person likes this

I'm pretty sure this script has "some flaws" (somewhere). Welcome to programming!

Share this post


Link to post
Share on other sites



I edited the script and inserted an image.

Sorry, try again.

 

1 person likes this

I'm pretty sure this script has "some flaws" (somewhere). Welcome to programming!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

"C:\Users\Owner\Downloads\_MiniSmart.au3" (41) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$aSMART[$n][0] = Number($a[$i])
^ ERROR

SSD as C:\ drive 

Hard Disk Number,0
Interface,"S-ATA Gen3, 6 Gbps"
Hard Disk Model ID,Crucial_CT120M500SSD1
Firmware Revision,MU03
Active  Checksum  ErrorLogCapability  ExtendedPollTimeInMinutes  InstanceName                                                        Length  OfflineCollectCapability  OfflineCollectionStatus  Reserved                              SelfTestStatus  ShortPollTimeInMinutes  SmartCapability  TotalTime  VendorSpecific                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               VendorSpecific2  VendorSpecific3  VendorSpecific4                                                                                                                                                                                                                                                                                                                                                                          
TRUE    160       1                   9                          SCSI\Disk&Ven_Crucial_&Prod_Crucial_CT120M50\4&38fbd192&0&000000_0  512     123                       128                      {3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}  0               2                       3                555        {16, 0, 1, 47, 0, 100, 100, 8, 0, 0, 0, 0, 0, 0, 5, 51, 0, 100, 100, 0, 0, 0, 0, 0, 0, 0, 9, 50, 0, 100, 100, 81, 5, 0, 0, 0, 0, 0, 12, 50, 0, 100, 100, 69, 0, 0, 0, 0, 0, 0, 171, 50, 0, 100, 100, 0, 0, 0, 0, 0, 0, 0, 172, 50, 0, 100, 100, 0, 0, 0, 0, 0, 0, 0, 173, 50, 0, 81, 81, 74, 2, 0, 0, 0, 0, 0, 174, 50, 0, 100, 100, 35, 0, 0, 0, 0, 0, 0, 180, 51, 0, 0, 0, 198, 7, 0, 0, 0, 0, 0, 183, 50, 0, 100, 100, 0, 0, 0, 0, 0, 0, 0, 184, 50, 0, 100, 100, 0, 0, 0, 0, 0, 0, 0, 187, 50, 0, 100, 100, 0, 0, 0, 0, 0, 0, 0, 194, 34, 0, 70, 59, 30, 0, 0, 0, 41, 0, 0, 196, 50, 0, 100, 100, 16, 0, 0, 0, 0, 0, 0, 197, 50, 0, 100, 100, 0, 0, 0, 0, 0, 0, 0, 198, 48, 0, 100, 100, 0, 0, 0, 0, 0, 0, 0, 199, 50, 0, 100, 100, 0, 0, 0, 0, 0, 0, 0, 202, 49, 0, 81, 81, 19, 0, 0, 0, 0, 0, 0, 206, 14, 0, 100, 100, 0, 0, 0, 0, 0, 0, 0, 210, 50, 0, 100, 100, 0, 0, 0, 0, 0, 0, 0, 246, 50, 0, 100, 100, 133, 226, 35, 243, 6, 0, 0, 247, 50, 0, 100, 100, 73, 70, 46, 3, 0, 0, 0, 248, 50, 0, 100, 100, 160, 240, 106, 219, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}  0                0                {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

so you can troubleshoot :) 

Edited by argumentum

Share this post


Link to post
Share on other sites

yes - give me a little bit of time, maybe an hour or so.

1 person likes this

I'm pretty sure this script has "some flaws" (somewhere). Welcome to programming!

Share this post


Link to post
Share on other sites

ok, try it now.

Thanks for the feedback. Two things were fixed with that.

 


I'm pretty sure this script has "some flaws" (somewhere). Welcome to programming!

Share this post


Link to post
Share on other sites
1 minute ago, ripdad said:

ok, try it now.

Row|Col 0|Col 1|Col 2|Col 3|Col 4|Col 5
[0]|Attribute|Raw/Value|Cycles|VSD1|SumCounts|AttributeName
[1]|1|8|0|0|0|ReadErrorRate
[2]|5|0|0|0|0|ReallocatedSectorsCount/SSDRetiredBlockCount
[3]|9|81|5|0|1361|PowerOnHours(POH)
[4]|12|69|0|0|69|PowerCycleCount
[5]|171|0|0|0|0|SSDProgramFailBlockCount
[6]|172|0|0|0|0|SSDEraseFailBlockCount
[7]|173|74|2|0|586|SSDWearLevelingCount
[8]|174|35|0|0|35|SSDUnexpectedPowerLossCount
[9]|180|198|7|0|1990|BlockCountTotal/SSDUnusedReservedBlockCount
[10]|183|0|0|0|0|SATADownshiftErrorCount/SSDRuntimeBadBlock
[11]|184|0|0|0|0|EndtoEnderror
[12]|187|0|0|0|0|ReportedUncorrectableErrors/SSDUncorrectableErrorCount
[13]|194|30|0|0|30C/86F|Temperature
[14]|196|16|0|0|16|ReallocationEventCount
[15]|197|0|0|0|0|CurrentPendingSectorCount
[16]|198|0|0|0|0|UncorrectableSectorCount/SSDOffLineUncorrectableErrorCount
[17]|199|0|0|0|0|UltraDMACRCErrorCount/SSDCRCErrorCount
[18]|202|19|0|0|0|DataAddressMarkErrors
[19]|206|0|0|0|0|FlyingHeight
[20]|210|0|0|0|0|VibrationDuringWrite
[21]|246|18|112|83|0|(Unknown Attribute)
[22]|247|20|198|47|0|(Unknown Attribute)
[23]|248|137|162|112|0|(Unknown Attribute)

:D

Share this post


Link to post
Share on other sites

Good!
One more item I have to work on - the Drive Model.
Those strings are not consistent.

I will have to change the code for something more suitable.
Maybe tomorrow.

 


I'm pretty sure this script has "some flaws" (somewhere). Welcome to programming!

Share this post


Link to post
Share on other sites

Okay, that should do it.

Updated first post.

.


I'm pretty sure this script has "some flaws" (somewhere). Welcome to programming!

Share this post


Link to post
Share on other sites

#11 ·  Posted

Looks good.

Thanks for the feedback.

 

1 person likes this

I'm pretty sure this script has "some flaws" (somewhere). Welcome to programming!

Share this post


Link to post
Share on other sites

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

  • Similar Content

    • Synapsee
      Remote\Distant Drive Information
      By Synapsee
      ;RemoteDriveInfo ;v0.0.0.1 ;Ressource ;Smart Temp : https://www.autoitscript.com/forum/topic/91067-drive-temperature/?do=findComment&comment=1091961 ;GetPNPDeviceID From DriveLetter : https://www.autoitscript.com/forum/topic/57202-need-help-get-pnp-device-id-for-usb-drive/?do=findComment&comment=433346 ;Get Disk Space Info : https://www.autoitscript.com/forum/topic/148390-wmi-query-how-to-get-data-from-object/?do=findComment&comment=1055088 ;For A to Z : https://www.autoitscript.com/forum/topic/4804-fornext-loop-with-letters/?do=findComment&comment=30417 ;Include #include <Array.au3> #include <String.au3> ;Sample 1 ;$sComputerName $sComputerName = "PC1" ;$sComputerName = "PC2" ;$sComputerName = @ComputerName ;$sDrive ;$sDrive = "system" ;$sDrive = "D:" $sDrive = "" $DriveInfo = _GetDriveInfo($sComputerName, $sDrive) _ArrayDisplay($DriveInfo) ;Sample 2 $DriveInfo = _GetDriveInfo($sComputerName, "system") If $DriveInfo[0][0] = "DriveLeter" Then If $DriveInfo[1][6] <> "" Then MsgBox(0, "", $DriveInfo[1][6] & "° - " & $DriveInfo[1][4] & "% ( " & Round($DriveInfo[1][2]/1024^3) & "Go / " & Round($DriveInfo[1][3]/1024^3) & "Go )" & @CRLF) Else MsgBox(0, "", $DriveInfo[1][4] & "% ( " & Round($DriveInfo[1][2]/1024^3) & "Go / " & Round($DriveInfo[1][3]/1024^3) & "Go )" & @CRLF) EndIf Else MsgBox(0, "", $DriveInfo[0][0] & @CRLF) EndIf ;Function Func _GetSystemDriveLtr($sComputerName) $objWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sComputerName & "\root\cimv2") $colTemp = $objWMI.ExecQuery("SELECT SystemDrive FROM Win32_OperatingSystem") If IsObj($colTemp) then For $objItem In $colTemp $sSystemDriveLtr = $objItem.systemdrive Next EndIf Return $sSystemDriveLtr EndFunc ;==> _GetSystemDriveLtr Func _GetPNPDeviceID($drive_letter, $sComputerName) Local $drive_letter_found, $drive_letter_found $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $sComputerName & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDiskToPartition", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $LogicalDiskToPartitionAntecedent = _StringBetween($objItem.Antecedent, '"', '"') $LogicalDiskToPartitionDependent = _StringBetween($objItem.Dependent, '"', '"') ;ConsoleWrite(@CR & $LogicalDiskToPartitionAntecedent[0] & " - " & $LogicalDiskToPartitionDependent[0]) $drive_statistics = $LogicalDiskToPartitionAntecedent[0] $drive_letter_found = $LogicalDiskToPartitionDependent[0] If $drive_letter = $drive_letter_found Then ExitLoop EndIf Next Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_LogicalDiskToPartition") EndIf If $drive_letter <> $drive_letter_found Then Return 0 ; If drive letter isn't function returns 0 $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDriveToDiskPartition", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $DiskDriveToDiskPartitionAntecedent = _StringBetween($objItem.Antecedent, '"', '"') $DiskDriveToDiskPartitionDependent = _StringBetween($objItem.Dependent, '"', '"') ;ConsoleWrite(@CR & $DiskDriveToDiskPartitionAntecedent[0] & " - " & $DiskDriveToDiskPartitionDependent[0]) $drive_statistics_found = $DiskDriveToDiskPartitionDependent[0] $drive_physical = StringTrimLeft($DiskDriveToDiskPartitionAntecedent[0], StringInStr($DiskDriveToDiskPartitionAntecedent[0], "\", 1, -1)) ;MsgBox(0,"TEST", $drive_physical) If $drive_statistics = $drive_statistics_found Then ExitLoop EndIf Next Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_DiskDriveToDiskPartition") EndIf $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems ;MsgBox(0,324234, $objItem.DeviceID) $DeviceID = StringTrimLeft($objItem.DeviceID, StringInStr($objItem.DeviceID, "\", 1, -1)) $PNPDeviceID = $objItem.PNPDeviceID ;MsgBox(0,122, $DeviceID) If $drive_physical = $DeviceID Then Return $PNPDeviceID EndIf Next Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_DiskDrive") EndIf EndFunc ;==> _GetPNPDeviceID Func _GetSmartTemp($InstanceName, $sComputerName) $objWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sComputerName & "\root\WMI") $colTemp = $objWMI.ExecQuery("SELECT * FROM MSStorageDriver_ATAPISmartData") $s = "" If IsObj($colTemp) and $InstanceName <> "" then For $objItem In $colTemp If StringInStr(StringUpper($objItem.InstanceName), StringUpper($InstanceName)) <> 0 Then $strVendorSpecific = $objItem.VendorSpecific For $i = 2 To UBound($strVendorSpecific) - 1 Step 12 If $strVendorSpecific[$i] = 0xC2 Then; find Vendor Parameter #194 - Temperatur $s &= " " & $strVendorSpecific[$i + 5]; Raw/Value celsuis ContinueLoop 2 EndIf Next For $i = 2 To UBound($strVendorSpecific) - 1 Step 12 If $strVendorSpecific[$i] = 0xBE Then; find Vendor Parameter #190 - Airflow Temperatur (if no tempetature is found) $s &= " " & $strVendorSpecific[$i + 5]; Raw/Value celsuis ContinueLoop 2 EndIf Next EndIf Next $s = StringTrimLeft($s, 1) Else $s = "" EndIf Return $s EndFunc ;==> _GetSmartTemp ;MainFunction Func _GetDriveInfo($sComputerName, $sDrive = "") Local $DriveArray[1][7] = [["DriveLeter", "FreespaceByte", "UsedspaceByte", "SizeByte", "UsedPercent", "IsSystem", "Temp"]] If Ping($sComputerName) = 0 Then Local $DriveArray[1][1] $DriveArray[0][0] = $sComputerName & " seems not online" Return $DriveArray EndIf If $sDrive = "" Then For $i = 65 To 90;For A to Z $sDriveLtr = Chr($i)&":" $DriveArray = _GetOneDriveInfo($sComputerName, $sDriveLtr, $DriveArray) Next ElseIf $sDrive = "system" Then $DriveArray = _GetOneDriveInfo($sComputerName, _GetSystemDriveLtr($sComputerName), $DriveArray) Else $DriveArray = _GetOneDriveInfo($sComputerName, $sDrive, $DriveArray) EndIf Return $DriveArray EndFunc ;==> _GetDriveInfo Func _GetOneDriveInfo($sComputerName, $sDriveLtr, $DriveArray) $objWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sComputerName & '\root\cimv2:Win32_LogicalDisk="' & $sDriveLtr & '"') If IsObj($objWMI) Then $UsedPercent = Round(100 / $objWMI.Size * ($objWMI.Size - $objWMI.FreeSpace)) If $UsedPercent <> -9223372036854775807 then $current_line = Ubound($DriveArray)+1 ReDim $DriveArray[$current_line][7] $DriveArray[$current_line-1][0] = $sDriveLtr $FreespaceByte = $objWMI.FreeSpace $DriveArray[$current_line-1][1] = $FreespaceByte $SizeByte = $objWMI.Size $DriveArray[$current_line-1][3] = $SizeByte $UsedspaceByte = $objWMI.Size - $objWMI.FreeSpace $DriveArray[$current_line-1][2] = $UsedspaceByte $UsedPercent = Round(100 / $objWMI.Size * ($objWMI.Size - $objWMI.FreeSpace)) $DriveArray[$current_line-1][4] = $UsedPercent If _GetSystemDriveLtr($sComputerName) = $sDriveLtr Then $IsSystem = 1 Else $IsSystem = 0 EndIf $DriveArray[$current_line-1][5] = $IsSystem $InstanceName = _GetPNPDeviceID($sDriveLtr, $sComputerName) $Temp = _GetSmartTemp($InstanceName, $sComputerName) $DriveArray[$current_line-1][6] = $Temp EndIf EndIf Return $DriveArray EndFunc  
      Ressource

      Smart Temp :
      GetPNPDeviceID From DriveLetter :
      Get Disk Space Info :
      For A to Z :