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