line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Armadito::Agent::Task::Scheduler; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
8702624
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
111
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
119
|
|
5
|
3
|
|
|
3
|
|
18
|
use base 'Armadito::Agent::Task'; |
|
3
|
|
|
|
|
44
|
|
|
3
|
|
|
|
|
1184
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1333
|
use MIME::Base64; |
|
3
|
|
|
|
|
1373
|
|
|
3
|
|
|
|
|
154
|
|
8
|
3
|
|
|
3
|
|
15
|
use Data::Dumper; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
118
|
|
9
|
3
|
|
|
3
|
|
15
|
use JSON; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
46
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
0
|
|
|
0
|
1
|
|
my ( $class, %params ) = @_; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(%params); |
15
|
|
|
|
|
|
|
|
16
|
0
|
0
|
|
|
|
|
if ( $params{debug} ) { |
17
|
0
|
|
|
|
|
|
$self->{debug} = 1; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $task = { |
21
|
|
|
|
|
|
|
name => "Scheduler", |
22
|
|
|
|
|
|
|
antivirus => $self->{agent}->{antivirus}->getJobj() |
23
|
0
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$self->{scheduler} = { |
26
|
|
|
|
|
|
|
name => $self->{agent}->{config}->{scheduler}, |
27
|
0
|
|
|
|
|
|
conf => {} |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
$self->{jobj}->{task} = $task; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
return $self; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _handleError { |
36
|
0
|
|
|
0
|
|
|
my ( $self, $response ) = @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
$self->{logger}->info( "Error Response : " . $response->content() ); |
39
|
0
|
|
|
|
|
|
my $obj = from_json( $response->content(), { utf8 => 1 } ); |
40
|
0
|
|
|
|
|
|
$self->{logger}->error( Dumper($obj) ); |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return $self; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub sendSchedulerInfos { |
46
|
0
|
|
|
0
|
0
|
|
my ( $self, $schedulerinfos ) = @_; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$self->{jobj}->{task}->{obj} = $schedulerinfos; |
49
|
0
|
|
|
|
|
|
my $json_text = to_json( $self->{jobj} ); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $response = $self->{glpi_client}->sendRequest( |
52
|
0
|
|
|
|
|
|
"url" => $self->{agent}->{config}->{server}[0] . "/api/schedulers", |
53
|
|
|
|
|
|
|
message => $json_text, |
54
|
|
|
|
|
|
|
method => "POST" |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
if ( $response->is_success() ) { |
58
|
0
|
|
|
|
|
|
$self->{logger}->info("Send Scheduler infos successful..."); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
else { |
61
|
0
|
|
|
|
|
|
$self->_handleError($response); |
62
|
0
|
|
|
|
|
|
$self->{logger}->info("Send Scheduler infos failed..."); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 NAME |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Armadito::Agent::Task::Scheduler - base class used for task scheduling management |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 DESCRIPTION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This task inherits from L<Armadito::Agent::Task>. It allows a remote management for agent's task scheduling solutions. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 FUNCTIONS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 run ( $self, %params ) |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Run the task. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 new ( $self, %params ) |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Instanciate Task. |
87
|
|
|
|
|
|
|
|