/[cricket]/parse_omni.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /parse_omni.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by dpavlin, Mon Sep 9 18:36:29 2002 UTC revision 1.2 by dpavlin, Tue Sep 10 08:12:17 2002 UTC
# Line 13  Line 13 
13  #       parse_omni.pl [/path/to/omnistat]  #       parse_omni.pl [/path/to/omnistat]
14  #  #
15  # Warning: I am not sure that I can catch all types which are known to  # Warning: I am not sure that I can catch all types which are known to
16  # omnistat. So far, I check and report following ones:  # omnistat. So far, I check and report events which are in @stat.
 #  
 #       Aborted  
 #       Completed  
 #       Completed/Errors  
 #       Completed/Failures  
 #       Failed  
 #       In Progress  
 #  
17  # All other (if there are any) will be reported as other (I really need to  # All other (if there are any) will be reported as other (I really need to
18  # re-read OmniBack documentation!)  # re-read OmniBack documentation!)
19    
# Line 30  use strict; Line 22  use strict;
22  my $omnistat= shift @ARGV || "/usr/omni/bin/omnistat";  my $omnistat= shift @ARGV || "/usr/omni/bin/omnistat";
23    
24  my @stat = (  my @stat = (
25    #       '------------------' output width
26          'In Progress',          'In Progress',
27            'In Progress/Failur',
28            'Queuing',
29          'Aborted',          'Aborted',
30            'Failed',
31          'Completed',          'Completed',
32          'Completed/Errors',          'Completed/Errors',
33          'Completed/Failures',          'Completed/Failure',
         'Failed',  
34          );          );
35    
36    my $debug = 0;
37    
38  my %backup;  my %backup;
39  my %restore;  my %restore;
40    
41  open(O,"$omnistat |") || die "can't start $omnistat !";  open(O,"$omnistat |") || die "can't start $omnistat !";
42    
43    my $header = <O>;
44    chomp $header;
45    # SessionID Type Status User
46    $header =~ m/^(\w+\s+)(\w+\s+)(\w+\s+)(\w+\s+)/;
47    
48    my $tf = length($1);    # Type from pos
49    my $tl = length($2);    # Type len
50    my $sf = $tf+$tl;       # Status from pos
51    my $sl = length($3);    # Status len
52    
53    my $media = 0;
54    
55  while(<O>) {  while(<O>) {
56          chomp;          chomp;
57          my @arr = split(/  +/,$_,4);          my $type = substr($_,$tf,$tl);
58          next if ($#arr != 3);          $type =~ s/ +$//;
59            my $status = substr($_,$sf,$sl);
60          if ($arr[1] =~ m/Backup/i) {          $status =~ s/ +$//;
61                  $backup{$arr[2]}++;  
62          } elsif ($arr[1] =~ m/Restore/i) {          if ($type =~ m/Backup/i) {
63                  $restore{$arr[2]}++;                  $backup{$status}++;
64          } elsif ($arr[1] !~ m/Type/) {          } elsif ($type =~ m/Restore/i) {
65                    $restore{$status}++;
66            } elsif ($type =~ m/Media/i) {
67                    $media++;
68            } elsif ($type !~ m/=+/) {
69                  # don't report this on header!                  # don't report this on header!
70                  print STDERR "unknown type: $arr[1]";                  print STDERR "unknown type: $type";
71          }          }
72  }  }
73  close(O);  close(O);
74    
75  # dump backup data  # dump data
76    
77  foreach (@stat) {  foreach (@stat) {
78            print STDERR "$_: " if ($debug);
79          if (defined $backup{$_}) {          if (defined $backup{$_}) {
80                  print $backup{$_},"\n";                  print $backup{$_},"\n";
81                  delete $backup{$_};                  delete $backup{$_};
82          } else {          } else {
83                  print "0\n";                  print "0\n";
84          }          }
85            if (defined $restore{$_}) {
86                    print $restore{$_},"\n";
87                    delete $restore{$_};
88            } else {
89                    print "0\n";
90            }
91  }  }
92    
93    # dump backup other
94    
95  my $other;  my $other;
96  foreach (keys %backup) {  foreach (keys %backup) {
97            print STDERR "other backup: -->$_<--\n" if ($debug);
98          $other += $backup{$_};          $other += $backup{$_};
99  }  }
100  print $other || "0\n";  print $other || "0\n";
101    
102  # dump restore data  # dump restore other
103    
 foreach (@stat) {  
         if (defined $restore{$_}) {  
                 print $restore{$_},"\n";  
                 delete $restore{$_};  
         } else {  
                 print "0\n";  
         }  
 }  
104  undef $other;  undef $other;
105  foreach (keys %restore) {  foreach (keys %restore) {
106            print STDERR "other restore -->$_<--\n" if ($debug);
107          $other += $restore{$_};          $other += $restore{$_};
108  }  }
109  print $other || "0\n";  print $other || "0\n";
110    
111    print "$media\n";
112    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.26