From 698062c29aad5253bc10d488958de289055429e5 Mon Sep 17 00:00:00 2001
From: "Alan J. Pippin" <ajp@pippins.net>
Date: Thu, 21 Aug 2008 21:16:47 -0600
Subject: [PATCH] Updated log file location to dump to /var/log/zfs instead of
 /var/log

---
 zfs-autosnap             | 2 +-
 zfs-autosnap-wrapper     | 2 +-
 zfs-log-parser           | 6 +++++-
 zfs-replicate            | 2 +-
 zfs-replicate-wrapper    | 2 +-
 zfs-scrub                | 2 +-
 zfs-scrub-usb-drive      | 2 +-
 zfs-snapshot-totals-cron | 2 +-
 8 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/zfs-autosnap b/zfs-autosnap
index 7273e57..795c802 100755
--- a/zfs-autosnap
+++ b/zfs-autosnap
@@ -7,7 +7,7 @@
 
 test=0
 
-[ $test == 0 ] && exec >> /var/log/zfs-autosnap.log 2>&1
+[ $test == 0 ] && exec >> /var/log/zfs/zfs-autosnap.log 2>&1
 
 # This script makes the following assumptions/requirements:
 #  * this script only handles one zfs filesystem, a wrapper should be created
diff --git a/zfs-autosnap-wrapper b/zfs-autosnap-wrapper
index 2e500e1..ad8f4fc 100755
--- a/zfs-autosnap-wrapper
+++ b/zfs-autosnap-wrapper
@@ -6,7 +6,7 @@
 
 # Setup some default values
 autosnap="/usr/local/etc/bin/zfs-autosnap"
-logfile="/var/log/zfs-autosnap.log"
+logfile="/var/log/zfs/zfs-autosnap.log"
 numsnapshots=20
 maxagedays=365
 
diff --git a/zfs-log-parser b/zfs-log-parser
index c277e14..2167493 100755
--- a/zfs-log-parser
+++ b/zfs-log-parser
@@ -82,7 +82,11 @@ sub parse_replicate_logfile {
 	$duration=adjust_duration($totals{$date}{duration});
 	$data=adjust_data($totals{$date}{data});
 	$transfertime=adjust_duration($totals{$date}{transfertime});
-	$rate = adjust_data(int($totals{$date}{data}/$totals{$date}{transfertime}));
+        if($totals{$date}{transfertime} > 0) { 
+	  $rate = adjust_data(int($totals{$date}{data}/$totals{$date}{transfertime}));
+        } else { 
+          $rate = 0;
+        }
 	print "$date: data=${data} transfertime=$transfertime rate=${rate}/sec duration=$duration\n";
     }
 }
diff --git a/zfs-replicate b/zfs-replicate
index f878518..9a6b82e 100755
--- a/zfs-replicate
+++ b/zfs-replicate
@@ -10,7 +10,7 @@
 # In test mode (test=1) commands are echoed, not executed
 test=0
 
-[ $test == 0 ] && exec >> /var/log/zfs-replicate.log 2>&1
+[ $test == 0 ] && exec >> /var/log/zfs/zfs-replicate.log 2>&1
 
 # Usage: zfs-backup [filesystem] [destination_pool]
 # This script has a limitation with children under a given filesystem.
diff --git a/zfs-replicate-wrapper b/zfs-replicate-wrapper
index cd81593..faeaeb0 100755
--- a/zfs-replicate-wrapper
+++ b/zfs-replicate-wrapper
@@ -7,7 +7,7 @@
 # Setup some default values
 replicate="/usr/local/etc/bin/zfs-replicate"
 logfile_parser="/usr/local/etc/bin/zfs-log-parser"
-logfile="/var/log/zfs-replicate.log"
+logfile="/var/log/zfs/zfs-replicate.log"
 lockdir="/tmp/zfs-admin-lock"
 destpool="backups"
 maxsleeptime=60
diff --git a/zfs-scrub b/zfs-scrub
index 2bff3d3..1b068d4 100755
--- a/zfs-scrub
+++ b/zfs-scrub
@@ -7,7 +7,7 @@
 #              This serializes the zfs scrub process for each pool.
 
 maxsleeptime=360
-logfile=/var/log/zfs-scrub.log
+logfile=/var/log/zfs/zfs-scrub.log
 
 for i in tank storage
 do
diff --git a/zfs-scrub-usb-drive b/zfs-scrub-usb-drive
index 1b73505..6136fab 100755
--- a/zfs-scrub-usb-drive
+++ b/zfs-scrub-usb-drive
@@ -8,7 +8,7 @@
 
 maxsleeptime=360
 mailto=root
-logfile=/var/log/zfs-scrub.log
+logfile=/var/log/zfs/zfs-scrub.log
 
 for i in backups
 do
diff --git a/zfs-snapshot-totals-cron b/zfs-snapshot-totals-cron
index e2eb9ed..726ce3c 100755
--- a/zfs-snapshot-totals-cron
+++ b/zfs-snapshot-totals-cron
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 snapshot_totals="/usr/local/etc/bin/zfs-snapshot-totals"
-logfile="/var/log/zfs-snapshot-totals.log"
+logfile="/var/log/zfs/zfs-snapshot-totals.log"
 
 date >> $logfile
 $snapshot_totals >> $logfile
-- 
2.34.1