Last active
November 5, 2024 07:03
-
-
Save eddiezato/58d72266222b2607c7234369f28df9b9 to your computer and use it in GitHub Desktop.
PowerShell: script to monitor SSD total lbas writes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-Location $PSScriptRoot | |
$tJson = .\smartctl.exe -j -A /dev/sda | ConvertFrom-Json | |
$totallba = ($tJson.ata_smart_attributes.table | where { $_.id -eq 241 }).raw.value | |
$lasttlba = Get-Content -Path "last" | |
$inGB = ([Math]::Round($totallba * 512 / 1GB, 2)).ToString("0.00") | |
$diff = ([Math]::Round(($totallba - $lasttlba) * 512 / 1MB, 2)).ToString("0.00") | |
$curDT = (Get-Date -Format "yyyy/MM/dd HH:mm:ss") | |
Add-Content -Path "ssd.log" -Value "$curDT $inGB GiB +$diff MiB" | |
Set-Content -Path "last" -Value $totallba |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment