2 |
|
|
3 |
use strict; |
use strict; |
4 |
use DBI; |
use DBI; |
5 |
|
use Cache::FileCache; |
6 |
|
|
7 |
my $debug = 0; |
my $debug = 0; |
8 |
|
|
9 |
my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr; |
my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr; |
10 |
|
my $cache = new Cache::FileCache(); |
11 |
|
|
12 |
my %omni; |
my %omni; |
13 |
|
|
26 |
|
|
27 |
print "sql:\n$sql\nrv: $rv\n" if ($debug); |
print "sql:\n$sql\nrv: $rv\n" if ($debug); |
28 |
|
|
29 |
$dbh->do ("insert into gantt (sessionid,type,status, |
my ($device,$host); |
30 |
user_group_host,specification) values |
|
31 |
('$omni{SessionID}','$omni{Session_type}', |
if ($rv eq "0E0" || !$rv) { |
32 |
'$omni{Session_status}', |
my $c = $cache->get( $omni{SessionID} ); |
33 |
'".$omni{'User.Group@Host'}."', |
|
34 |
'$omni{Backup_Specification}')") if ($rv eq "0E0" || !$rv); |
if (defined $c) { |
35 |
|
($device,$host) = split(/\t/,$c,2); |
36 |
|
print STDERR "cache hit for $omni{SessionID} - $host:$device\n" if ($debug); |
37 |
|
} else { |
38 |
|
print STDERR "cache miss for $omni{SessionID}" if ($debug); |
39 |
|
open(O, "/usr/omni/bin/omnistat -session $omni{SessionID} |") || die "omnistat: $!"; |
40 |
|
while(<O>) { |
41 |
|
chomp; |
42 |
|
next if (/^$/ || /^Device/ || /^=+$/); |
43 |
|
($device,$host,undef) = split(/\s+/,$_,3); |
44 |
|
$cache->set( $omni{SessionID}, "$device\t$host", "24 hours" ); |
45 |
|
print STDERR " = $host:$device\n" if ($debug); |
46 |
|
last; |
47 |
|
} |
48 |
|
close(O); |
49 |
|
} |
50 |
|
|
51 |
|
$dbh->do ("insert into gantt (sessionid,type,status, |
52 |
|
user_group_host,specification,device,host) values |
53 |
|
('$omni{SessionID}','$omni{Session_type}', |
54 |
|
'$omni{Session_status}', |
55 |
|
'".$omni{'User.Group@Host'}."', |
56 |
|
'$omni{Backup_Specification}', |
57 |
|
'$device','$host')") |
58 |
|
} |
59 |
} |
} |
60 |
|
|
61 |
open(O, "/usr/omni/bin/omnistat -detail |") || die "omnistat: $!"; |
open(O, "/usr/omni/bin/omnistat -detail |") || die "omnistat: $!"; |