--- parse_omni.pl 2002/09/09 18:36:29 1.1 +++ parse_omni.pl 2002/09/10 18:09:24 1.4 @@ -13,15 +13,7 @@ # parse_omni.pl [/path/to/omnistat] # # Warning: I am not sure that I can catch all types which are known to -# omnistat. So far, I check and report following ones: -# -# Aborted -# Completed -# Completed/Errors -# Completed/Failures -# Failed -# In Progress -# +# omnistat. So far, I check and report events which are in @stat. # All other (if there are any) will be reported as other (I really need to # re-read OmniBack documentation!) @@ -30,63 +22,92 @@ my $omnistat= shift @ARGV || "/usr/omni/bin/omnistat"; my @stat = ( +# '------------------' output width 'In Progress', + 'In Progress/Failur', + 'In Progress/Errors', + 'Queuing', 'Aborted', + 'Failed', 'Completed', 'Completed/Errors', - 'Completed/Failures', - 'Failed', + 'Completed/Failure', ); +my $debug = 0; + my %backup; my %restore; open(O,"$omnistat |") || die "can't start $omnistat !"; + +my $header = ; +chomp $header; +# SessionID Type Status User +$header =~ m/^(\w+\s+)(\w+\s+)(\w+\s+)(\w+\s+)/; + +my $tf = length($1); # Type from pos +my $tl = length($2); # Type len +my $sf = $tf+$tl; # Status from pos +my $sl = length($3); # Status len + +my $media = 0; + while() { chomp; - my @arr = split(/ +/,$_,4); - next if ($#arr != 3); - - if ($arr[1] =~ m/Backup/i) { - $backup{$arr[2]}++; - } elsif ($arr[1] =~ m/Restore/i) { - $restore{$arr[2]}++; - } elsif ($arr[1] !~ m/Type/) { + my $type = substr($_,$tf,$tl); + $type =~ s/ +$//; + my $status = substr($_,$sf,$sl); + $status =~ s/ +$//; + + if ($type =~ m/Backup/i) { + $backup{$status}++; + } elsif ($type =~ m/Restore/i) { + $restore{$status}++; + } elsif ($type =~ m/Media/i) { + $media++; + } elsif ($type !~ m/=+/) { # don't report this on header! - print STDERR "unknown type: $arr[1]"; + print STDERR "unknown type: '$type'\n"; } } close(O); -# dump backup data +# dump data foreach (@stat) { + print STDERR "$_: " if ($debug); if (defined $backup{$_}) { print $backup{$_},"\n"; delete $backup{$_}; } else { print "0\n"; } + if (defined $restore{$_}) { + print $restore{$_},"\n"; + delete $restore{$_}; + } else { + print "0\n"; + } } + +# dump backup other + my $other; foreach (keys %backup) { + print STDERR "unknown status backup: '$_'\n"; $other += $backup{$_}; } print $other || "0\n"; -# dump restore data +# dump restore other -foreach (@stat) { - if (defined $restore{$_}) { - print $restore{$_},"\n"; - delete $restore{$_}; - } else { - print "0\n"; - } -} undef $other; foreach (keys %restore) { + print STDERR "unkwown status restore: '$_'\n"; $other += $restore{$_}; } print $other || "0\n"; +print "$media\n"; +