1 |
dpavlin |
1.1 |
#!/usr/bin/perl -w |
2 |
|
|
|
3 |
|
|
use strict; |
4 |
|
|
use DBI; |
5 |
|
|
|
6 |
|
|
my $debug = 0; |
7 |
|
|
|
8 |
|
|
my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr; |
9 |
|
|
|
10 |
|
|
my %omni; |
11 |
|
|
|
12 |
|
|
sub db { |
13 |
|
|
my $rv = $dbh->do("update gantt |
14 |
|
|
set finish=now() where |
15 |
|
|
sessionid='$omni{SessionID}' and |
16 |
|
|
type='$omni{Session_type}' and |
17 |
|
|
status='$omni{Session_status}' and |
18 |
|
|
user_group_host='".$omni{'User.Group@Host'}."' and |
19 |
|
|
specification='$omni{Backup_Specification}'"); |
20 |
|
|
|
21 |
|
|
$dbh->do ("insert into gantt (sessionid,type,status, |
22 |
|
|
user_group_host,specification) values |
23 |
|
|
('$omni{SessionID}','$omni{Session_type}', |
24 |
|
|
'$omni{Session_status}', |
25 |
|
|
'".$omni{'User.Group@Host'}."', |
26 |
|
|
'$omni{Backup_Specification}')") if ($rv eq "0E0"); |
27 |
|
|
} |
28 |
|
|
|
29 |
|
|
open(O, "/usr/omni/bin/omnistat -detail |") || die "omnistat: $!"; |
30 |
|
|
while(<O>) { |
31 |
|
|
chomp; |
32 |
|
|
if (/^$/) { |
33 |
|
|
db() if (scalar keys %omni == 4); |
34 |
|
|
%omni = (); |
35 |
|
|
print "------------\n" if ($debug); |
36 |
|
|
next; |
37 |
|
|
} |
38 |
|
|
s/^[\t\s]+//; |
39 |
|
|
my ($l,$r) = split (/\s*:\s*/,$_,2); |
40 |
|
|
$l =~ s/\s+/_/g; |
41 |
|
|
$r =~ s/\s+$//g; |
42 |
|
|
print "$l -> $r\n" if ($debug); |
43 |
|
|
$omni{$l} = $r; |
44 |
|
|
|
45 |
|
|
} |
46 |
|
|
db(); |
47 |
|
|
close(O); |