line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (C) 2015, Snehasis Sinha |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Apache::Hadoop::Watcher::Jmx; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
21378
|
use 5.010001; |
|
1
|
|
|
|
|
3
|
|
7
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
20
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
1009
|
use JSON; |
|
1
|
|
|
|
|
16027
|
|
|
1
|
|
|
|
|
5
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require Apache::Hadoop::Watcher::Base; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @ISA = qw(); |
15
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Preloaded methods go here. |
19
|
|
|
|
|
|
|
sub new { |
20
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
21
|
0
|
|
|
|
|
|
my %args = @_; |
22
|
|
|
|
|
|
|
my $self = { |
23
|
0
|
|
0
|
|
|
|
jmx => 'http://'.($args{'host'}||'localhost').':'.($args{'port'}||'50070').'/jmx', |
|
|
|
0
|
|
|
|
|
24
|
|
|
|
|
|
|
out => undef, |
25
|
|
|
|
|
|
|
qlist => { |
26
|
|
|
|
|
|
|
'java_runtime' => 'java.lang:type=Runtime', |
27
|
|
|
|
|
|
|
'java_memory' => 'java.lang:type=Memory', |
28
|
|
|
|
|
|
|
'namenode_status' => 'Hadoop:service=NameNode,name=NameNodeStatus', |
29
|
|
|
|
|
|
|
'port9000_detailed' => 'Hadoop:service=NameNode,name=RpcDetailedActivityForPort9000', |
30
|
|
|
|
|
|
|
'namenode_activity' => 'Hadoop:service=NameNode,name=NameNodeActivity', |
31
|
|
|
|
|
|
|
'port9000_activity' => 'Hadoop:service=NameNode,name=RpcActivityForPort9000', |
32
|
|
|
|
|
|
|
'namenode_retry_cache' => 'Hadoop:service=NameNode,name=RetryCache.NameNodeRetryCache', |
33
|
|
|
|
|
|
|
'ugi_metrics' => 'Hadoop:service=NameNode,name=UgiMetrics', |
34
|
|
|
|
|
|
|
'control_metrics' => 'Hadoop:service=NameNode,name=MetricsSystem,sub=Control', |
35
|
|
|
|
|
|
|
'jvm_metrics' => 'Hadoop:service=NameNode,name=JvmMetrics', |
36
|
|
|
|
|
|
|
'fsname_state' => 'Hadoop:service=NameNode,name=FSNamesystemState', |
37
|
|
|
|
|
|
|
'fsname_system' => 'Hadoop:service=NameNode,name=FSNamesystem', |
38
|
|
|
|
|
|
|
'startup_progress' => 'Hadoop:service=NameNode,name=StartupProgress', |
39
|
|
|
|
|
|
|
'stats_metrics' => 'Hadoop:service=NameNode,name=MetricsSystem,sub=Stats', |
40
|
|
|
|
|
|
|
'namenode_info' => 'Hadoop:service=NameNode,name=NameNodeInfo', |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
}; |
43
|
0
|
|
|
|
|
|
bless $self, $class; |
44
|
0
|
|
|
|
|
|
return $self; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# dumps output hashref |
48
|
|
|
|
|
|
|
sub print { |
49
|
0
|
|
|
0
|
0
|
|
my ($self) = (@_); |
50
|
0
|
|
|
|
|
|
Apache::Hadoop::Watcher::Base->new->_print ( output=>$self->{'out'} ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# returns list of services |
54
|
|
|
|
|
|
|
sub list { |
55
|
0
|
|
|
0
|
0
|
|
my ($self) = (@_); |
56
|
0
|
|
|
|
|
|
my @servicelist; |
57
|
0
|
|
|
|
|
|
foreach my $href ( @{$self->{'out'}} ) { |
|
0
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
push @servicelist, $href->{'name'}; |
59
|
|
|
|
|
|
|
} |
60
|
0
|
|
|
|
|
|
return \@servicelist; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# returns output hashref |
64
|
|
|
|
|
|
|
sub get { |
65
|
0
|
|
|
0
|
0
|
|
my ($self) = (@_); |
66
|
0
|
|
|
|
|
|
return $self->{'out'}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub set { |
70
|
0
|
|
|
0
|
0
|
|
my ($self, %opts) = (@_); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub get_system_properties { |
74
|
0
|
|
|
0
|
0
|
|
my ($self) = (@_); |
75
|
0
|
|
|
|
|
|
my $href; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
$self->_query (query=>$self->{'qlist'}->{'system_properties'}); |
78
|
0
|
|
|
|
|
|
$href = $self->{'out'}->[0]->{'SystemProperties'}; |
79
|
0
|
|
|
|
|
|
foreach my $e (sort @{$href}) { |
|
0
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
if ( $e->{'key'} eq 'java.class.path' ) { |
81
|
0
|
|
|
|
|
|
print sprintf "%30s %s\n", $e->{'key'}, ' '; |
82
|
0
|
|
|
|
|
|
foreach ( split /:/, $e->{'value'} ) { |
83
|
0
|
|
|
|
|
|
print sprintf "%30s %s\n", ' ', $_; |
84
|
|
|
|
|
|
|
} |
85
|
0
|
|
|
|
|
|
next; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
0
|
0
|
|
|
|
|
if ( $e->{'key'} eq 'sun.boot.class.path' ) { |
89
|
0
|
|
|
|
|
|
print sprintf "%30s %s\n", $e->{'key'}, ' '; |
90
|
0
|
|
|
|
|
|
foreach ( split /:/, $e->{'value'} ) { |
91
|
0
|
|
|
|
|
|
print sprintf "%30s %s\n", ' ', $_; |
92
|
|
|
|
|
|
|
} |
93
|
0
|
|
|
|
|
|
next; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
print sprintf "%30s %s\n", $e->{'key'}, $e->{'value'}; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# jmx json methods |
101
|
|
|
|
|
|
|
sub _query { |
102
|
0
|
|
|
0
|
|
|
my ($self, %opts) = (@_); |
103
|
0
|
|
|
|
|
|
my $base = Apache::Hadoop::Watcher::Base->new; |
104
|
0
|
0
|
|
|
|
|
my $url = defined $opts{'query'} ? $self->{'jmx'}.'?qry='.$opts{'query'} : $self->{'jmx'}; |
105
|
0
|
|
|
|
|
|
$self->{'out'} = (decode_json $base->_wget (url=>$url))->{'beans'}; |
106
|
|
|
|
|
|
|
#$self->{'out'} = (decode_json $base->_wget (url=>$url)); |
107
|
0
|
|
|
|
|
|
$base->_jsonjmx ( $self->{'out'} ); |
108
|
0
|
|
|
|
|
|
$self->{'out'} =~ s/\'//g; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# request |
112
|
|
|
|
|
|
|
sub request { |
113
|
0
|
|
|
0
|
0
|
|
my ($self, %opts) = (@_); |
114
|
0
|
|
|
|
|
|
my $q = undef; |
115
|
|
|
|
|
|
|
|
116
|
0
|
0
|
|
|
|
|
$q = $self->{'qlist'}->{$opts{'method'}} if defined $opts{'method'}; |
117
|
0
|
0
|
|
|
|
|
$q = $opts{'service'} if defined $opts{'service'}; |
118
|
0
|
|
|
|
|
|
$self->_query (query => $q); |
119
|
0
|
|
|
|
|
|
return $self; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__END__ |