projects
/
zfs-nexenta
/
.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Moved old zfs-replicate scripts out of the way.
[zfs-nexenta/.git]
/
zfs-log-parser
diff --git
a/zfs-log-parser
b/zfs-log-parser
index 5c280032b97c63149c2411ca89e980aba24fc0d1..4ecca3c37e59db5a4aaeecfa9dea6277b4dda928 100755
(executable)
--- 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});
$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";
}
}
print "$date: data=${data} transfertime=$transfertime rate=${rate}/sec duration=$duration\n";
}
}
@@
-91,9
+95,13
@@
sub parse_snapshot_totals_logfile {
%totals=();
$in_totals=0;
$maxlen=0;
%totals=();
$in_totals=0;
$maxlen=0;
+ $found_startdate=0;
$header="";
while(<FILE>) {
$line = $_;
$header="";
while(<FILE>) {
$line = $_;
+ if($line =~ /logfile turned over/) { next; }
+ if(($in_totals == 0) && ("$startdate" ne "") && ($line !~ /$startdate/) && ($found_startdate==0)) { next; }
+ if(($in_totals == 0) && ("$startdate" ne "") && ($line =~ /$startdate/) && ($found_startdate==0)) { $found_startdate=1; }
if(($in_totals == 0) && ($line =~ /(\S+)\s+(\S+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\S+)\s+(\S+)/)) {
$dayname=$1; $month=$2; $daynum=$3; $hour=$4; $minute=$5; $sec=$6; $year=$8;
$in_totals = 1;
if(($in_totals == 0) && ($line =~ /(\S+)\s+(\S+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\S+)\s+(\S+)/)) {
$dayname=$1; $month=$2; $daynum=$3; $hour=$4; $minute=$5; $sec=$6; $year=$8;
$in_totals = 1;
@@
-103,12
+111,12
@@
sub parse_snapshot_totals_logfile {
if(!defined $founddates{$date}) { $header .= $date . " "; }
$founddates{$date} = 1;
}
if(!defined $founddates{$date}) { $header .= $date . " "; }
$founddates{$date} = 1;
}
- if(($in_totals == 1) && ($line =~ /^\s+$/)) {
+
els
if(($in_totals == 1) && ($line =~ /^\s+$/)) {
$in_totals = 0;
}
$in_totals = 0;
}
-
if(($in_totals == 1) && ($line =~ /(\S+)\s+([\d\.]+
)(\w+)\s+(\d+)/)) {
+
elsif(($in_totals == 1) && ($line =~ /(\S+)\s+([\d\.]*
)(\w+)\s+(\d+)/)) {
$filesystem = $1; $data = $2; $size = $3; $num_snaps = $4;
$filesystem = $1; $data = $2; $size = $3; $num_snaps = $4;
- if($filesystem =~ /Snapshots/) { next; }
+ if($filesystem =~ /Snapshots/
|| $filesystem =~ /Total/
) { next; }
if($filesystem =~ /$backup_pool/) { next; }
if(length($filesystem) > $maxlen) { $maxlen = length($filesystem); }
if($size =~ /K/i) { $data = $data * $kilo; }
if($filesystem =~ /$backup_pool/) { next; }
if(length($filesystem) > $maxlen) { $maxlen = length($filesystem); }
if($size =~ /K/i) { $data = $data * $kilo; }
@@
-128,6
+136,7
@@
sub parse_snapshot_totals_logfile {
foreach $date (sort keys %$hashref) {
if($date !~ /(\d+)-(\d+)-(\d+)/) { next; }
$date_data=adjust_data($totals{$filesystem}{$date}{data});
foreach $date (sort keys %$hashref) {
if($date !~ /(\d+)-(\d+)-(\d+)/) { next; }
$date_data=adjust_data($totals{$filesystem}{$date}{data});
+ if($date_data eq "") { $date_data = "0"; }
$data .= sprintf("%10s",$date_data). " ";
$date_totals{$date}{data} += $totals{$filesystem}{$date}{data};
}
$data .= sprintf("%10s",$date_data). " ";
$date_totals{$date}{data} += $totals{$filesystem}{$date}{data};
}
@@
-150,7
+159,11
@@
sub parse_snapshot_totals_logfile {
# MAIN
#########
#print "-> Parsing $logfile\n";
# MAIN
#########
#print "-> Parsing $logfile\n";
-open(FILE,"$logfile") || die "-E- Unable to open $logfile\n";
+if("$logfile" =~ /\.[bz2|gz]/) {
+ open(FILE,"zcat $logfile|") || die "-E- Unable to open $logfile\n";
+} else {
+ open(FILE,"$logfile") || die "-E- Unable to open $logfile\n";
+}
if($logfile =~ /replicate/) { parse_replicate_logfile(); }
if($logfile =~ /snapshot-totals/) { parse_snapshot_totals_logfile(); }
if($logfile =~ /replicate/) { parse_replicate_logfile(); }
if($logfile =~ /snapshot-totals/) { parse_snapshot_totals_logfile(); }