/[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.4 by dpavlin, Tue Sep 10 18:09:24 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            'In Progress/Errors',
29            'Queuing',
30          'Aborted',          'Aborted',
31            'Failed',
32          'Completed',          'Completed',
33          'Completed/Errors',          'Completed/Errors',
34          'Completed/Failures',          'Completed/Failure',
         'Failed',  
35          );          );
36    
37    my $debug = 0;
38    
39  my %backup;  my %backup;
40  my %restore;  my %restore;
41    
42  open(O,"$omnistat |") || die "can't start $omnistat !";  open(O,"$omnistat |") || die "can't start $omnistat !";
43    
44    my $header = <O>;
45    chomp $header;
46    # SessionID Type Status User
47    $header =~ m/^(\w+\s+)(\w+\s+)(\w+\s+)(\w+\s+)/;
48    
49    my $tf = length($1);    # Type from pos
50    my $tl = length($2);    # Type len
51    my $sf = $tf+$tl;       # Status from pos
52    my $sl = length($3);    # Status len
53    
54    my $media = 0;
55    
56  while(<O>) {  while(<O>) {
57          chomp;          chomp;
58          my @arr = split(/  +/,$_,4);          my $type = substr($_,$tf,$tl);
59          next if ($#arr != 3);          $type =~ s/ +$//;
60            my $status = substr($_,$sf,$sl);
61          if ($arr[1] =~ m/Backup/i) {          $status =~ s/ +$//;
62                  $backup{$arr[2]}++;  
63          } elsif ($arr[1] =~ m/Restore/i) {          if ($type =~ m/Backup/i) {
64                  $restore{$arr[2]}++;                  $backup{$status}++;
65          } elsif ($arr[1] !~ m/Type/) {          } elsif ($type =~ m/Restore/i) {
66                    $restore{$status}++;
67            } elsif ($type =~ m/Media/i) {
68                    $media++;
69            } elsif ($type !~ m/=+/) {
70                  # don't report this on header!                  # don't report this on header!
71                  print STDERR "unknown type: $arr[1]";                  print STDERR "unknown type: '$type'\n";
72          }          }
73  }  }
74  close(O);  close(O);
75    
76  # dump backup data  # dump data
77    
78  foreach (@stat) {  foreach (@stat) {
79            print STDERR "$_: " if ($debug);
80          if (defined $backup{$_}) {          if (defined $backup{$_}) {
81                  print $backup{$_},"\n";                  print $backup{$_},"\n";
82                  delete $backup{$_};                  delete $backup{$_};
83          } else {          } else {
84                  print "0\n";                  print "0\n";
85          }          }
86            if (defined $restore{$_}) {
87                    print $restore{$_},"\n";
88                    delete $restore{$_};
89            } else {
90                    print "0\n";
91            }
92  }  }
93    
94    # dump backup other
95    
96  my $other;  my $other;
97  foreach (keys %backup) {  foreach (keys %backup) {
98            print STDERR "unknown status backup: '$_'\n";
99          $other += $backup{$_};          $other += $backup{$_};
100  }  }
101  print $other || "0\n";  print $other || "0\n";
102    
103  # dump restore data  # dump restore other
104    
 foreach (@stat) {  
         if (defined $restore{$_}) {  
                 print $restore{$_},"\n";  
                 delete $restore{$_};  
         } else {  
                 print "0\n";  
         }  
 }  
105  undef $other;  undef $other;
106  foreach (keys %restore) {  foreach (keys %restore) {
107            print STDERR "unkwown status restore: '$_'\n";
108          $other += $restore{$_};          $other += $restore{$_};
109  }  }
110  print $other || "0\n";  print $other || "0\n";
111    
112    print "$media\n";
113    

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

  ViewVC Help
Powered by ViewVC 1.1.26