File Coverage

blib/lib/JMX/Jmx4Perl/Product/Weblogic.pm
Criterion Covered Total %
statement 20 47 42.5
branch 0 4 0.0
condition 0 3 0.0
subroutine 8 18 44.4
pod 8 9 88.8
total 36 81 44.4


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2             package JMX::Jmx4Perl::Product::Weblogic;
3              
4 3     3   16 use JMX::Jmx4Perl::Product::BaseHandler;
  3         6  
  3         76  
5 3     3   17 use JMX::Jmx4Perl::Request;
  3         5  
  3         219  
6 3     3   15 use Data::Dumper;
  3         4  
  3         143  
7 3     3   17 use strict;
  3         5  
  3         91  
8 3     3   63 use base "JMX::Jmx4Perl::Product::BaseHandler";
  3         6  
  3         218  
9              
10 3     3   14 use Carp qw(croak);
  3         5  
  3         1528  
11              
12             =head1 NAME
13              
14             JMX::Jmx4Perl::Product::Weblogic - Handler for Oracle WebLogic
15              
16             =head1 DESCRIPTION
17              
18             This is the product handler support for Oracle Weblogic Server 9 and 10
19             (L)
20              
21             =cut
22              
23             sub id {
24 3     3 1 22 return "weblogic";
25             }
26              
27             sub name {
28 0     0 1 0 return "Oracle WebLogic Server";
29             }
30              
31             sub order {
32 3     3 1 16 return undef;
33             }
34              
35             sub _try_version {
36 0     0     my $self = shift;
37 0           my $is_weblogic = $self->_try_server_domain;
38 0 0         return undef unless $is_weblogic;
39 0           return $self->try_attribute("version",$self->{server_domain},"ConfigurationVersion");
40             }
41              
42             sub vendor {
43 0     0 1   return "Oracle";
44             }
45              
46             sub server_info {
47 0     0 1   my $self = shift;
48 0           my $ret = $self->SUPER::server_info();
49 0           $ret .= sprintf("%-10.10s %s\n","IP:",$self->{jmx4perl}->get_attribute("SERVER_ADDRESS"));
50             }
51              
52             sub _try_server_domain {
53 0     0     my $self = shift;
54 0           return $self->try_attribute
55             ("server_domain",
56             "com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean",
57             "DomainConfiguration",
58             "objectName");
59             }
60              
61             sub jsr77 {
62 0     0 1   return 0;
63             }
64              
65             sub autodetect_pattern {
66 0     0 1   return ("version",1);
67             }
68              
69             sub init_aliases {
70             return
71             {
72             attributes => {
73             SERVER_ADDRESS => [ sub {
74 0     0     my $self = shift;
75 0           $self->_try_server_domain;
76 0           $self->try_attribute("admin_server",
77             $self->{server_domain},
78             "AdminServerName");
79 0           return [ "com.bea:Name=" . $self->{admin_server} . ",Type=ServerRuntime",
80             "AdminServerHost" ];
81 0     0 1   }],
82             },
83             operations => {
84             # Needs to be done in a more complex. Depends on admin server name *and*
85             # JVM used
86             THREAD_DUMP => \&exec_thread_dump
87             }
88             # Alias => [ "mbean", "attribute", "path" ]
89             };
90             }
91              
92             sub exec_thread_dump {
93 0     0 0   my $self = shift;
94 0           my $jmx = $self->{jmx4perl};
95              
96 0           my $beans = $jmx->search("com.bea:Type=JRockitRuntime,*");
97 0 0 0       if ($beans && @{$beans}) {
  0            
98 0           my $bean = $beans->[0];
99 0           my $request = new JMX::Jmx4Perl::Request(READ,$bean,"ThreadStackDump");
100 0           return $jmx->request($request);
101             }
102 0           die $self->name,": Cannot execute THREAD_DUMP because I can't find a suitable JRockitRuntime";
103             }
104              
105             =head1 LICENSE
106              
107             This file is part of jmx4perl.
108              
109             Jmx4perl is free software: you can redistribute it and/or modify
110             it under the terms of the GNU General Public License as published by
111             the Free Software Foundation, either version 2 of the License, or
112             (at your option) any later version.
113              
114             jmx4perl is distributed in the hope that it will be useful,
115             but WITHOUT ANY WARRANTY; without even the implied warranty of
116             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
117             GNU General Public License for more details.
118              
119             You should have received a copy of the GNU General Public License
120             along with jmx4perl. If not, see .
121              
122             A commercial license is available as well. Please contact roland@cpan.org for
123             further details.
124              
125             =head1 AUTHOR
126              
127             roland@cpan.org
128              
129             =cut
130              
131             1;