| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Siebel::Srvrmgr::ListParser::Output::Tabular::Struct; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Siebel::Srvrmgr::ListParser::Output::Tabular::Struct - base class for parsing srvrmgr tabular output |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=cut |
|
10
|
|
|
|
|
|
|
|
|
11
|
27
|
|
|
27
|
|
26153
|
use Moose; |
|
|
27
|
|
|
|
|
685772
|
|
|
|
27
|
|
|
|
|
196
|
|
|
12
|
27
|
|
|
27
|
|
177124
|
use namespace::autoclean; |
|
|
27
|
|
|
|
|
16655
|
|
|
|
27
|
|
|
|
|
722
|
|
|
13
|
27
|
|
|
27
|
|
1969
|
use Carp; |
|
|
27
|
|
|
|
|
61
|
|
|
|
27
|
|
|
|
|
11552
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=pod |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
This is a base classes to parse C<srvrmgr> output in tabular form. That means that the output is expected to be |
|
20
|
|
|
|
|
|
|
as a table, having a header and a clear definition of columns. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
The subclasses of this class are expected to be used inside an output class like L<Siebel::Srvrmgr::ListParser::Output::Tabular> |
|
23
|
|
|
|
|
|
|
since it will know the differences in parsing fixed width output from delimited one. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 header_regex |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This attribute is read-only. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
The regular expression used to match the header of the list <command> output (the sequence of column names). |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
There is a L<Moose> C<builder> associated with it, so the definition of the regular expression is created automatically. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This attribute is also C<lazy>. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has 'header_regex' => ( |
|
40
|
|
|
|
|
|
|
is => 'ro', |
|
41
|
|
|
|
|
|
|
isa => 'Str', |
|
42
|
|
|
|
|
|
|
builder => '_build_header_regex', |
|
43
|
|
|
|
|
|
|
writer => '_set_header_regex', |
|
44
|
|
|
|
|
|
|
reader => 'get_header_regex', |
|
45
|
|
|
|
|
|
|
lazy => 1 |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _build_header_regex { |
|
49
|
|
|
|
|
|
|
|
|
50
|
85
|
|
|
85
|
|
162
|
my $self = shift; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$self->_set_header_regex( |
|
53
|
85
|
|
|
|
|
4510
|
join( $self->get_col_sep(), @{ $self->get_header_cols() } ) ); |
|
|
85
|
|
|
|
|
4631
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=pod |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 col_sep |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
This attribute is read-only. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
A regular expression string used to match the columns separator. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
col_sep has a builder C<sub> that must be override by subclasses of this class or |
|
66
|
|
|
|
|
|
|
an exception will be raised. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This attribute is also C<lazy>. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
has 'col_sep' => ( |
|
73
|
|
|
|
|
|
|
is => 'ro', |
|
74
|
|
|
|
|
|
|
isa => 'Str', |
|
75
|
|
|
|
|
|
|
builder => '_build_col_sep', |
|
76
|
|
|
|
|
|
|
writer => '_set_col_sep', |
|
77
|
|
|
|
|
|
|
reader => 'get_col_sep', |
|
78
|
|
|
|
|
|
|
lazy => 1 |
|
79
|
|
|
|
|
|
|
); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _build_col_sep { |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
0
|
|
0
|
confess '_build_col_sep must be overrided by subclasses'; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 header_cols |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This attribute is read-only and required during object instantiation. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
An array reference with all the header columns names, in the exact sequence their appear in the output. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
has 'header_cols' => ( |
|
96
|
|
|
|
|
|
|
is => 'ro', |
|
97
|
|
|
|
|
|
|
isa => 'ArrayRef', |
|
98
|
|
|
|
|
|
|
reader => 'get_header_cols', |
|
99
|
|
|
|
|
|
|
writer => '_set_header_cols', |
|
100
|
|
|
|
|
|
|
required => 1 |
|
101
|
|
|
|
|
|
|
); |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=pod |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 METHODS |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
All the attributes, since read-only, have their associated getters. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 get_col_sep |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Returns the col_sep attribute value. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 get_header_cols |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Returns the header_cols attribute value. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 split_fields |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Split a output line into fields as defined by C<get_col_sep> method. It expects a string as parameter. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns an array reference. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
If the separator could not be matched against the string, returns C<undef>. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub split_fields { |
|
128
|
|
|
|
|
|
|
|
|
129
|
4062
|
|
|
4062
|
1
|
6380
|
my $self = shift; |
|
130
|
4062
|
|
|
|
|
5358
|
my $line = shift; |
|
131
|
|
|
|
|
|
|
|
|
132
|
4062
|
|
|
|
|
202501
|
my $sep = $self->get_col_sep(); |
|
133
|
|
|
|
|
|
|
|
|
134
|
4062
|
|
|
|
|
12773
|
my $comp_sep = qr/$sep/; |
|
135
|
|
|
|
|
|
|
|
|
136
|
4062
|
100
|
|
|
|
14999
|
if ( $line =~ $comp_sep ) { |
|
137
|
|
|
|
|
|
|
|
|
138
|
4060
|
|
|
|
|
27497
|
my @columns = split( $comp_sep, $line ); |
|
139
|
4060
|
|
|
|
|
14782
|
return \@columns; |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
else { |
|
143
|
|
|
|
|
|
|
|
|
144
|
2
|
|
|
|
|
11
|
return undef; |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=pod |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 define_fields_pattern |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This method must be overrided by subclasses of this classes or an exception will be raised. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
It is responsible to define automatically the fields pattern to be used during parsing to retrieve |
|
157
|
|
|
|
|
|
|
fields values. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub define_fields_pattern { |
|
162
|
|
|
|
|
|
|
|
|
163
|
2
|
|
|
2
|
1
|
1464
|
confess |
|
164
|
|
|
|
|
|
|
'define_fields_pattern must be overrided by subclasses of Siebel::Srvrmgr::ListParser::Output::Tabular::Struct'; |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=pod |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head2 get_fields |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
This method must be overrided by subclasses of this classes or an exception will be raised. |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This methods returns the fields data as an array reference. Expects as parameter the string of the line of |
|
175
|
|
|
|
|
|
|
C<srvrmgr> output. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub get_fields { |
|
180
|
|
|
|
|
|
|
|
|
181
|
2
|
|
|
2
|
1
|
4110
|
confess |
|
182
|
|
|
|
|
|
|
'get_fields must be overrided by subclasses of Siebel::Srvrmgr::ListParser::Output::Tabular::Struct'; |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=pod |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 CAVEATS |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
All subclasses of Siebel::Srvrmgr::ListParser::Output::Tabular::Struct expect to have both the header and trailer of |
|
191
|
|
|
|
|
|
|
executed commands in C<srvrmgr> program. Removing one or both of them will result in parsing errors and |
|
192
|
|
|
|
|
|
|
probably exceptions. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=over |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=item * |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
L<Siebel::Srvrmgr::ListParser::Output::Tabular> |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item * |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
L<Moose> |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item * |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
L<Siebel::Srvrmgr::ListParser::Output::Tabular::Struct::Fixed> |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=item * |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
L<Siebel::Srvrmgr::ListParser::Output::Tabular::Struct::Delimited> |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=back |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 AUTHOR |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>. |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
This software is copyright (c) 2013 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>. |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
This file is part of Siebel Monitoring Tools. |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Siebel Monitoring Tools is free software: you can redistribute it and/or modify |
|
227
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
|
228
|
|
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or |
|
229
|
|
|
|
|
|
|
(at your option) any later version. |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Siebel Monitoring Tools is distributed in the hope that it will be useful, |
|
232
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
233
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
234
|
|
|
|
|
|
|
GNU General Public License for more details. |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
|
237
|
|
|
|
|
|
|
along with Siebel Monitoring Tools. If not, see L<http://www.gnu.org/licenses/>. |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=cut |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |