Advertisement
Guest User

Troubleshoot.sh

a guest
May 2nd, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #!/bin/bash
  2. # Troubleshoot.sh
  3. # A more elaborate version of Troubleshoot.sh.
  4.  
  5. SUCCESS=0
  6. E_DB=99 # Error code for missing entry.
  7.  
  8. declare -A address
  9. # -A option declares associative array.
  10.  
  11.  
  12.  
  13. if [ -f Troubleshoot.log ]
  14. then
  15. rm Troubleshoot.log
  16. fi
  17.  
  18. if [ -f HDs.log ]
  19. then
  20. rm HDs.log
  21. fi
  22.  
  23. smartctl --scan | awk '{print $1}' >> HDs.log
  24. lspci | grep -i raid >> HDs.log
  25.  
  26. getArray ()
  27. {
  28. i=0
  29. while read line # Read a line
  30. do
  31. array[i]=$line # Put it into the array
  32. i=$(($i + 1))
  33. done < $1
  34. }
  35.  
  36. getArray "HDs.log"
  37.  
  38.  
  39. for e in "${array[@]}"
  40. do
  41. if [[ $e =~ /dev/sd* || $e =~ /dev/hd* ]]
  42. then
  43. echo "smartctl -i -A $e" >> Troubleshoot.log
  44. smartctl -i -A $e >> Troubleshoot.log # Run smartctl into all disks that the host have
  45. fi
  46. done
  47. exit $? # In this case, exit code = 99, since that is function return.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement