| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# $Id: AutoSys.pm 68 2008-02-11 10:50:27Z sini $ |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# CA::AutoSys - Perl Interface to CA's AutoSys job control. |
|
5
|
|
|
|
|
|
|
# Copyright (c) 2007 Sinisa Susnjar |
|
6
|
|
|
|
|
|
|
# See LICENSE for terms of distribution. |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# This library is free software; you can redistribute it and/or |
|
9
|
|
|
|
|
|
|
# modify it under the terms of the GNU Lesser General Public |
|
10
|
|
|
|
|
|
|
# License as published by the Free Software Foundation; either |
|
11
|
|
|
|
|
|
|
# version 2.1 of the License, or (at your option) any later version. |
|
12
|
|
|
|
|
|
|
# |
|
13
|
|
|
|
|
|
|
# This library is distributed in the hope that it will be useful, |
|
14
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16
|
|
|
|
|
|
|
# Lesser General Public License for more details. |
|
17
|
|
|
|
|
|
|
# |
|
18
|
|
|
|
|
|
|
# You should have received a copy of the GNU Lesser General Public |
|
19
|
|
|
|
|
|
|
# License along with this library; if not, write to the Free Software |
|
20
|
|
|
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21
|
|
|
|
|
|
|
# |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package CA::AutoSys; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
require CA::AutoSys::Job; |
|
26
|
|
|
|
|
|
|
require CA::AutoSys::Status; |
|
27
|
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
5731
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
37
|
|
|
29
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
30
|
1
|
|
|
1
|
|
2173
|
use DBI; |
|
|
1
|
|
|
|
|
25511
|
|
|
|
1
|
|
|
|
|
67
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
|
9
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
59
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$VERSION = '1.05'; |
|
35
|
|
|
|
|
|
|
|
|
36
|
1
|
|
|
1
|
|
5
|
use Exporter; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
35
|
|
|
37
|
1
|
|
|
1
|
|
4
|
use vars qw(@ISA @EXPORT); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
487
|
|
|
38
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
39
|
|
|
|
|
|
|
@EXPORT = qw(&new); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
our $errstr; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { |
|
44
|
0
|
|
|
0
|
1
|
|
my $self = {}; |
|
45
|
0
|
|
|
|
|
|
my $class = shift(); |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
$errstr = ''; |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
if (@_) { |
|
50
|
0
|
|
|
|
|
|
my %args = @_; |
|
51
|
0
|
0
|
|
|
|
|
$self->{dsn} = $args{dsn} ? $args{dsn} : undef; |
|
52
|
0
|
0
|
|
|
|
|
$self->{server} = $args{server} ? $args{server} : undef; |
|
53
|
0
|
0
|
|
|
|
|
$self->{user} = $args{user} ? $args{user} : undef; |
|
54
|
0
|
0
|
|
|
|
|
$self->{password} = $args{password} ? $args{password} : undef; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
if (!defined($self->{dsn})) { |
|
58
|
0
|
0
|
|
|
|
|
if (!defined($self->{server})) { |
|
59
|
0
|
|
|
|
|
|
$errstr = "no dsn given in new()"; |
|
60
|
0
|
|
|
|
|
|
return undef; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
# Default to Sybase when no dsn was given... |
|
63
|
0
|
|
|
|
|
|
$self->{dsn} = "dbi:Sybase:server=$self->{server}"; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
0
|
|
|
|
|
|
$self->{dbh} = DBI->connect($self->{dsn}, $self->{user}, $self->{password}); |
|
66
|
0
|
0
|
|
|
|
|
if (!$self->{dbh}) { |
|
67
|
0
|
|
|
|
|
|
$errstr = "can't connect to dsn ".$self->{dsn}.": ".$DBI::errstr; |
|
68
|
0
|
|
|
|
|
|
return undef; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
bless($self); |
|
72
|
0
|
|
|
|
|
|
return $self; |
|
73
|
|
|
|
|
|
|
} # new() |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub find_jobs { |
|
76
|
0
|
|
|
0
|
1
|
|
my $self = shift(); |
|
77
|
0
|
|
|
|
|
|
my $job_name = shift(); |
|
78
|
0
|
|
|
|
|
|
my $job = CA::AutoSys::Job->new(parent => $self, database_handle => $self->{dbh}); |
|
79
|
0
|
|
|
|
|
|
return $job->find_jobs($job_name); |
|
80
|
|
|
|
|
|
|
} # find_jobs() |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub send_event { |
|
83
|
0
|
|
|
0
|
1
|
|
my $self = shift(); |
|
84
|
0
|
|
|
|
|
|
my ($job_name, $event, $status, $event_time); |
|
85
|
0
|
0
|
|
|
|
|
if (@_) { |
|
86
|
0
|
|
|
|
|
|
my %args = @_; |
|
87
|
0
|
0
|
|
|
|
|
$job_name = $args{job_name} ? $args{job_name} : ''; |
|
88
|
0
|
0
|
|
|
|
|
$event = $args{event} ? $args{event} : ''; |
|
89
|
0
|
0
|
|
|
|
|
$status = $args{status} ? $args{status} : ''; |
|
90
|
0
|
0
|
|
|
|
|
$event_time = $args{event_time} ? $args{event_time} : ''; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my $sth = $self->{dbh}->prepare(qq{ |
|
94
|
|
|
|
|
|
|
exec sendevent '$event', '$job_name', '$status', '', '$event_time', '' |
|
95
|
|
|
|
|
|
|
}); |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$sth->execute(); |
|
98
|
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
my ($rc) = $sth->fetchrow_array(); |
|
100
|
0
|
|
|
|
|
|
return $rc; |
|
101
|
|
|
|
|
|
|
} # send_event() |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
|
104
|
|
|
|
|
|
|
__END__ |