line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Armadito::Agent::Task::State; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
4948477
|
use strict; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
113
|
|
4
|
4
|
|
|
4
|
|
13
|
use warnings; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
148
|
|
5
|
4
|
|
|
4
|
|
14
|
use base 'Armadito::Agent::Task'; |
|
4
|
|
|
|
|
33
|
|
|
4
|
|
|
|
|
1508
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
22
|
use Data::Dumper; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
168
|
|
8
|
4
|
|
|
4
|
|
20
|
use JSON; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
58
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
0
|
|
|
0
|
1
|
|
my ( $class, %params ) = @_; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(%params); |
14
|
|
|
|
|
|
|
|
15
|
0
|
0
|
|
|
|
|
if ( $params{debug} ) { |
16
|
0
|
|
|
|
|
|
$self->{debug} = 1; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $task = { |
20
|
|
|
|
|
|
|
name => "State", |
21
|
|
|
|
|
|
|
antivirus => $self->{agent}->{antivirus}->getJobj() |
22
|
0
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
$self->{jobj}->{task} = $task; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _sendToGLPI { |
30
|
0
|
|
|
0
|
|
|
my ( $self, $stateobj ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
$self->{jobj}->{task}->{obj} = $stateobj; |
33
|
0
|
|
|
|
|
|
my $json_text = to_json( $self->{jobj} ); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $response = $self->{glpi_client}->sendRequest( |
36
|
0
|
|
|
|
|
|
"url" => $self->{agent}->{config}->{server}[0] . "/api/states", |
37
|
|
|
|
|
|
|
message => $json_text, |
38
|
|
|
|
|
|
|
method => "POST" |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
if ( $response->is_success() ) { |
42
|
0
|
|
|
|
|
|
$self->{logger}->info("Send AV State successful..."); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
else { |
45
|
0
|
|
|
|
|
|
$self->_handleError($response); |
46
|
0
|
|
|
|
|
|
$self->{logger}->info("Send AV State failed..."); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _addAVDetail { |
51
|
0
|
|
|
0
|
|
|
my ( $self, $attr, $value ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$attr =~ s/^://; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $avdetail = { |
56
|
|
|
|
|
|
|
attr => $attr, |
57
|
|
|
|
|
|
|
value => $value |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
push( @{ $self->{data}->{avdetails} }, $avdetail ); |
|
0
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _handleError { |
64
|
0
|
|
|
0
|
|
|
my ( $self, $response ) = @_; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$self->{logger}->info( "Error Response : " . $response->content() ); |
67
|
0
|
|
|
|
|
|
my $obj = from_json( $response->content(), { utf8 => 1 } ); |
68
|
0
|
|
|
|
|
|
$self->{logger}->error( Dumper($obj) ); |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
return $self; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 NAME |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Armadito::Agent::Task::State - State Task base class |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DESCRIPTION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This task inherits from L<Armadito::Agent::Task>. Get Antivirus state and send it to GPLI server Armadito plugin. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 FUNCTIONS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 run ( $self, %params ) |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Run the task. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 new ( $self, %params ) |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Instanciate Task. |
94
|
|
|
|
|
|
|
|