Advertisement
Guest User

SmartMonTools Script

a guest
Mar 29th, 2012
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.99 KB | None | 0 0
  1. #!/usr/bin/bash
  2. [ ! "$@" ] && echo "Usage: $0 type [type] [type]"
  3.  
  4. [ ! -e smart-logs ] && mkdir smart-logs
  5. [ ! -d smart-logs ] && Can not create smart-logs dir && exit 1
  6.  
  7. a=0
  8.  
  9. for t in "$@"; do
  10.  
  11.         case "$t" in
  12.                 offline)  l=error;;
  13.                 short|long)  l=selftest;;
  14.                 *) echo $t is an unrecognised test type. Skipping... && continue
  15.         esac
  16.  
  17.        for hd in  /dev/disk/by-id/ata*; do
  18.                 r=$(( $(smartctl -t $t -d ata $hd | grep 'Please wait' | awk '{print $3}') ))
  19.                 echo Check $hd - $t test in $r minutes
  20.                 [ $r -gt $a ] && a=$r
  21.        done
  22.      echo "Waiting $a minutes for all tests to complete"
  23.                 sleep $(($a)) m
  24.  
  25.         for hd in /dev/disk/by-id/ata*; do
  26.                 smartctl -l $l -d ata $hd 2>&1 >> smart-logs/smart-${t}-${hd##*/}.log
  27.         done
  28.  
  29.        
  30. done
  31.  
  32. for i in {1..10}; do
  33.         sleep .01
  34.         echo -n -e \\a
  35. done
  36.  
  37. echo "All tests have completed"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement