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

Contents of /parse_omni.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Tue Sep 10 18:09:24 2002 UTC (21 years, 6 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 #!/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 # omnistat. So far, I check and report events which are in @stat.
17 # 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 # '------------------' output width
26 'In Progress',
27 'In Progress/Failur',
28 'In Progress/Errors',
29 'Queuing',
30 'Aborted',
31 'Failed',
32 'Completed',
33 'Completed/Errors',
34 'Completed/Failure',
35 );
36
37 my $debug = 0;
38
39 my %backup;
40 my %restore;
41
42 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>) {
57 chomp;
58 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 # don't report this on header!
71 print STDERR "unknown type: '$type'\n";
72 }
73 }
74 close(O);
75
76 # dump data
77
78 foreach (@stat) {
79 print STDERR "$_: " if ($debug);
80 if (defined $backup{$_}) {
81 print $backup{$_},"\n";
82 delete $backup{$_};
83 } else {
84 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;
97 foreach (keys %backup) {
98 print STDERR "unknown status backup: '$_'\n";
99 $other += $backup{$_};
100 }
101 print $other || "0\n";
102
103 # dump restore other
104
105 undef $other;
106 foreach (keys %restore) {
107 print STDERR "unkwown status restore: '$_'\n";
108 $other += $restore{$_};
109 }
110 print $other || "0\n";
111
112 print "$media\n";
113

  ViewVC Help
Powered by ViewVC 1.1.26