howe icon indicating copy to clipboard operation
howe copied to clipboard

Support displaying S.M.A.R.T. status

Open Greybane opened this issue 6 years ago • 2 comments

I've managed to hack something together using smartctl but It's not very pretty compared to the rest of the output.

I'd be real neat to see current status, drive hours, time of last self-test and what type (short/extended).

Greybane avatar Dec 25 '18 13:12 Greybane

@Greybane not sure if you're still looking for something along these lines but I threw this together, made available via my bin dir, then executed via howe.

Example Output: Screenshot 2024-01-27 at 12 46 58

#!/bin/bash

# Check if smartctl is installed
command -v smartctl > /dev/null 2>&1
if [ $? -ne 0 ]; then
  echo "Error: smartctl command not found. Please install smartmontools."
  exit 1
fi

bold=$(tput bold)
yellow=$(tput setaf 3)
reset=$(tput sgr0)

# Get a list of all hard drives
drives=$(lsblk -o NAME -n -d | grep -E '^sd|^hd')

# Display assessments for each drive
output+='\nDrive\tStatus\tTemp\tCycles'
for drive in $drives; do
  smartResult=$(sudo smartctl -AH /dev/$drive)

  # echo $smartResult
  assessment=$(sudo smartctl -AH /dev/$drive | awk '/self-assessment/{print $6}')
  cycles=$(sudo smartctl -AH /dev/$drive | awk '/Power_Cycle_Count/{print $10}')
  temperature=$(sudo smartctl -AH /dev/$drive | awk '/Temperature_Celsius/{print $10}')

  output+="\n$yellow$drive:$reset\t$assessment\t$temperature\t$cycles"
done

echo -e $output

maverick1872 avatar Jan 27 '24 20:01 maverick1872

I will say the advantage to this being separated from howe implementation itself, is that it's easily portable and executable standalone.

maverick1872 avatar Jan 27 '24 20:01 maverick1872