JohnnyGrey86

Looping Resilver Monitor

Mar 14th, 2020
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.54 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # A simple looping script to display the
  4. # resilvering progress of a specific pool.
  5. # Idea came from Technicus, and lots of Googling!
  6. # Ctrl + C to kill the script
  7.  
  8.  
  9. # Specify the name of the pool to monitor. Case sensitive!
  10.  
  11. POOL=Pool_Name_Here
  12.  
  13. # Define how often, in seconds, that the
  14. # screen refreshes. Decimals do work, but 1-2 seconds
  15. # should work best
  16.  
  17. INTERVAL=2
  18.  
  19. for (( ; ; ))
  20. do
  21.         Percent=$(zpool status Tank | awk '/done/ {print $3}')
  22.         TimeStarted=$(zpool status Tank | awk '/since/ {print $6, $7, $8, $10, $9}')
  23.         ScanSpeed=$(zpool status $POOL | awk '/scanned/ {print substr($4, 1, length($4)-1)}')
  24.         ScanTotal=$(zpool status $POOL | awk '/scanned/ {print $1}')
  25.         IssueSpeed=$(zpool status $POOL | awk '/issued/ {print substr($8, 1, length($2)-1)}')
  26.         IssueTotal=$(zpool status $POOL | awk '/issued/ {print $9}')
  27.         Resilvered=$(zpool status $POOL | awk '/resilvered/ {print $1}')
  28.         ETA=$(zpool status Tank | awk '/done/ {print $5, $6, $7}')
  29.         clear
  30.         echo "----------Resilver Progress-------------"
  31.         echo "Pool:     $POOL"
  32.         echo "Started:  $TimeStarted"
  33.         echo "Progress: $Percent"
  34.         echo "ETA:      $ETA"
  35.         echo "-----------Resilver  Stats--------------"
  36.         echo "Scan Speed:     $ScanSpeed"
  37.         echo "Amount Scanned: $ScanTotal"
  38.         echo "Issue Speed:    $IssueSpeed"
  39.         echo "Amount Issued:  $IssueTotal"
  40.         echo "----------------------------------------"
  41.         sleep $INTERVAL
  42. done
Advertisement
Add Comment
Please, Sign In to add comment