/[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

Annotation of /parse_omni.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations)
Tue Sep 10 18:09:24 2002 UTC (21 years, 7 months ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -0 lines
File MIME type: text/plain
new type, brown-bag fix

1 dpavlin 1.1 #!/usr/bin/perl -w
2     #
3     # cricket module which parses output from HP OmniBack omnistat command
4     # line utility (you need to have User Interface installed on machine
5     # on which you plan to run omni_parse.pl) and draws nice graphs about
6     # concurrent jobs (can be used to plan licenses)
7     #
8     # Dobrica Pavlinusic <dpavlin@rot13.org>
9     # http://www.rot13.org/~dpavlin/sysadm.html
10     #
11     # Usage:
12     #
13     # parse_omni.pl [/path/to/omnistat]
14     #
15     # Warning: I am not sure that I can catch all types which are known to
16 dpavlin 1.2 # omnistat. So far, I check and report events which are in @stat.
17 dpavlin 1.1 # All other (if there are any) will be reported as other (I really need to
18     # re-read OmniBack documentation!)
19    
20     use strict;
21    
22     my $omnistat= shift @ARGV || "/usr/omni/bin/omnistat";
23    
24     my @stat = (
25 dpavlin 1.2 # '------------------' output width
26 dpavlin 1.1 'In Progress',
27 dpavlin 1.2 'In Progress/Failur',
28 dpavlin 1.4 'In Progress/Errors',
29 dpavlin 1.2 'Queuing',
30 dpavlin 1.1 'Aborted',
31 dpavlin 1.2 'Failed',
32 dpavlin 1.1 'Completed',
33     'Completed/Errors',
34 dpavlin 1.2 'Completed/Failure',
35 dpavlin 1.1 );
36    
37 dpavlin 1.2 my $debug = 0;
38    
39 dpavlin 1.1 my %backup;
40     my %restore;
41    
42     open(O,"$omnistat |") || die "can't start $omnistat !";
43 dpavlin 1.2
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 dpavlin 1.1 while(<O>) {
57     chomp;
58 dpavlin 1.2 my $type = substr($_,$tf,$tl);
59     $type =~ s/ +$//;
60     my $status = substr($_,$sf,$sl);
61     $status =~ s/ +$//;
62    
63     if ($type =~ m/Backup/i) {
64     $backup{$status}++;
65     } elsif ($type =~ m/Restore/i) {
66     $restore{$status}++;
67     } elsif ($type =~ m/Media/i) {
68     $media++;
69     } elsif ($type !~ m/=+/) {
70 dpavlin 1.1 # don't report this on header!
71 dpavlin 1.3 print STDERR "unknown type: '$type'\n";
72 dpavlin 1.1 }
73     }
74     close(O);
75    
76 dpavlin 1.2 # dump data
77 dpavlin 1.1
78     foreach (@stat) {
79 dpavlin 1.2 print STDERR "$_: " if ($debug);
80 dpavlin 1.1 if (defined $backup{$_}) {
81     print $backup{$_},"\n";
82     delete $backup{$_};
83     } else {
84     print "0\n";
85     }
86 dpavlin 1.2 if (defined $restore{$_}) {
87     print $restore{$_},"\n";
88     delete $restore{$_};
89     } else {
90     print "0\n";
91     }
92 dpavlin 1.1 }
93 dpavlin 1.2
94     # dump backup other
95    
96 dpavlin 1.1 my $other;
97     foreach (keys %backup) {
98 dpavlin 1.3 print STDERR "unknown status backup: '$_'\n";
99 dpavlin 1.1 $other += $backup{$_};
100     }
101     print $other || "0\n";
102    
103 dpavlin 1.2 # dump restore other
104 dpavlin 1.1
105     undef $other;
106     foreach (keys %restore) {
107 dpavlin 1.3 print STDERR "unkwown status restore: '$_'\n";
108 dpavlin 1.1 $other += $restore{$_};
109     }
110     print $other || "0\n";
111 dpavlin 1.2
112     print "$media\n";
113 dpavlin 1.1

  ViewVC Help
Powered by ViewVC 1.1.26