Dodany przez: /usr/local/sbin/smartcheck, 11:18 11-04-2018

Nowy Pobierz
  1. #!/bin/bash
  2. #
  3.  
  4. SMARTCTL=`which smartctl 2>/dev/null`
  5.  
  6. if [ -z $SMARTCTL ] || [ ! -x $SMARTCTL ]; then
  7.  echo "It seems you have no smartmontools installed. "
  8.  echo "Invoke 'apt install smartmontools' and re-run script"
  9.  exit 1
  10. fi
  11.  
  12. function check {
  13. tmp_parm=`mktemp`
  14. tmp_name=`mktemp`
  15. $SMARTCTL -A $1 | sed -r 's/^\s+//g' > $tmp_parm
  16. $SMARTCTL -i $1| sed -r 's/^\s+//g' > $tmp_name
  17.  
  18. echo -e $1 - `egrep -m1 "Model " $tmp_name | awk '{$1="";$2=""; print  "Model:   "$0}'`
  19. echo -e $1 - `egrep -m1 "Device " $tmp_name | awk '{$1="";$2=""; print "Symbol:  "$0}'`
  20. echo -e $1 - `egrep -m1 "Serial " $tmp_name | awk '{$1="";$2=""; print "Seria:   "$0}'`
  21.  
  22. for val in 9 5 10 11 171 172 177 181 187 188 196 197 198 199 200 231 ; do
  23.  print=`egrep "^$val " $tmp_parm | awk '{ print $2" = "$10 }'`
  24.   if [ ! -z "$print" ]; then
  25.    echo -n "$1: "
  26.   if  [[ `echo $print | grep "Power_On_Hours" ` ]]; then
  27.    echo -e "\033[36;2m$print\033[0m"
  28.   elif [ `echo $print | awk '{ print $3 }'` != 0 ]; then
  29.    echo -e "\033[31;2m$print\033[0m"
  30.   else
  31.    echo -e "\033[32;2m$print\033[0m"
  32.   fi
  33.  fi
  34. done
  35.  
  36. echo
  37.  
  38.  
  39. rm -f $tmp_parm
  40. rm -r $tmp_name
  41.  
  42. }
  43.  
  44. if [ $# -gt 0 ]; then
  45.  devices=$@
  46. else
  47.  devices=`ls /dev/sd[a-z] 2>/dev/null ; ls /dev/nvme[0-9]n[0-9] 2>/dev/null`
  48. fi
  49.  
  50. echo
  51. if [ -b /dev/twe0 ]; then
  52.  check "-d 3ware,0 /dev/twe0"
  53.  check "-d 3ware,1 /dev/twe0"
  54. else
  55.  for d in $devices; do
  56.   check $d
  57.  done
  58. fi
  59.  
  60.  

Źródło:

Ostatnie wpisy

Linki

Funkcje