Skip to content

Instantly share code, notes, and snippets.

@eddiezato
Created January 9, 2022 05:17
Show Gist options
  • Save eddiezato/58d72266222b2607c7234369f28df9b9 to your computer and use it in GitHub Desktop.
Save eddiezato/58d72266222b2607c7234369f28df9b9 to your computer and use it in GitHub Desktop.
Monitor SSD total lbas writes
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