line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::JBoss::Management; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
991
|
use 5.010; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
46
|
|
4
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
85
|
|
5
|
1
|
|
|
1
|
|
561
|
use URL::Encode qw /url_encode_utf8/; |
|
1
|
|
|
|
|
4037
|
|
|
1
|
|
|
|
|
44
|
|
6
|
1
|
|
|
1
|
|
457
|
use Moo; |
|
1
|
|
|
|
|
1273
|
|
|
1
|
|
|
|
|
5
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'Net::JBoss'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Net::JBoss::Management - Bindings for JBoss Management API |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 0.01 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Net::JBoss::Management; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my %con = ( |
28
|
|
|
|
|
|
|
username => 'admin', |
29
|
|
|
|
|
|
|
password => 'password', |
30
|
|
|
|
|
|
|
server => 'jboss1.example.com', |
31
|
|
|
|
|
|
|
port => 9990, #optional |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $jboss = Net::JBoss::Management->new(%con); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $state = $jboss->get_state(); |
37
|
|
|
|
|
|
|
my $jvm_usage = $jboss->get_jvm_usage(); |
38
|
|
|
|
|
|
|
my $runtime_stats = $jboss->get_runtime_stats(); |
39
|
|
|
|
|
|
|
my $runtime_details = $jboss->get_runtime_details(); |
40
|
|
|
|
|
|
|
my $server_env = $jboss->get_server_env(); |
41
|
|
|
|
|
|
|
my $datasources = $jboss->get_datasources(); |
42
|
|
|
|
|
|
|
my $app_status = $jboss->get_app_status('hawtio.war'); |
43
|
|
|
|
|
|
|
my $active_session = $jboss->get_active_sessions('hawtio.war'); |
44
|
|
|
|
|
|
|
my $pool_stats = $jboss->get_ds_pool_stats('java:jboss/datasources/jboss_Pool'); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 Attributes |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Other attributes is also inherited from JBoss.pm |
49
|
|
|
|
|
|
|
Check 'perldoc Net::JBoss' for detail |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
notes : |
52
|
|
|
|
|
|
|
ro = read only, can be specified only during initialization |
53
|
|
|
|
|
|
|
rw = read write, user can set this attribute |
54
|
|
|
|
|
|
|
rwp = read write protected, for internal class |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
management_url = (ro) store default management url path |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
has 'management_url' => ( is => 'ro', default => '/management' ); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 BUILD |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
The Constructor, build logging, call pass_log_obj method |
67
|
|
|
|
|
|
|
Build final url |
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub BUILD { |
71
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
$self->pass_log_obj; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $url = $self->base_url . $self->management_url; |
76
|
0
|
|
|
|
|
|
$self->_set_url($url); |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
$self->log->debug($url); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 get_state |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
return server state |
84
|
|
|
|
|
|
|
my $state = $jboss->state(); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub get_state { |
89
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
$self->_set_resource_url('/?operation=attribute&name=server-state&json.pretty'); |
92
|
0
|
|
|
|
|
|
$self->log->debug($self->resource_url); |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
$self->get_api_response(); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 get_jvm_usage |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
return jvm usage |
100
|
|
|
|
|
|
|
my $jvm_usage = $jboss->get_jvm_usage(); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub get_jvm_usage { |
105
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
$self->_set_resource_url('/core-service/platform-mbean/type/memory?operation=resource&include-runtime=true&json.pretty'); |
108
|
0
|
|
|
|
|
|
$self->log->debug($self->resource_url); |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
$self->get_api_response(); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 get_runtime_stats |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
get HTTP connector runtime statistics |
116
|
|
|
|
|
|
|
my $runtime_stats = $jboss->runtime_stats(); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub get_runtime_stats { |
121
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
$self->_set_resource_url('/subsystem/web/connector/http?operation=resource&include-runtime=true&recursive&json.pretty'); |
124
|
0
|
|
|
|
|
|
$self->log->debug($self->resource_url); |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
$self->get_api_response(); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 get_runtime_details |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
get JBoss runtime details |
132
|
|
|
|
|
|
|
my $runtime_details = $jboss->get_runtime_details(); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub get_runtime_details { |
137
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
$self->_set_resource_url('/core-service/platform-mbean/type/runtime?operation=resource&include-runtime=true&json.pretty'); |
140
|
0
|
|
|
|
|
|
$self->log->debug($self->resource_url); |
141
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
$self->get_api_response(); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 get_server_env |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
get JBoss server environment |
148
|
|
|
|
|
|
|
my $server_env = $jboss->get_server_env(); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub get_server_env { |
153
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
154
|
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
$self->_set_resource_url('/core-service/server-environment?operation=resource&include-runtime=true&json.pretty'); |
156
|
0
|
|
|
|
|
|
$self->log->debug($self->resource_url); |
157
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
$self->get_api_response(); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 get_datasources |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
get data source and driver |
164
|
|
|
|
|
|
|
my $datasources = $jboss->get_datasources(); |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub get_datasources { |
169
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
170
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
$self->_set_resource_url('/subsystem/datasources/?operation=resource&recursive=true&json.pretty'); |
172
|
0
|
|
|
|
|
|
$self->log->debug($self->resource_url); |
173
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
$self->get_api_response(); |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 get_app_status |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
get web application status |
180
|
|
|
|
|
|
|
web application name is required |
181
|
|
|
|
|
|
|
my $app_status = $jboss->get_app_status('hawtio.war'); |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=cut |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub get_app_status { |
186
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
187
|
|
|
|
|
|
|
|
188
|
0
|
|
|
|
|
|
my $app_name = shift; |
189
|
0
|
0
|
|
|
|
|
croak "web application name is required" |
190
|
|
|
|
|
|
|
unless $app_name; |
191
|
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
|
$self->_set_resource_url(qq|/deployment/$app_name?operation=attribute&name=status&json.pretty|); |
193
|
0
|
|
|
|
|
|
$self->log->debug($self->resource_url); |
194
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
$self->get_api_response(); |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head2 get_active_sessions |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
get web application active sessions |
201
|
|
|
|
|
|
|
web application name is required |
202
|
|
|
|
|
|
|
my $active_session = $jboss->get_active_sessions('hawtio.war'); |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
sub get_active_sessions { |
207
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
208
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
my $app_name = shift; |
210
|
0
|
0
|
|
|
|
|
croak "web application name is required" |
211
|
|
|
|
|
|
|
unless $app_name; |
212
|
|
|
|
|
|
|
|
213
|
0
|
|
|
|
|
|
$self->_set_resource_url(qq|/deployment/$app_name/subsystem/web?operation=attribute&name=active-sessions&json.pretty|); |
214
|
0
|
|
|
|
|
|
$self->log->debug($self->resource_url); |
215
|
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
|
$self->get_api_response(); |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head2 get_ds_pool_stats |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
get usage metric of connection pooling of the data source |
222
|
|
|
|
|
|
|
my $pool_stats = $jboss->get_ds_pool_stats('java:jboss/datasources/jboss_Pool'); |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=cut |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
sub get_ds_pool_stats { |
227
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
228
|
0
|
|
|
|
|
|
my $ds_name = shift; |
229
|
|
|
|
|
|
|
|
230
|
0
|
0
|
|
|
|
|
croak "data source name is required" |
231
|
|
|
|
|
|
|
unless $ds_name; |
232
|
0
|
|
|
|
|
|
$ds_name = url_encode_utf8($ds_name); |
233
|
0
|
|
|
|
|
|
$self->log->info("encode : $ds_name"); |
234
|
|
|
|
|
|
|
|
235
|
0
|
|
|
|
|
|
$self->_set_resource_url(qq|/subsystem/datasources/data-source/$ds_name/statistics/pool/?operation=resource&recursive=true&include-runtime=true&json.pretty|); |
236
|
0
|
|
|
|
|
|
$self->log->debug($self->resource_url); |
237
|
|
|
|
|
|
|
|
238
|
0
|
|
|
|
|
|
$self->get_api_response(); |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 AUTHOR |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
"Heince Kurniawan", C<< <"heince at gmail.com"> >> |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 BUGS |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
248
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
249
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 SUPPORT |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
perldoc Net::JBoss |
257
|
|
|
|
|
|
|
perldoc Net::JBoss::Management |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
You can also look for information at: |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=over 4 |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
L |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
L |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=item * CPAN Ratings |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
L |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=item * Search CPAN |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
L |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=back |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
Copyright 2015 "Heince Kurniawan". |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
290
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
291
|
|
|
|
|
|
|
copy of the full license at: |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
L |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
296
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
297
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
298
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
301
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
302
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
305
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
308
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
309
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
310
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
311
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
312
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
313
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
314
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
317
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
318
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
319
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
320
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
321
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
322
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
323
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=cut |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
1; # End of JBoss |