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 |
|
|
'Queuing', |
29 |
dpavlin |
1.1 |
'Aborted', |
30 |
dpavlin |
1.2 |
'Failed', |
31 |
dpavlin |
1.1 |
'Completed', |
32 |
|
|
'Completed/Errors', |
33 |
dpavlin |
1.2 |
'Completed/Failure', |
34 |
dpavlin |
1.1 |
); |
35 |
|
|
|
36 |
dpavlin |
1.2 |
my $debug = 0; |
37 |
|
|
|
38 |
dpavlin |
1.1 |
my %backup; |
39 |
|
|
my %restore; |
40 |
|
|
|
41 |
|
|
open(O,"$omnistat |") || die "can't start $omnistat !"; |
42 |
dpavlin |
1.2 |
|
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 |
dpavlin |
1.1 |
while(<O>) { |
56 |
|
|
chomp; |
57 |
dpavlin |
1.2 |
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 |
dpavlin |
1.1 |
# don't report this on header! |
70 |
dpavlin |
1.2 |
print STDERR "unknown type: $type"; |
71 |
dpavlin |
1.1 |
} |
72 |
|
|
} |
73 |
|
|
close(O); |
74 |
|
|
|
75 |
dpavlin |
1.2 |
# dump data |
76 |
dpavlin |
1.1 |
|
77 |
|
|
foreach (@stat) { |
78 |
dpavlin |
1.2 |
print STDERR "$_: " if ($debug); |
79 |
dpavlin |
1.1 |
if (defined $backup{$_}) { |
80 |
|
|
print $backup{$_},"\n"; |
81 |
|
|
delete $backup{$_}; |
82 |
|
|
} else { |
83 |
|
|
print "0\n"; |
84 |
|
|
} |
85 |
dpavlin |
1.2 |
if (defined $restore{$_}) { |
86 |
|
|
print $restore{$_},"\n"; |
87 |
|
|
delete $restore{$_}; |
88 |
|
|
} else { |
89 |
|
|
print "0\n"; |
90 |
|
|
} |
91 |
dpavlin |
1.1 |
} |
92 |
dpavlin |
1.2 |
|
93 |
|
|
# dump backup other |
94 |
|
|
|
95 |
dpavlin |
1.1 |
my $other; |
96 |
|
|
foreach (keys %backup) { |
97 |
dpavlin |
1.2 |
print STDERR "other backup: -->$_<--\n" if ($debug); |
98 |
dpavlin |
1.1 |
$other += $backup{$_}; |
99 |
|
|
} |
100 |
|
|
print $other || "0\n"; |
101 |
|
|
|
102 |
dpavlin |
1.2 |
# dump restore other |
103 |
dpavlin |
1.1 |
|
104 |
|
|
undef $other; |
105 |
|
|
foreach (keys %restore) { |
106 |
dpavlin |
1.2 |
print STDERR "other restore -->$_<--\n" if ($debug); |
107 |
dpavlin |
1.1 |
$other += $restore{$_}; |
108 |
|
|
} |
109 |
|
|
print $other || "0\n"; |
110 |
dpavlin |
1.2 |
|
111 |
|
|
print "$media\n"; |
112 |
dpavlin |
1.1 |
|