From 20a696fe558ae539023864c047543bb2e0e9f1a3 Mon Sep 17 00:00:00 2001 From: "Alan J. Pippin" Date: Wed, 12 Mar 2008 10:14:46 -0600 Subject: [PATCH] Fixed bug when parsing filesystems that have no data on a given date. --- zfs-log-parser | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zfs-log-parser b/zfs-log-parser index dbb3c15..f3619db 100755 --- a/zfs-log-parser +++ b/zfs-log-parser @@ -107,9 +107,9 @@ sub parse_snapshot_totals_logfile { elsif(($in_totals == 1) && ($line =~ /^\s+$/)) { $in_totals = 0; } - elsif(($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; - 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; } @@ -129,6 +129,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}); + if($date_data eq "") { $date_data = "0"; } $data .= sprintf("%10s",$date_data). " "; $date_totals{$date}{data} += $totals{$filesystem}{$date}{data}; } -- 2.34.1