File Coverage

blib/lib/Siebel/Srvrmgr/ListParser/Output/Tabular/ByServer.pm
Criterion Covered Total %
statement 24 24 100.0
branch 4 4 100.0
condition 3 3 100.0
subroutine 7 7 100.0
pod 3 3 100.0
total 41 41 100.0


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