Fixed a race condition that could lead to 2 scrubs running simultaneously.
authorAlan J. Pippin <ajp@pippins.net>
Tue, 18 Mar 2008 02:03:10 +0000 (20:03 -0600)
committerAlan J. Pippin <ajp@pippins.net>
Tue, 18 Mar 2008 02:03:10 +0000 (20:03 -0600)
Added logging support.

zfs-scrub
zfs-scrub-usb-drive

index f022a54d1c86272edd2c664e2d2ddd8d29504d09..2bff3d367539d6e8ff6c77ac6328ba0cb351c97f 100755 (executable)
--- a/zfs-scrub
+++ b/zfs-scrub
@@ -7,6 +7,7 @@
 #              This serializes the zfs scrub process for each pool.
 
 maxsleeptime=360
+logfile=/var/log/zfs-scrub.log
 
 for i in tank storage
 do
@@ -25,7 +26,9 @@ do
     fi
   done
 
-  echo "Scrubing zfs pool $i"
+  date=`date`
+  echo "$date: Scrub started for zfs pool $i" >> $logfile
   /sbin/zpool scrub $i
+  sleep 60
 
 done
index 8a07e5cae10d8c533b6cde8a64fa57a28587bf94..1b735052667ba5a00f96c808e2a054da5a14fdc0 100755 (executable)
@@ -8,6 +8,7 @@
 
 maxsleeptime=360
 mailto=root
+logfile=/var/log/zfs-scrub.log
 
 for i in backups
 do
@@ -26,8 +27,9 @@ do
     fi
   done
 
-  echo "Scrubing zfs pool $i"
-  /usr/local/etc/bin/usb-drive-power on
+  date=`date`
+  echo "$date: Scrub started for zfs pool $i" >> $logfile
+  /usr/local/etc/bin/usb-drive-power on >> /dev/null
   /sbin/zpool import $i
   /sbin/zpool scrub $i
 
@@ -45,6 +47,9 @@ do
     fi
   done
 
+  date=`date`
+  echo "$date: Scrub completed for zfs pool $i" >> $logfile
+
   # Check for any scrub errors
   /sbin/zpool status $i | grep scrub: | grep "with 0 errors" > /dev/null 2>&1
   if [ $? != 0 ]; then
@@ -54,7 +59,7 @@ do
 
   # Power off the USB drive
   /sbin/zpool export $i
-  /usr/local/etc/bin/usb-drive-power off
+  /usr/local/etc/bin/usb-drive-power off >> /dev/null
 
 done