File Coverage

blib/lib/Siebel/Srvrmgr/ListParser/Output/Tabular/ByServer.pm
Criterion Covered Total %
statement 21 21 100.0
branch 4 4 100.0
condition 3 3 100.0
subroutine 6 6 100.0
pod 2 2 100.0
total 36 36 100.0


line stmt bran cond sub pod time code
1             package Siebel::Srvrmgr::ListParser::Output::Tabular::ByServer;
2              
3 4     4   3883 use strict;
  4         10  
  4         124  
4 4     4   25 use warnings;
  4         12  
  4         170  
5 4     4   23 use Moose::Role;
  4         11  
  4         38  
6 4     4   22368 use Siebel::Srvrmgr::Regexes qw(SIEBEL_SERVER);
  4         10  
  4         1055  
7              
8             =head1 NAME
9              
10             Siebel::Srvrmgr::ListParser::Output::Tabular::ByServer - a Moose Role to retrieve data under a Siebel Server
11              
12             =head1 SYNOPSIS
13              
14             with 'Siebel::Srvrmgr::ListParser::Output::Tabular::ByServer';
15              
16             =head1 DESCRIPTION
17              
18             This roles exposes two methods common to classes that have to parse data that is "under" a Siebel Server, for example, the output
19             of the C<list tasks> and C<list procs>. Here:
20              
21             srvrmgr> list procs
22              
23             SV_NAME CC_ALIAS TK_PID TK_SISPROC TK_NUM_NORMAL_TASKS TK_NUM_SUBTASK_TASKS TK_NUM_HIDDEN_TASKS PROC_VM_FREE_PAGES PROC_VM_USED_PAGES PROC_PH_USED_PAGES TK_IS_PROC_ENABLED TK_DISP_RUNSTATE TK_SOCKETS
24             ------------ ------------------------- ------ ---------- ------------------- -------------------- ------------------- ------------------ ------------------ ------------------ ------------------ ---------------- ----------
25             foobar000023 CommInboundRcvr 5504 29 0 0 35 947650 100925 40205 True Running 0
26             foobar000023 ServerMgr 2153 119 1 0 2 1020680 27895 7538 True Running 0
27             foobar000023 EAIObjMgr_esn 5394 24 0 0 7 914435 134140 74499 True Running 0
28             foobar000023 EAIObjMgr_esn 5371 23 0 0 7 930429 118146 60284 True Running 0
29             foobar000023 EAIObjMgr_esn 5353 22 0 0 7 916442 132133 73079 True Running 0
30              
31             =head1 METHODS
32              
33             All classes using this role must implement a C<get_data_parsed> method and the method must return a hash reference containing Siebel Server names as keys
34             and an array reference as their respective values.
35              
36             =cut
37              
38             requires qw(get_data_parsed);
39              
40             =head2 get_servers
41              
42             Returns a list of the Siebel Server names from the parsed output, sorted alphabetically.
43              
44             =cut
45              
46             sub get_servers {
47              
48 3     3 1 27 my $self = shift;
49              
50 3         8 return sort( keys( %{ $self->get_data_parsed() } ) );
  3         185  
51              
52             }
53              
54             =head2 val_items_server
55              
56             Returns the items (whatever they are) under a Siebel Server name.
57              
58             Expects as parameter the Siebel Server name and will validate it.
59              
60             If correct, the data under the server will be returned as a reference. Otherwise a exception will be raised.
61              
62             =cut
63              
64             sub val_items_server {
65              
66 12     12 1 17 my $self = shift;
67 12         20 my $server = shift;
68              
69 12 100 100     107 confess 'Siebel Server name parameter is required and must be valid'
70             unless ( ( defined($server) ) and ( $server =~ SIEBEL_SERVER ) );
71              
72 6         309 my $data_ref = $self->get_data_parsed();
73              
74             confess "servername '$server' is not available in the output parsed"
75 6 100       69 unless ( exists( $data_ref->{$server} ) );
76              
77 3         12 return $data_ref->{$server};
78              
79             }
80              
81             =head2 CAVEATS
82              
83             This role is tight coupled with the interface of L<Siebel::Srvrmgr::ListParser::Output::Tabular>, so consider
84             it as experimental.
85              
86             =head2 SEE ALSO
87              
88             =over
89              
90             =item *
91              
92             L<Siebel::Srvrmgr::ListParser::Output::Tabular>
93              
94             =item *
95              
96             L<Moose::Role>
97              
98             =back
99              
100             =head1 AUTHOR
101              
102             Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
103              
104             =head1 COPYRIGHT AND LICENSE
105              
106             This software is copyright (c) 2015 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
107              
108             This file is part of Siebel Monitoring Tools.
109              
110             Siebel Monitoring Tools is free software: you can redistribute it and/or modify
111             it under the terms of the GNU General Public License as published by
112             the Free Software Foundation, either version 3 of the License, or
113             (at your option) any later version.
114              
115             Siebel Monitoring Tools is distributed in the hope that it will be useful,
116             but WITHOUT ANY WARRANTY; without even the implied warranty of
117             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
118             GNU General Public License for more details.
119              
120             You should have received a copy of the GNU General Public License
121             along with Siebel Monitoring Tools. If not, see L<http://www.gnu.org/licenses/>.
122              
123             =cut
124              
125             1;