File Coverage

blib/lib/Siebel/Srvrmgr/ListParser/Output/Tabular/ListProcs.pm
Criterion Covered Total %
statement 35 36 97.2
branch 6 8 75.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 49 52 94.2


line stmt bran cond sub pod time code
1             package Siebel::Srvrmgr::ListParser::Output::Tabular::ListProcs;
2              
3 1     1   3560 use Moose 2.0401;
  1         21  
  1         8  
4 1     1   7164 use namespace::autoclean 0.13;
  1         26  
  1         9  
5 1     1   631 use Siebel::Srvrmgr::ListParser::Output::ListProcs::Proc;
  1         417  
  1         324  
6             our $VERSION = '0.29'; # VERSION
7              
8             =pod
9              
10             =head1 NAME
11              
12             Siebel::Srvrmgr::ListParser::Output::Tabular::ListProcs - subclass to parse list procs command
13              
14             =cut
15              
16             extends 'Siebel::Srvrmgr::ListParser::Output::Tabular';
17              
18             with 'Siebel::Srvrmgr::ListParser::Output::Tabular::ByServer';
19              
20             =head1 DESCRIPTION
21              
22             This subclass of L<Siebel::Srvrmgr::ListParser::Output::Tabular> parses the output of the command C<list comp types>.
23              
24             This is the list configuration of the C<srvrmgr> expected by the module:
25              
26             srvrmgr> configure list procs
27             SV_NAME (31): Server name
28             CC_ALIAS (31): Component alias
29             TK_PID (11): Task process id
30             TK_SISPROC (11): Task sisproc number
31             TK_NUM_NORMAL_TASKS (11): Number of normal tasks in this process
32             TK_NUM_SUBTASK_TASKS (11): Number of subtask tasks in this process
33             TK_NUM_HIDDEN_TASKS (11): Number of hidden tasks in this process
34             PROC_VM_FREE_PAGES (11): Process virtual memory free pages
35             PROC_VM_USED_PAGES (11): Process virtual memory used pages
36             PROC_PH_USED_PAGES (11): Process physical memory used pages
37             TK_IS_PROC_ENABLED (31): Is the process enabled for tasks
38             TK_DISP_RUNSTATE (31): Process run state
39             TK_SOCKETS (11): Sockets Received
40              
41             If the configuration is not setup as this, the parsing will fail and the module may raise exceptions.
42              
43             This class will B<not> support fixed width output: with such configuration, the width of CC_ALIAS column will vary and not respect the configured with in C<srvrmgr>.
44              
45             =head1 ATTRIBUTES
46              
47             All from superclass.
48              
49             =head1 METHODS
50              
51             =cut
52              
53             sub _build_expected {
54              
55 1     1   3 my $self = shift;
56              
57 1         46 $self->_set_expected_fields(
58             [
59             'SV_NAME', 'CC_ALIAS',
60             'TK_PID', 'TK_SISPROC',
61             'TK_NUM_NORMAL_TASKS', 'TK_NUM_SUBTASK_TASKS',
62             'TK_NUM_HIDDEN_TASKS', 'PROC_VM_FREE_PAGES',
63             'PROC_VM_USED_PAGES', 'PROC_PH_USED_PAGES',
64             'TK_IS_PROC_ENABLED', 'TK_DISP_RUNSTATE',
65             'TK_SOCKETS'
66             ]
67             );
68              
69             }
70              
71             =head2 get_procs
72              
73             Returns a iterator (sub reference) to retrieve L<Siebel::Srvrmgr::ListParser::Output::ListProcs::Proc> objects from the parsed output.
74              
75             Expects as parameter the name of the server tha you want to retrieve the procs.
76              
77             =cut
78              
79             sub get_procs {
80              
81 4     4 1 9053 my $self = shift;
82 4         11 my $server = shift;
83 4         10 my $counter = 0;
84              
85 4         22 my $server_ref = $self->val_items_server($server);
86              
87 1         4 my $total = scalar( @{$server_ref} ) - 1;
  1         7  
88              
89             return sub {
90              
91 48 100   48   1272 if ( $counter <= $total ) {
92              
93 47         260 my $fields_ref = $server_ref->[$counter];
94              
95 47         172 $counter++;
96              
97 47 50       4862 return Siebel::Srvrmgr::ListParser::Output::ListProcs::Proc->new(
98             {
99             server => $fields_ref->[0],
100             comp_alias => $fields_ref->[1],
101             pid => $fields_ref->[2],
102             sisproc => $fields_ref->[3],
103             normal_tasks => $fields_ref->[4],
104             sub_tasks => $fields_ref->[5],
105             hidden_tasks => $fields_ref->[6],
106             vm_free => $fields_ref->[7],
107             vm_used => $fields_ref->[8],
108             pm_used => $fields_ref->[9],
109             proc_enabled => ( $fields_ref->[10] eq 'True' ) ? 1 : 0,
110             run_state => $fields_ref->[11],
111             sockets => $fields_ref->[12]
112              
113             }
114             );
115              
116             }
117             else {
118              
119 1         5 return;
120              
121             }
122              
123             } # end of sub block
124 1         14 }
125              
126             sub _consume_data {
127              
128 103     103   167 my $self = shift;
129 103         154 my $fields_ref = shift;
130 103         162 my $parsed_ref = shift;
131              
132 103 50       140 if ( @{$fields_ref} ) {
  103         221  
133              
134 103         166 my %line;
135 103         232 my $server_name = $fields_ref->[0];
136              
137 103 100       212 if ( exists( $parsed_ref->{$server_name} ) ) {
138              
139 100         141 push( @{ $parsed_ref->{$server_name} }, $fields_ref );
  100         228  
140              
141             }
142             else {
143              
144 3         11 $parsed_ref->{$server_name} = [$fields_ref];
145              
146             }
147              
148 103         415 return 1;
149              
150             }
151             else {
152              
153 0           return 0;
154              
155             }
156              
157             }
158              
159             =pod
160              
161             =head1 SEE ALSO
162              
163             =over
164              
165             =item *
166              
167             L<Siebel::Srvrmgr::ListParser::Output::Tabular>
168              
169             =item *
170              
171             L<Moose>
172              
173             =item *
174              
175             L<Siebel::Srvrmgr::ListParser::Output::Tabular::ByServer>
176              
177             =back
178              
179             =head1 AUTHOR
180              
181             Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
182              
183             =head1 COPYRIGHT AND LICENSE
184              
185             This software is copyright (c) 2015 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
186              
187             This file is part of Siebel Monitoring Tools.
188              
189             Siebel Monitoring Tools is free software: you can redistribute it and/or modify
190             it under the terms of the GNU General Public License as published by
191             the Free Software Foundation, either version 3 of the License, or
192             (at your option) any later version.
193              
194             Siebel Monitoring Tools is distributed in the hope that it will be useful,
195             but WITHOUT ANY WARRANTY; without even the implied warranty of
196             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
197             GNU General Public License for more details.
198              
199             You should have received a copy of the GNU General Public License
200             along with Siebel Monitoring Tools. If not, see L<http://www.gnu.org/licenses/>.
201              
202             =cut
203              
204             __PACKAGE__->meta->make_immutable;