/[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.3 - (show annotations)
Tue Sep 10 17:43:19 2002 UTC (16 years, 9 months ago) by dpavlin
Branch: MAIN
Changes since 1.2: +3 -3 lines
File MIME type: text/plain
some errors really should go in cricket log (dump to stderr)

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 'Queuing',
29 'Aborted',
30 'Failed',
31 'Completed',
32 'Completed/Errors',
33 'Completed/Failure',
34 );
35
36 my $debug = 0;
37
38 my %backup;
39 my %restore;
40
41 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>) {
56 chomp;
57 my $type = substr($_,$tf,$tl);
58 $type =~ s/ +$//;
59 my $status = substr($_,$sf,$sl);
60 $status =~ s/ +$//;
61
62 if ($type =~ m/Backup/i) {
63 $backup{$status}++;
64 } 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!
70 print STDERR "unknown type: '$type'\n";
71 }
72 }
73 close(O);
74
75 # dump data
76
77 foreach (@stat) {
78 print STDERR "$_: " if ($debug);
79 if (defined $backup{$_}) {
80 print $backup{$_},"\n";
81 delete $backup{$_};
82 } else {
83 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;
96 foreach (keys %backup) {
97 print STDERR "unknown status backup: '$_'\n";
98 $other += $backup{$_};
99 }
100 print $other || "0\n";
101
102 # dump restore other
103
104 undef $other;
105 foreach (keys %restore) {
106 print STDERR "unkwown status restore: '$_'\n";
107 $other += $restore{$_};
108 }
109 print $other || "0\n";
110
111 print "$media\n";
112

  ViewVC Help
Powered by ViewVC 1.1.26