line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Monitis::Agents; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
5
|
|
|
|
|
|
|
require Carp; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use base 'Monitis'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
955
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub get { |
10
|
0
|
|
|
0
|
1
|
|
my ($self, @params) = @_; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
my @mandatory = qw//; |
13
|
0
|
|
|
|
|
|
my @optional = qw/keyRegExp/; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my $params = $self->prepare_params(\@params, \@mandatory, \@optional); |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
return $self->api_get('agents' => $params); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub info { |
21
|
0
|
|
|
0
|
1
|
|
my ($self, @params) = @_; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my @mandatory = qw/agentId/; |
24
|
0
|
|
|
|
|
|
my @optional = qw/loadTests/; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my $params = $self->prepare_params(\@params, \@mandatory, \@optional); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
return $self->api_get('agentInfo' => $params); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub get_all_agents_snapshot { |
32
|
0
|
|
|
0
|
1
|
|
my ($self, @params) = @_; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my @mandatory = qw//; |
35
|
0
|
|
|
|
|
|
my @optional = qw/platform timezone tag/; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $params = $self->prepare_params(\@params, \@mandatory, \@optional); |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
return $self->api_get('allAgentsSnapshot' => $params); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub get_agents_snapshot { |
43
|
0
|
|
|
0
|
1
|
|
my ($self, @params) = @_; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my @mandatory = qw/agentKey/; |
46
|
0
|
|
|
|
|
|
my @optional = qw/timezone/; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $params = $self->prepare_params(\@params, \@mandatory, \@optional); |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return $self->api_get('agentSnapshot' => $params); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub delete { |
54
|
0
|
|
|
0
|
1
|
|
my ($self, @params) = @_; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my @mandatory = qw//; |
57
|
0
|
|
|
|
|
|
my @optional = qw/agentIds keyRegExp/; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $params = $self->prepare_params(\@params, \@mandatory, \@optional); |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
return $self->api_post('deleteAgents' => $params); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub download { |
65
|
0
|
|
|
0
|
1
|
|
my ($self, @params) = @_; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my @mandatory = qw/platform/; |
68
|
0
|
|
|
|
|
|
my @optional = qw//; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $params = $self->prepare_params(\@params, \@mandatory, \@optional); |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $request = $self->build_post_request('downloadAgent' => $params); |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
my $response = $self->ua->request($request); |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my $type = $response->header('Content-Type'); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Error handling |
79
|
0
|
0
|
|
|
|
|
if ($type =~ /^text/) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
return $self->parse_response($response); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
elsif (!$response->is_success) { |
83
|
0
|
|
|
|
|
|
return {status => "Network error: '" . $response->status_line . "'"}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
elsif ($type ne 'application/file') { |
86
|
0
|
|
|
|
|
|
return {status => "Wrong content-type: '$type'"}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
my $content = $response->decoded_content; |
90
|
0
|
|
|
|
|
|
my $windows; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# Look for platform name in parameters |
93
|
0
|
|
|
|
|
|
for (my $i = 0; $i <= $#$params; $i += 2) { |
94
|
0
|
0
|
|
|
|
|
next unless $params->[$i] eq 'platform'; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Detect platform |
97
|
0
|
|
|
|
|
|
$windows = $params->[$i + 1] =~ /^win/i; |
98
|
0
|
|
|
|
|
|
last; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
0
|
0
|
|
|
|
|
if (!$windows) { |
|
|
0
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# Check GZIP header for non-Windows platforms |
104
|
0
|
0
|
|
|
|
|
return unless substr($content, 0, 2) eq chr(31) . chr(139); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
elsif ($windows) { |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# Check ZIP header for Windows platforms |
109
|
0
|
0
|
|
|
|
|
return unless unpack 'L4', substr($content, 0, 4) == 0x04034b50; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
$content; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
__END__ |