Skip to content

Instantly share code, notes, and snippets.

@theAkito
Last active December 14, 2022 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theAkito/d3ceb3ce35e4331c70babc2382a7578a to your computer and use it in GitHub Desktop.
Save theAkito/d3ceb3ce35e4331c70babc2382a7578a to your computer and use it in GitHub Desktop.
Get most significant S.M.A.R.T. attribute data with Nu
# Runs in Nushell. https://www.nushell.sh/
# Replace `/dev/sda` with whatever drive you want to inspect.
# The `-d sat` option might vary in your case.
# Most of the time, you do not need this option, at all.
smartctl -ajd sat /dev/sda | from json
| get ata_smart_attributes.table
| select name raw
| rename -c [ raw count ]
| update cells -c [ count ] { |value| $value.value }
| where name =~ 'Reallocated_Sector_Ct|Current_Pending_Sector|Offline_Uncorrectable'
| insert status OK
| each { |row|
if $row.count > 0 {
$row | update status FAIL
} else { $row }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment