line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Hadoop::DFSAdmin::ReportParser; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
21785
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1053
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.3"; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub parse { |
9
|
3
|
|
|
3
|
0
|
10345
|
my ($this, @lines) = @_; |
10
|
3
|
|
|
|
|
28
|
chomp @lines; |
11
|
3
|
|
|
|
|
6
|
my @summary = (); |
12
|
3
|
|
|
|
|
32
|
while (@lines) { |
13
|
30
|
100
|
|
|
|
70
|
last if $lines[0] =~ m!^-+$!; |
14
|
27
|
|
|
|
|
57
|
push @summary, (shift @lines); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
return +{ |
17
|
3
|
|
|
|
|
13
|
namenode(@summary), |
18
|
|
|
|
|
|
|
datanodes(@lines), |
19
|
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub namenode { |
23
|
3
|
|
|
3
|
0
|
11
|
my @summary = @_; |
24
|
3
|
|
|
|
|
6
|
my %values = (); |
25
|
3
|
|
|
|
|
6
|
foreach my $line (@summary) { |
26
|
27
|
100
|
|
|
|
215
|
if ($line =~ m!^Configured Capacity: *(\d+)!i) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
27
|
3
|
|
|
|
|
15
|
$values{capacity_configured} = $1; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
elsif ($line =~ m!^Present Capacity: *(\d+)!i) { |
30
|
3
|
|
|
|
|
7
|
$values{capacity_present} = $1; |
31
|
3
|
|
|
|
|
8
|
$values{capacity} = $1; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif ($line =~ m!^DFS Remaining: *(\d+)!i) { |
34
|
3
|
|
|
|
|
8
|
$values{remaining} = $1; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
elsif ($line =~ m!^DFS Used: *(\d+)!i) { |
37
|
3
|
|
|
|
|
8
|
$values{used} = $1; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
elsif ($line =~ m!^DFS Used%: *([.0-9]+)!i) { |
40
|
3
|
|
|
|
|
9
|
$values{used_percent} = $1; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif ($line =~ m!^Under replicated blocks: *(\d+)!i) { |
43
|
3
|
|
|
|
|
17
|
$values{blocks_under_replicated} = $1; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
elsif ($line =~ m!^Blocks with corrupt replicas: *(\d+)!i) { |
46
|
3
|
|
|
|
|
9
|
$values{blocks_with_corrupt_replicas} = $1; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
elsif ($line =~ m!^Missing blocks: *(\d+)!i) { |
49
|
3
|
|
|
|
|
8
|
$values{blocks_missing} = $1; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
3
|
|
|
|
|
19
|
$values{remaining_percent} = undef; |
53
|
3
|
50
|
33
|
|
|
37
|
if (defined $values{remaining} and defined $values{capacity_configured}) { |
54
|
3
|
|
|
|
|
44
|
$values{remaining_percent} = sprintf("%.2f", $values{remaining} * 100 / $values{capacity_configured}); |
55
|
|
|
|
|
|
|
} |
56
|
3
|
|
|
|
|
35
|
return %values; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub datanodes { |
60
|
3
|
|
|
3
|
0
|
48
|
my @lines = @_; |
61
|
3
|
|
|
|
|
5
|
my %datanode_summary = (); |
62
|
3
|
|
|
|
|
6
|
my @datanodes = (); |
63
|
3
|
|
|
|
|
6
|
my @chunk = (); |
64
|
|
|
|
|
|
|
|
65
|
3
|
|
|
|
|
11
|
foreach my $line (@lines) { |
66
|
300
|
100
|
|
|
|
711
|
if ($line =~ m!^\s*$!) { |
67
|
51
|
100
|
|
|
|
123
|
push @datanodes, datanode(@chunk) if scalar(@chunk) > 0; |
68
|
51
|
|
|
|
|
68
|
@chunk = (); |
69
|
51
|
|
|
|
|
58
|
next; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
249
|
100
|
|
|
|
445
|
next if $line =~ m!^-+$!; |
73
|
|
|
|
|
|
|
|
74
|
246
|
100
|
|
|
|
420
|
if ($line =~ m!^Datanodes available: (\d+) \((\d+) total, (\d+) dead\)!i) { |
75
|
3
|
|
|
|
|
20
|
%datanode_summary = ( |
76
|
|
|
|
|
|
|
datanodes_num => $2, |
77
|
|
|
|
|
|
|
datanodes_available => $1, |
78
|
|
|
|
|
|
|
datanodes_dead => $3, |
79
|
|
|
|
|
|
|
); |
80
|
3
|
|
|
|
|
11
|
next; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
243
|
|
|
|
|
319
|
push @chunk, $line; |
84
|
|
|
|
|
|
|
} |
85
|
3
|
50
|
|
|
|
9
|
if (scalar(@chunk) > 0) { |
86
|
3
|
|
|
|
|
7
|
push @datanodes, datanode(@chunk); |
87
|
|
|
|
|
|
|
} |
88
|
3
|
|
|
|
|
6
|
my $capacity_total = 0; |
89
|
3
|
|
|
|
|
14
|
my %aggr = ( |
90
|
|
|
|
|
|
|
used_non_dfs_total => 0, |
91
|
|
|
|
|
|
|
used_non_dfs_total_percent => 0, |
92
|
|
|
|
|
|
|
datanode_remaining_min => undef, |
93
|
|
|
|
|
|
|
datanode_remaining_max => undef, |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
|
96
|
3
|
|
|
|
|
4
|
foreach my $node (@datanodes) { |
97
|
27
|
|
|
|
|
42
|
$capacity_total += $node->{capacity_configured}; |
98
|
27
|
|
|
|
|
39
|
$aggr{used_non_dfs_total} += $node->{used_non_dfs}; |
99
|
27
|
100
|
100
|
|
|
107
|
if (not defined $aggr{datanode_remaining_min} or $aggr{datanode_remaining_min} > $node->{remaining}) { |
100
|
9
|
|
|
|
|
15
|
$aggr{datanode_remaining_min} = $node->{remaining}; |
101
|
|
|
|
|
|
|
} |
102
|
27
|
100
|
100
|
|
|
102
|
if (not defined $aggr{datanode_remaining_max} or $aggr{datanode_remaining_max} < $node->{remaining}) { |
103
|
9
|
|
|
|
|
34
|
$aggr{datanode_remaining_max} = $node->{remaining}; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
3
|
|
|
|
|
23
|
$aggr{used_non_dfs_total_percent} = sprintf("%.2f", $aggr{used_non_dfs_total} * 100 / $capacity_total); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
return ( |
109
|
3
|
|
|
|
|
84
|
%datanode_summary, |
110
|
|
|
|
|
|
|
%aggr, |
111
|
|
|
|
|
|
|
datanodes => \@datanodes, |
112
|
|
|
|
|
|
|
); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub datanode { |
116
|
27
|
|
|
27
|
0
|
55
|
my @lines = @_; |
117
|
27
|
|
|
|
|
36
|
my %node = (); |
118
|
27
|
|
|
|
|
30
|
foreach my $line (@lines){ |
119
|
243
|
100
|
|
|
|
1551
|
if ($line =~ m!^Name: *([-.:0-9a-zA-Z]+)!i) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
120
|
27
|
|
|
|
|
78
|
$node{name} = $1; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
elsif ($line =~ m!^Decommission Status *: *([a-zA-Z0-9]+)!i) { |
123
|
27
|
|
|
|
|
77
|
$node{status} = lc($1); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
elsif ($line =~ m!^Configured Capacity: *(\d+)!i) { |
126
|
27
|
|
|
|
|
64
|
$node{capacity_configured} = $1; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
elsif ($line =~ m!^DFS Used: *(\d+)!i) { |
129
|
27
|
|
|
|
|
56
|
$node{used_dfs} = $1; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
elsif ($line =~ m!^Non DFS Used: *(\d+)!i) { |
132
|
27
|
|
|
|
|
85
|
$node{used_non_dfs} = $1; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
elsif ($line =~ m!^DFS Remaining: *(\d+)!i) { |
135
|
27
|
|
|
|
|
55
|
$node{remaining} = $1; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
elsif ($line =~ m!^DFS Used%: ([.0-9]+)!i) { |
138
|
27
|
|
|
|
|
56
|
$node{used_percent} = $1; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
elsif ($line =~ m!^DFS Remaining%: ([.0-9]+)!i) { |
141
|
27
|
|
|
|
|
72
|
$node{remaining_percent} = $1; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
elsif ($line =~ m!^Last contact: (.*)!i) { |
144
|
27
|
|
|
|
|
81
|
$node{last_connect} = $1; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
27
|
|
|
|
|
71
|
return \%node; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
1; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
__END__ |