Advertisement
Flo_R1der

SMART healthcheck

May 13th, 2023
784
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.32 KB | Source Code | 0 0
  1. # $1=device(sda/sdb), $2=type(ssd/hdd)
  2.  function fn_run_smartcheck () {
  3.          SMART_LOGFILE=$BCKP_DATA/healthcheck_$2_$1_$(date +%Y-%m-%d).txt
  4.      sudo smartctl -t short -a /dev/$1 > $SMART_LOGFILE
  5.      
  6.          if [[ $2 == "ssd" ]]; then fn_print_results_ssd $1; fi
  7.          if [[ $2 == "hdd" ]]; then fn_print_results_hdd $1; fi
  8.      
  9.          echo
  10.          echo
  11.  }
  12.  
  13.  # $1=device(sda/sdb)
  14.  function fn_print_results_ssd () {
  15.          echo "=> SSD-Life Overview:"
  16.          cat $SMART_LOGFILE | \
  17.          grep "Device Model:\|Rotation Rate:\|Form Factor:\|overall-health"
  18.          echo  
  19.          cat $SMART_LOGFILE | \
  20.          grep "ID#\|Raw_Read_Error_Rate\|Reallocated_Sector_Ct\|Power_On_Hours\|Power_Cycle_Count"
  21.          cat $SMART_LOGFILE | \
  22.          grep "Temperature_Celsius\|Total_LBAs_Written\|Total_LBAs_Read"
  23.  }
  24.  
  25.  # $1=device(sda/sdb)
  26.  function fn_print_results_hdd () {
  27.          echo "=> HDD-Life Overview:"
  28.          cat $SMART_LOGFILE | \
  29.          grep "Device Model:\|Rotation Rate:\|Form Factor:\|overall-health"
  30.          echo  
  31.          cat $SMART_LOGFILE | \
  32.          grep "ID#\|Raw_Read_Error_Rate\|Spin_Up_Time\|Start_Stop_Count"
  33.          cat $SMART_LOGFILE | \
  34.          grep "Reallocated_Sector_Ct\|Power_On_Hours\|Power_Cycle_Count\|Temperature_Celsius"
  35.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement