argumentum Posted 4 hours ago Posted 4 hours ago ..had a PC that lost 1% NVMe of heath each day. Why, how ?, no clue. Rebooted the PC and it stopped chewing up the drive. And found out by chance and not because something ( an alarm or anything ) alerted me. Where can I get something that I can use ? Ended up installing smartctl from smartmontools.org. Then is a matter of putting that I need in an array and, have fun with it ? ( code something that will so something ? ..., haven't got there yet ) Spoiler expandcollapse popup#include <Debug.au3> #include <_RunWaitEx.au3> ; https://www.autoitscript.com/forum/index.php?showtopic=212643 _RunWaitEx_DefaultConsoleWrite(0) main() Func main() Local $hTimer = TimerInit() ;~ Local $sPath = @ScriptDir ; yes, you can copy the files anywhere and use it portable Local $sPath = "C:\Program Files\smartmontools\bin" If Not FileGetSize($sPath & "\smartctl.exe") Then ConsoleWrite(@CRLF & '--- get the utility package from "https://www.smartmontools.org/wiki/Download#InstalltheWindowspackage"' & @CRLF & @CRLF) Exit 5 EndIf ;~ Local $sRet = _RunWaitEx("smartctl.exe --scan --json=o", @ScriptDir) ; chopping strings is less complicated Local $sRet = _RunWaitEx("smartctl.exe --scan", $sPath) ;~ ConsoleWrite(_RunWaitEx_LastExtended() & @CRLF & $sRet & @CRLF) Local $aTemp, $aData = StringSplit($sRet, @CRLF, 1) Local $aDevices[UBound($aData)][10] = [[0]] For $n = 1 To $aData[0] $aTemp = StringSplit($aData[$n], " ", 0) If UBound($aTemp) < 4 Then ContinueLoop $aDevices[0][0] += 1 $aDevices[$aDevices[0][0]][0] = StringReplace($aTemp[1], "/dev/", "") $aDevices[$aDevices[0][0]][1] = $aTemp[3] Next ReDim $aDevices[$aDevices[0][0] + 1][21] Local $iChop = 0, $sInfo1, $sInfo2 For $n = 1 To $aDevices[0][0] If $aDevices[$n][1] <> "nvme" Then ContinueLoop $sRet = _RunWaitEx("smartctl.exe -A -i " & $aDevices[$n][0], $sPath) $aData = StringSplit($sRet, @CRLF, 1) For $iData = 1 To $aData[0] If Not $iChop Then $iChop = StringInStr($aData[$iData], " ", 0, -1) If $iChop Then $iChop += 2 EndIf If Not $iChop Then ContinueLoop $sInfo1 = StringStripWS(StringLeft($aData[$iData], $iChop), 3) $sInfo2 = StringTrimLeft($aData[$iData], $iChop) Switch $sInfo1 Case "Model Number:" $aDevices[$n][3] = $sInfo2 Case "Serial Number:" $aDevices[$n][4] = $sInfo2 Case "Total NVM Capacity:" $aDevices[$n][5] = $sInfo2 Case "Critical Warning:" $aDevices[$n][6] = $sInfo2 Case "Temperature:" $aDevices[$n][7] = $sInfo2 Case "Available Spare:" $aDevices[$n][8] = $sInfo2 Case "Available Spare Threshold:" $aDevices[$n][9] = $sInfo2 Case "Percentage Used:" $aDevices[$n][10] = $sInfo2 Case "Data Units Read:" $aDevices[$n][11] = $sInfo2 Case "Data Units Written:" $aDevices[$n][12] = $sInfo2 Case "Power Cycles:" $aDevices[$n][13] = $sInfo2 Case "Power On Hours:" $aDevices[$n][14] = $sInfo2 Case "Unsafe Shutdowns:" $aDevices[$n][15] = $sInfo2 Case "Media and Data Integrity Errors:" $aDevices[$n][16] = $sInfo2 Case "Error Information Log Entries:" $aDevices[$n][17] = $sInfo2 Case "Warning Comp. Temperature Time:" $aDevices[$n][18] = $sInfo2 Case "Critical Comp. Temperature Time:" $aDevices[$n][19] = $sInfo2 Case "Temperature Sensor 1:" $aDevices[$n][20] = $sInfo2 EndSwitch Next Next Local $sHeader = "DEV|Type| |Model Number|Serial Number|Total NVM Capacity|Critical Warning|Temperature|Available Spare|" & _ "Available Spare Threshold|Percentage Used|Data Units Read|Data Units Written|Power Cycles|" & _ "Power On Hours|Unsafe Shutdowns|Media and Data Integrity Errors|Error Information Log Entries|" & _ "Warning Comp. Temperature Time|Critical Comp. Temperature Time|Temperature Sensor 1" _DebugArrayDisplay($aDevices, TimerDiff($hTimer), "", 0, Default, $sHeader) Return $aDevices ; if you're gonna use the data elsewhere EndFunc ;==>main It looks more like a snippet than an example but this way will be easier to find the post. ioa747 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now