File Coverage

blib/lib/Siebel/Srvrmgr/ListParser/Output/Tabular/ListServers.pm
Criterion Covered Total %
statement 26 27 96.3
branch 1 2 50.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 33 35 94.2


line stmt bran cond sub pod time code
1             package Siebel::Srvrmgr::ListParser::Output::Tabular::ListServers;
2 4     4   7202 use Moose;
  4         210027  
  4         27  
3 4     4   19247 use namespace::autoclean;
  4         1071  
  4         26  
4              
5             =pod
6              
7             =head1 NAME
8              
9             Siebel::Srvrmgr::ListParser::Output::Tabular::ListServers - subclass to parse list servers command
10              
11             =cut
12              
13             extends 'Siebel::Srvrmgr::ListParser::Output::Tabular';
14              
15             =pod
16              
17             =head1 SYNOPSIS
18              
19             See L<Siebel::Srvrmgr::ListParser::Output::Tabular> for examples.
20              
21             =head1 DESCRIPTION
22              
23             This subclass of L<Siebel::Srvrmgr::ListParser::Output::Tabular> parses the output of the command C<list servers>.
24              
25             This class expectes the following order and configuration of fields from C<list servers> command:
26              
27             srvrmgr> configure list servers
28             SBLSRVR_NAME (31): Siebel Server name
29             SBLSRVR_GROUP_NAME (46): Siebel server Group name
30             HOST_NAME (31): Host name of server machine
31             INSTALL_DIR (256): Server install directory name
32             SBLMGR_PID (16): O/S process/thread ID of Siebel Server Manager
33             SV_DISP_STATE (61): Server state (started, stopped, etc.)
34             SBLSRVR_STATE (31): Server state internal (started, stopped, etc.)
35             START_TIME (21): Time the server was started
36             END_TIME (21): Time the server was stopped
37             SBLSRVR_STATUS (101): Server status
38              
39             Anything different from that will generate exceptions when parsing
40              
41             =head1 ATTRIBUTES
42              
43             All from parent class.
44              
45             =head1 METHODS
46              
47             All methods from superclass plus some additional ones described below.
48              
49             The hash reference returned by C<get_data_parsed> will look like that:
50              
51             siebfoobar' => HASH
52             'end_time' => ''
53             'host_name' => 'siebfoobar'
54             'install_dir' => '/app/siebel/siebsrvr'
55             'sblmgr_pid' => 20452
56             'sblsrvr_group_name' => ''
57             'sblsrvr_state' => 'Running'
58             'sblsrvr_status' => '8.1.1.7 [21238] LANG_INDEPENDENT'
59             'start_time' => '2013-04-22 15:32:25'
60             'sv_disp_state' => 'Running'
61              
62             where the keys are the Siebel servers names, each one holding a reference to another hash with the keys shown above.
63              
64             =cut
65              
66             sub _build_expected {
67              
68 9     9   17 my $self = shift;
69              
70 9         323 $self->_set_expected_fields(
71             [
72             'SBLSRVR_NAME', 'SBLSRVR_GROUP_NAME',
73             'HOST_NAME', 'INSTALL_DIR',
74             'SBLMGR_PID', 'SV_DISP_STATE',
75             'SBLSRVR_STATE', 'START_TIME',
76             'END_TIME', 'SBLSRVR_STATUS'
77             ]
78             );
79              
80             }
81              
82             =pod
83              
84             =head2 get_lc_fields
85              
86             Returns an array reference with all the expected fields names in lowercase.
87              
88             =cut
89              
90             sub get_lc_fields {
91              
92 16     16 1 11 my $self = shift;
93 16         18 my @names;
94              
95 16         15 foreach ( @{ $self->get_expected_fields() } ) {
  16         500  
96              
97 160         175 push( @names, lc($_) );
98              
99             }
100              
101 16         26 return \@names;
102              
103             }
104              
105             sub _consume_data {
106              
107 16     16   19 my $self = shift;
108 16         15 my $fields_ref = shift;
109 16         18 my $parsed_ref = shift;
110              
111 16         13 my $list_len = scalar( @{$fields_ref} );
  16         16  
112 16         21 my $server_name = $fields_ref->[0];
113              
114 16         30 my $columns_ref = $self->get_lc_fields();
115              
116 16 50       21 if ( @{$fields_ref} ) {
  16         27  
117              
118 16         34 for ( my $i = 1 ; $i < $list_len ; $i++ ) {
119              
120 144         278 $parsed_ref->{$server_name}->{ $columns_ref->[$i] } =
121             $fields_ref->[$i];
122              
123             }
124              
125 16         74 return 1;
126              
127             }
128             else {
129              
130 0           return 0;
131              
132             }
133              
134             }
135              
136             =pod
137              
138             =head1 SEE ALSO
139              
140             =over
141              
142             =item *
143              
144             L<Siebel::Srvrmgr::ListParser::Output::Tabular>
145              
146             =item *
147              
148             L<Moose>
149              
150             =back
151              
152             =head1 AUTHOR
153              
154             Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
155              
156             =head1 COPYRIGHT AND LICENSE
157              
158             This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
159              
160             This file is part of Siebel Monitoring Tools.
161              
162             Siebel Monitoring Tools is free software: you can redistribute it and/or modify
163             it under the terms of the GNU General Public License as published by
164             the Free Software Foundation, either version 3 of the License, or
165             (at your option) any later version.
166              
167             Siebel Monitoring Tools is distributed in the hope that it will be useful,
168             but WITHOUT ANY WARRANTY; without even the implied warranty of
169             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
170             GNU General Public License for more details.
171              
172             You should have received a copy of the GNU General Public License
173             along with Siebel Monitoring Tools. If not, see L<http://www.gnu.org/licenses/>.
174              
175             =cut
176              
177             __PACKAGE__->meta->make_immutable;
178             1;