blib/lib/ASNMTAP/Asnmtap.pm

filter: Statementstmt 77.6% 191 / 246 Branchbran 49.4% 83 / 168 Conditioncond 59.2% 16 / 27 MC/DCmcdc 37.5% 6 / 16 Subroutinesub 88.5% 31 / 35 Podpod 92.3% 12 / 13 totaltotal 67.1% 339 / 505 CC 60 SCAR 18.8
CC
60
Cov
66%
new
18.4
getOptionsType
12.0
_getOptions
8.3
CRAP 6.6
« plugins/templates/check_template-WebTransact.pl ↑ Summary blib/lib/ASNMTAP/PseudoHash.pm »
1 # ----------------------------------------------------------------------------------------------------------
2 # © Copyright 2000-2011 by Alex Peeters [alex.peeters@citap.be]
3 # ----------------------------------------------------------------------------------------------------------
4 # 2011/mm/dd, v3.002.003, package ASNMTAP::Asnmtap Object-Oriented Perl
5 # ----------------------------------------------------------------------------------------------------------
6  
7 package ASNMTAP::Asnmtap;
8  
9 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
10  
11 107 ▶use Carp qw(carp cluck);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 107 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
15  
16 107 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 107 ▶use warnings; # Must be used in test mode only. This reduces a little process speed
Subroutine BEGIN: called CC=1 SCAR=0.0
18 #use diagnostics; # Must be used in test mode only. This reduces a lot of process speed
19  
20 107 ▶no warnings 'deprecated';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
23  
24 107 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
25 107 ▶ use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 107 @ASNMTAP::Asnmtap::ISA = qw(Exporter);
28  
29 107 %ASNMTAP::Asnmtap::EXPORT_TAGS = (ALL => [ qw($APPLICATION $BUSINESS $DEPARTMENT $COPYRIGHT $SENDEMAILTO $TYPEMONITORING $RUNCMDONDEMAND
30 $CAPTUREOUTPUT
31 $PREFIXPATH $LOGPATH $PIDPATH $PERL5LIB $MANPATH $LD_LIBRARY_PATH
32 %ERRORS %STATE %TYPE
33  
34 $CHATCOMMAND $DIFFCOMMAND $KILLALLCOMMAND $PERLCOMMAND $PPPDCOMMAND $ROUTECOMMAND $RSYNCCOMMAND $SCPCOMMAND $SSHCOMMAND
35  
36 &_checkAccObjRef
37 &_checkSubArgs0 &_checkSubArgs1 &_checkSubArgs2
38 &_checkReadOnly0 &_checkReadOnly1 &_checkReadOnly2
39 &_dumpValue
40
41 $APPLICATIONPATH
42  
43 $PLUGINPATH) ],
44  
45 ASNMTAP => [ qw($APPLICATION $BUSINESS $DEPARTMENT $COPYRIGHT $SENDEMAILTO $TYPEMONITORING $RUNCMDONDEMAND
46 $CAPTUREOUTPUT
47 $PREFIXPATH $LOGPATH $PIDPATH $PERL5LIB $MANPATH $LD_LIBRARY_PATH
48 %ERRORS %STATE %TYPE) ],
49  
50 COMMANDS => [ qw($CHATCOMMAND $DIFFCOMMAND $KILLALLCOMMAND $PERLCOMMAND $PPPDCOMMAND $ROUTECOMMAND $RSYNCCOMMAND $SCPCOMMAND $SSHCOMMAND) ],
51  
52 _HIDDEN => [ qw(&_checkAccObjRef
53 &_checkSubArgs0 &_checkSubArgs1 &_checkSubArgs2
54 &_checkReadOnly0 &_checkReadOnly1 &_checkReadOnly2
55 &_dumpValue) ],
56  
57 APPLICATIONS => [ qw($APPLICATIONPATH) ],
58  
59 PLUGINS => [ qw($PLUGINPATH) ] );
60  
61 107 @ASNMTAP::Asnmtap::EXPORT_OK = ( @{ $ASNMTAP::Asnmtap::EXPORT_TAGS{ALL} } );
62  
63 107 $ASNMTAP::Asnmtap::VERSION = do { my @r = (q$Revision: 3.002.003$ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r };
64 }
65  
66 # read config file - - - - - - - - - - - - - - - - - - - - - - - - - -
67  
68 107 my %_config;
69  
70 107 our $PREFIXPATH = '/opt/asnmtap';
71 107 my $_configfile = "$PREFIXPATH/Asnmtap.cnf";
72  
73 107 ▶if ( -e $_configfile or ( exists $ENV{ASNMTAP_PATH} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $_configfile or exists $ENV{"ASNMTAP_PATH"}) 0 107 107
Condition33%1/3
-e $_configfile or exists $ENV{"ASNMTAP_PATH"}
l!l&&r!l&&!r
00107
MC/DC0%0/2
-e $_configfile or exists $ENV{"ASNMTAP_PATH"}
-e $_configfile exists $ENV{"ASNMTAP_PATH"}
Truth table33%1/3
A or B
A= -e $_configfileB= exists $ENV{"ASNMTAP_PATH"}
ABresult
1X1
011
000
74 0 ▶ if ( exists $ENV{ASNMTAP_PATH} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ENV{"ASNMTAP_PATH"}) 0 0 0
75 0 $PREFIXPATH = $ENV{ASNMTAP_PATH};
76 0 $_configfile = "$PREFIXPATH/Asnmtap.cnf";
77 }
78  
79 0 ▶ die "ASNMTAP::Asnmtap: Config '$_configfile' doesn't exist." unless (-e $_configfile);
Branch: 1 branch
BranchTrueFalseTotal
unless -e $_configfile 0 0 0
80  
81 107 ▶ use Config::General qw(ParseConfig);
Subroutine BEGIN: called CC=1 SCAR=0.0
82 0 %_config = ParseConfig ( -ConfigFile => $_configfile, -InterPolateVars => 0 ) ;
83 0 ▶ die "ASNMTAP::Asnmtap: Config '$_configfile' can't be loaded." unless (%_config);
Branch: 1 branch
BranchTrueFalseTotal
unless %_config 0 0 0
84 0 undef $_configfile;
85 }
86  
87 # SET ENVIRONMENT VARIABLES = = = = = = = = = = = = = = = = = = = = = =
88  
89 107 ▶$ENV{PATH} = ( exists $_config{ENV}{PATH} ) ? $_config{ENV}{PATH} : '/opt/csw/bin:/usr/local/bin:/usr/bin:/bin:/opt/csw/sbin:/usr/local/sbin:/usr/sbin:/sbin';
Branch: 1 branch
BranchTrueFalseTotal
exists $_config{'ENV'}{'PATH'} ? : 0 107 107
90 107 ▶$ENV{BASH_ENV} = ( exists $_config{ENV}{BASH_ENV} ) ? $_config{ENV}{BASH_ENV} : '';
Branch: 1 branch
BranchTrueFalseTotal
exists $_config{'ENV'}{'BASH_ENV'} ? : 0 107 107
91 107 ▶$ENV{ENV} = ( exists $_config{ENV}{ENV} ) ? $_config{ENV}{ENV} : '';
Branch: 1 branch
BranchTrueFalseTotal
exists $_config{'ENV'}{'ENV'} ? : 0 107 107
92  
93 # SET ASNMTAP::Asnmtap VARIABLES - - - - - - - - - - - - - - - - - - -
94  
95 107 ▶our $PERL5LIB = $_config{SET}{PERL5LIB} if ( exists $_config{SET}{PERL5LIB} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_config{"SET"}{"PERL5LIB"} 0 107 107
96 107 ▶our $MANPATH = $_config{SET}{MANPATH} if ( exists $_config{SET}{MANPATH} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_config{"SET"}{"MANPATH"} 0 107 107
97 107 ▶our $LD_LIBRARY_PATH = $_config{SET}{LD_LIBRARY_PATH} if ( exists $_config{SET}{LD_LIBRARY_PATH} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_config{"SET"}{"LD_LIBRARY_PATH"} 0 107 107
98  
99 107 our $APPLICATIONPATH = $PREFIXPATH .'/applications';
100 107 our $PLUGINPATH = $PREFIXPATH .'/plugins';
101 107 our $LOGPATH = $PREFIXPATH .'/log';
102 107 our $PIDPATH = $PREFIXPATH .'/pid';
103  
104 107 ▶if ( exists $_config{SUBDIR} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_config{"SUBDIR"}) 0 107 107
105 0 ▶ $APPLICATIONPATH = $PREFIXPATH .'/'. $_config{SUBDIR}{APPLICATIONS} if ( exists $_config{SUBDIR}{APPLICATIONS} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_config{"SUBDIR"}{"APPLICATIONS"} 0 0 0
106 0 ▶ $PLUGINPATH = $PREFIXPATH .'/'. $_config{SUBDIR}{PLUGINS} if ( exists $_config{SUBDIR}{PLUGINS} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_config{"SUBDIR"}{"PLUGINS"} 0 0 0
107 0 ▶ $LOGPATH = $PREFIXPATH .'/'. $_config{SUBDIR}{LOG} if ( exists $_config{SUBDIR}{LOG} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_config{"SUBDIR"}{"LOG"} 0 0 0
108 0 ▶ $PIDPATH = $PREFIXPATH .'/'. $_config{SUBDIR}{PID} if ( exists $_config{SUBDIR}{PID} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_config{"SUBDIR"}{"PID"} 0 0 0
109 }
110  
111 107 ▶our $APPLICATION = ( exists $_config{COMMON}{APPLICATION} ) ? $_config{COMMON}{APPLICATION} : 'Application Monitoring';
Branch: 1 branch
BranchTrueFalseTotal
exists $_config{'COMMON'}{'APPLICATION'} ? : 0 107 107
112 107 ▶our $BUSINESS = ( exists $_config{COMMON}{BUSINESS} ) ? $_config{COMMON}{BUSINESS} : 'CITAP';
Branch: 1 branch
BranchTrueFalseTotal
exists $_config{'COMMON'}{'BUSINESS'} ? : 0 107 107
113 107 ▶our $DEPARTMENT = ( exists $_config{COMMON}{DEPARTMENT} ) ? $_config{COMMON}{DEPARTMENT} : 'Development';
Branch: 1 branch
BranchTrueFalseTotal
exists $_config{'COMMON'}{'DEPARTMENT'} ? : 0 107 107
114 107 ▶our $COPYRIGHT = ( exists $_config{COMMON}{COPYRIGHT} ) ? $_config{COMMON}{COPYRIGHT} : '2000-2011';
Branch: 1 branch
BranchTrueFalseTotal
exists $_config{'COMMON'}{'COPYRIGHT'} ? : 0 107 107
115 107 ▶our $SENDEMAILTO = ( exists $_config{COMMON}{SENDEMAILTO} ) ? $_config{COMMON}{SENDEMAILTO} : 'alex.peeters@citap.be';
Branch: 1 branch
BranchTrueFalseTotal
exists $_config{'COMMON'}{'SENDEMAILTO'} ? : 0 107 107
116 107 ▶our $TYPEMONITORING = ( exists $_config{COMMON}{TYPEMONITORING} ) ? $_config{COMMON}{TYPEMONITORING} : 'central';
Branch: 1 branch
BranchTrueFalseTotal
exists $_config{'COMMON'}{'TYPEMONITORING'} ? : 0 107 107
117 107 ▶our $RUNCMDONDEMAND = ( exists $_config{COMMON}{RUNCMDONDEMAND} ) ? $_config{COMMON}{RUNCMDONDEMAND} : 'localhost';
Branch: 1 branch
BranchTrueFalseTotal
exists $_config{'COMMON'}{'RUNCMDONDEMAND'} ? : 0 107 107
118  
119 107 ▶our $CAPTUREOUTPUT = ( exists $_config{IO}{CAPTUREOUTPUT} ) ? $_config{IO}{CAPTUREOUTPUT} : 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $_config{'IO'}{'CAPTUREOUTPUT'} ? : 0 107 107
120  
121 107 our $CHATCOMMAND = '/usr/sbin/chat';
122 107 our $DIFFCOMMAND = '/usr/bin/diff';
123 107 our $KILLALLCOMMAND = '/usr/bin/killall';
124 107 our $PERLCOMMAND = '/usr/bin/perl';
125 107 our $PPPDCOMMAND = '/usr/sbin/pppd';
126 107 our $ROUTECOMMAND = '/sbin/route';
127 107 our $RSYNCCOMMAND = '/usr/bin/rsync';
128 107 our $SCPCOMMAND = '/usr/bin/scp';
129 107 our $SSHCOMMAND = '/usr/bin/ssh';
130  
131 107 ▶if ( exists $_config{COMMAND} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_config{"COMMAND"}) 0 107 107
132 0 ▶ $CHATCOMMAND = $_config{COMMAND}{CHAT} if ( exists $_config{COMMAND}{CHAT} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_config{"COMMAND"}{"CHAT"} 0 0 0
133 0 ▶ $DIFFCOMMAND = $_config{COMMAND}{DIFF} if ( exists $_config{COMMAND}{DIFF} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_config{"COMMAND"}{"DIFF"} 0 0 0
134 0 ▶ $KILLALLCOMMAND = $_config{COMMAND}{KILLALL} if ( exists $_config{COMMAND}{KILLALL} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_config{"COMMAND"}{"KILLALL"} 0 0 0
135 0 ▶ $PERLCOMMAND = $_config{COMMAND}{PERL} if ( exists $_config{COMMAND}{PERL} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_config{"COMMAND"}{"PERL"} 0 0 0
136 0 ▶ $PPPDCOMMAND = $_config{COMMAND}{PPPD} if ( exists $_config{COMMAND}{PPPD} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_config{"COMMAND"}{"PPPD"} 0 0 0
137 0 ▶ $ROUTECOMMAND = $_config{COMMAND}{ROUTE} if ( exists $_config{COMMAND}{ROUTE} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_config{"COMMAND"}{"ROUTE"} 0 0 0
138 0 ▶ $RSYNCCOMMAND = $_config{COMMAND}{RSYNC} if ( exists $_config{COMMAND}{RSYNC} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_config{"COMMAND"}{"RSYNC"} 0 0 0
139 0 ▶ $SCPCOMMAND = $_config{COMMAND}{SCP} if ( exists $_config{COMMAND}{SCP} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_config{"COMMAND"}{"SCP"} 0 0 0
140 0 ▶ $SSHCOMMAND = $_config{COMMAND}{SSH} if ( exists $_config{COMMAND}{SSH} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_config{"COMMAND"}{"SSH"} 0 0 0
141 }
142  
143 107 undef %_config;
144  
145 # Plugin variables - - - - - - - - - - - - - - - - - - - - - - - - - - -
146  
147 107 our %ERRORS = ('OK'=>'0','WARNING'=>'1','CRITICAL'=>'2','UNKNOWN'=>'3','DEPENDENT'=>'4','OFFLINE'=>'5','NO TEST'=>'6','NO DATA'=>'7','IN PROGRESS'=>'8','TRENDLINE'=>'9');
148 107 our %STATE = ('0'=>'OK','1'=>'WARNING','2'=>'CRITICAL','3'=>'UNKNOWN','4'=>'DEPENDENT','5'=>'OFFLINE','6'=>'NO TEST','7'=>'NO DATA','8'=>'IN PROGRESS','9'=>'TRENDLINE');
149 107 our %TYPE = ('REPLACE'=>'0','APPEND'=>'1','INSERT'=>'2','COMMA_REPLACE'=>'3','COMMA_APPEND'=>'4','COMMA_INSERT'=>'5');
150  
151 # Constructor & initialisation - - - - - - - - - - - - - - - - - - - - -
152  
153 106 ▶sub new (@) {
Subroutine new: called CC=15 SCAR=29.1
Pod undocumented
154 106 my $classname = shift;
155  
156 0 ▶ unless ( defined $classname ) { my @c = caller; die "Syntax error: Class name expected after new at $c[1] line $c[2]\n" }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $classname) 0 106 106
157 0 ▶ if ( ref $classname) { my @c = caller; die "Syntax error: Can't construct new ".ref($classname)." from another object at $c[1] line $c[2]\n" }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $classname) 0 106 106
158  
159 106 my $self = {};
160  
161 106 my @parameters = (_programName => 'NOT DEFINED',
162 _programDescription => 'NOT DEFINED',
163 _programVersion => '0.000.000',
164 _programUsagePrefix => undef,
165 _programUsageSuffix => undef,
166 _programHelpPrefix => undef,
167 _programHelpSuffix => undef,
168 _programGetOptions => undef,
169 _debug => 0);
170  
171 106 ▶ if ( $] < 5.010000 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] < 5.01) { } 0 106 106
172 0 eval "use fields";
173 0 $self = fields::phash (@parameters);
174 } else {
175 107 ▶ use ASNMTAP::PseudoHash;
Subroutine BEGIN: called CC=1 SCAR=0.0
176  
177 106 $self = do {
178 106 my @array = undef;
179  
180 106 ▶ while (my ($k, $v) = splice(@parameters, 0, 2)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@parameters, 0, 2)) 954 106 1060
181 954 $array[$array[0]{$k} = @array] = $v;
182 }
183  
184 106 bless(\@array, $classname);
185 };
186 }
187  
188 106 my %args = @_;
189
190 106 ▶ $self->{_programName} = $args{_programName} if ( exists $args{_programName} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"_programName"} 106 0 106
191 106 ▶ $self->{_programDescription} = $args{_programDescription} if ( exists $args{_programDescription} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"_programDescription"} 106 0 106
192 106 ▶ $self->{_programVersion} = $args{_programVersion} if ( exists $args{_programVersion} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"_programVersion"} 106 0 106
193 106 ▶ $self->{_programUsagePrefix} = $args{_programUsagePrefix} if ( exists $args{_programUsagePrefix} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"_programUsagePrefix"} 55 51 106
194 106 ▶ $self->{_programHelpPrefix} = $args{_programHelpPrefix} if ( exists $args{_programHelpPrefix} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"_programHelpPrefix"} 55 51 106
195 106 ▶ $self->{_programUsageSuffix} = $args{_programUsageSuffix} if ( exists $args{_programUsageSuffix} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"_programUsageSuffix"} 0 106 106
196 106 ▶ $self->{_programHelpSuffix} = $args{_programHelpSuffix} if ( exists $args{_programHelpSuffix} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"_programHelpSuffix"} 0 106 106
197 106 ▶ $self->{_programGetOptions} = $args{_programGetOptions} if ( exists $args{_programGetOptions} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"_programGetOptions"} 98 8 106
198 106 ▶ $self->{_debug} = $args{_debug} if ( exists $args{_debug} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"_debug"} 106 0 106
199  
200 106 ▶ if ( defined $self->{_programVersion} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"_programVersion"}) 106 0 106
201 106 $self->{_programVersion} =~ s/^\$Revision: //;
202 106 $self->{_programVersion} =~ s/ \$\s*$//;
203 }
204  
205 106 bless ($self, $classname);
206 106 $self->_init(\%args);
207 106 $self->_getOptions();
208 40 return ($self);
209 }
210  
211 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
212  
213 106 ▶sub _init {
Subroutine _init: called CC=2 SCAR=7.0
214 106 ▶ carp ('ASNMTAP::Asnmtap: _init') if ( $_[0]->{_debug} );
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]{"_debug"} 0 106 106
215  
216 106 $_[0]->{_programUsageSuffix} = ' [-v|--verbose <LEVEL>] [-V|--version] [-h|--help] [--usage] [--dumpData]';
217  
218 106 $_[0]->{_programHelpSuffix} = "
219 -v, --verbose=<LEVEL>
220 0: single line, minimal output
221 1: single line, additional information
222 2: multi line, configuration debug output
223 3: lots of detail for problem diagnosis
224 -V, --version
225 Report version
226 -h, --help
227 Display the help message
228 --usage
229 Display the short usage statement
230 --dumpData
231 Display the stringified data structures from the current object
232 ";
233  
234 106 push (@{ $_[0]->{_programGetOptions} }, 'verbose|v:i', 'version|V', 'help|h', 'usage', 'dumpData');
235  
236 106 $_[0]->[ $_[0]->[0]{_getOptionsType} = @{$_[0]} ] = {};
237 }
238  
239 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
240  
241 130 ▶sub _getOptions {
Subroutine _getOptions: called CC=8 SCAR=21.2
242 130 ▶ carp ('ASNMTAP::Asnmtap: _getOptions') if ( $_[0]->{_debug} );
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]{"_debug"} 0 130 130
243  
244 130 Getopt::Long::Configure ('bundling', 'pass_through');
245  
246 130 my %getOptionsArgv;
247 130 my $programGetOptions = $_[0]->{_programGetOptions};
248 130 my $resultGetOptions = GetOptions ( \%getOptionsArgv, @$programGetOptions );
249 130 ▶ carp ('ASNMTAP::Asnmtap: _getOptions '. "Unknown option(s): @ARGV") if ( ref $_[0] !~ /ASNMTAP::Asnmtap::Plugins/ );
Branch: 1 branch
BranchTrueFalseTotal
if ref !($_[0] =~ /ASNMTAP::Asnmtap::Plugins/) 0 130 130
250 130 $_[0]->[ $_[0]->[0]{_getOptionsArgv} = @{$_[0]} ] = {%getOptionsArgv};
251 130 ▶ $_[0]->printRevision () if ( exists $_[0]->{_getOptionsArgv}->{version} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_[0]{"_getOptionsArgv"}{"version"} 24 106 130
252 106 ▶ $_[0]->printHelp () if ( exists $_[0]->{_getOptionsArgv}->{help} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_[0]{"_getOptionsArgv"}{"help"} 24 82 106
253 82 ▶ $_[0]->printUsage ('.') if ( exists $_[0]->{_getOptionsArgv}->{usage} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_[0]{"_getOptionsArgv"}{"usage"} 0 82 82
254  
255 82 ▶ my $verbose = (exists $_[0]->{_getOptionsArgv}->{verbose}) ? $_[0]->{_getOptionsArgv}->{verbose} : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $_[0]{'_getOptionsArgv'}{'verbose'} ? : 0 82 82
256 82 ▶ $_[0]->printUsage ('Invalid verbose option: '. $verbose) unless ($verbose =~ /^[0123]$/);
Branch: 1 branch
BranchTrueFalseTotal
unless $verbose =~ /^[0123]$/ 0 82 82
257  
258 82 $_[0]->[ $_[0]->[0]{_getOptionsValues} = @{$_[0]} ] = {};
259 }
260  
261 # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
262  
263 0 ▶sub _checkAccObjRef { unless ( ref $_[0] ) { cluck 'Syntax error: Access object reference expected'; exit $ERRORS{UNKNOWN} } }
Subroutine _checkAccObjRef: called CC=2 SCAR=10.5
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $_[0]) 0 1187 1187
264  
265 0 ▶sub _checkSubArgs0 { if ( @_ > 1 ) { cluck "Syntax error: To many arguments ". (caller 1)[3]; exit $ERRORS{UNKNOWN} } }
Subroutine _checkSubArgs0: called CC=2 SCAR=10.5
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 0 9 9
266 0 ▶sub _checkSubArgs1 { if ( @_ > 2 ) { cluck "Syntax error: To many arguments ". (caller 1)[3]; exit $ERRORS{UNKNOWN} } }
Subroutine _checkSubArgs1: called CC=2 SCAR=10.5
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 2) 0 458 458
267 0 ▶sub _checkSubArgs2 { if ( @_ > 3 ) { cluck "Syntax error: To many arguments ". (caller 1)[3]; exit $ERRORS{UNKNOWN} } }
Subroutine _checkSubArgs2: called CC=2 SCAR=10.5
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 3) 0 455 455
268  
269 0 ▶sub _checkReadOnly0 { if ( @_ > 1 ) { cluck "Syntax error: Can't change value of read-only attribute ". (caller 1)[3]; exit $ERRORS{UNKNOWN} } }
Subroutine _checkReadOnly0: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
270 0 ▶sub _checkReadOnly1 { if ( @_ > 2 ) { cluck "Syntax error: Can't change value of read-only attribute ". (caller 1)[3]; exit $ERRORS{UNKNOWN} } }
Subroutine _checkReadOnly1: called CC=2 SCAR=10.5
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 2) 0 261 261
271 0 ▶sub _checkReadOnly2 { if ( @_ > 3 ) { cluck "Syntax error: Can't change value of read-only attribute ". (caller 1)[3]; exit $ERRORS{UNKNOWN} } }
Subroutine _checkReadOnly2: called CC=2 SCAR=10.5
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 3) 0 4 4
272  
273 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
274  
275 0 ▶sub _dumpValue {
Subroutine _dumpValue: not called CC=1 SCAR=6.9
276 0 require Dumpvalue;
277 0 my $dumper = Dumpvalue->new ();
278 0 print "\n->ASNMTAP::Asnmtap: Dump debug data\n\n";
279 0 $dumper->dumpValue ( $_[0] );
280 0 print "\n\n";
281 0 cluck $_[1];
282 0 exit $ERRORS{UNKNOWN};
283 }
284  
285 # Object accessor methods - - - - - - - - - - - - - - - - - - - - - - - -
286  
287 6 ▶sub programName { &_checkAccObjRef ( $_[0] ); &_checkSubArgs1; $_[0]->{_programName} = $_[1] if ( defined $_[1] ); $_[0]->{_programName}; }
Subroutine programName: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[1] 3 3 6
288  
289 6 ▶sub programDescription { &_checkAccObjRef ( $_[0] ); &_checkSubArgs1; $_[0]->{_programDescription} = $_[1] if ( defined $_[1] ); $_[0]->{_programDescription}; }
Subroutine programDescription: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[1] 3 3 6
290  
291 6 ▶sub programVersion { &_checkAccObjRef ( $_[0] ); &_checkSubArgs1; $_[0]->{_programVersion} = $_[1] if ( defined $_[1] ); $_[0]->{_programVersion}; }
Subroutine programVersion: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[1] 3 3 6
292  
293 187 ▶sub getOptionsArgv { &_checkAccObjRef ( $_[0] ); &_checkReadOnly1; ( defined $_[1] and defined $_[0]->{_getOptionsArgv}->{$_[1]} ) ? $_[0]->{_getOptionsArgv}->{$_[1]} : undef; }
Subroutine getOptionsArgv: called CC=3 SCAR=11.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] && defined $_[0]{'_getOptionsArgv'}{$_[1]} ? : 100 87 187
Condition66%2/3
defined $_[1] and defined $_[0]{"_getOptionsArgv"}{$_[1]}
!ll&&!rl&&r
087100
MC/DC50%1/2
defined $_[1] and defined $_[0]{"_getOptionsArgv"}{$_[1]}
defined $_[1] defined $_[0]{"_getOptionsArgv"}{$_[1]}
Truth table66%2/3
A and B
A= defined $_[1]B= defined $_[0]{"_getOptionsArgv"}{$_[1]}
ABresult
0X0
100
111
294  
295 74 ▶sub getOptionsValue { &_checkAccObjRef ( $_[0] ); &_checkReadOnly1; ( defined $_[1] and defined $_[0]->{_getOptionsValues}->{$_[1]} ) ? $_[0]->{_getOptionsValues}->{$_[1]} : undef; }
Subroutine getOptionsValue: called CC=3 SCAR=11.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] && defined $_[0]{'_getOptionsValues'}{$_[1]} ? : 73 1 74
Condition66%2/3
defined $_[1] and defined $_[0]{"_getOptionsValues"}{$_[1]}
!ll&&!rl&&r
0173
MC/DC50%1/2
defined $_[1] and defined $_[0]{"_getOptionsValues"}{$_[1]}
defined $_[1] defined $_[0]{"_getOptionsValues"}{$_[1]}
Truth table66%2/3
A and B
A= defined $_[1]B= defined $_[0]{"_getOptionsValues"}{$_[1]}
ABresult
0X0
100
111
296  
297 0 ▶sub getOptionsType { &_checkAccObjRef ( $_[0] ); &_checkReadOnly1; ( defined $_[1] and defined $_[0]->{_getOptionsType}->{$_[1]} ) ? $_[0]->{_getOptionsType}->{$_[1]} : undef; }
Subroutine getOptionsType: not called CC=3 SCAR=24.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] && defined $_[0]{'_getOptionsType'}{$_[1]} ? : 0 0 0
Condition0%0/3
defined $_[1] and defined $_[0]{"_getOptionsType"}{$_[1]}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_[1] and defined $_[0]{"_getOptionsType"}{$_[1]}
defined $_[1] defined $_[0]{"_getOptionsType"}{$_[1]}
Truth table0%0/3
A and B
A= defined $_[1]B= defined $_[0]{"_getOptionsType"}{$_[1]}
ABresult
0X0
100
111
298  
299 12 ▶sub debug { &_checkAccObjRef ( $_[0] ); &_checkSubArgs1; $_[0]->{_debug} = $_[1] if ( defined $_[1] and $_[1] =~ /^[01]$/ ); $_[0]->{_debug}; }
Subroutine debug: called CC=3 SCAR=11.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[1] and $_[1] =~ /^[01]$/ 6 6 12
Condition100%3/3
defined $_[1] and $_[1] =~ /^[01]$/
!ll&&!rl&&r
336
MC/DC100%2/2
defined $_[1] and $_[1] =~ /^[01]$/
defined $_[1] $_[1] =~ /^[01]$/
Truth table100%3/3
A and B
A= defined $_[1]B= $_[1] =~ /^[01]$/
ABresult
0X0
100
111
300  
301 # Class accessor methods - - - - - - - - - - - - - - - - - - - - - - - -
302  
303 2 ▶sub dumpData {
Subroutine dumpData: called CC=3 SCAR=11.0
Pod documented
304 2 &_checkAccObjRef ( $_[0] ); &_checkSubArgs1;
305  
306 2 ▶ if ( defined $_[1] or $_[0]->{_debug} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[1] or $_[0]{"_debug"}) 1 1 2
Condition66%2/3
defined $_[1] or $_[0]{"_debug"}
l!l&&r!l&&!r
101
MC/DC50%1/2
defined $_[1] or $_[0]{"_debug"}
defined $_[1] $_[0]{"_debug"}
Truth table66%2/3
A or B
A= defined $_[1]B= $_[0]{"_debug"}
ABresult
1X1
011
000
307 107 ▶ use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
308 1 print "\n". ref ($_[0]) .": Now we'll dump data\n\n", Dumper ( $_[0] ), "\n\n";
309 }
310 }
311  
312 # Utility methods - - - - - - - - - - - - - - - - - - - - - - - - - - - -
313  
314 33 ▶sub printRevision {
Subroutine printRevision: called CC=3 SCAR=11.0
Pod documented
315 33 &_checkAccObjRef ( $_[0] ); &_checkSubArgs1;
316  
317 33 print "\nThis is program: ", $_[0]->{_programName}, " (", $_[0]->{_programDescription}, ") v", $_[0]->{_programVersion}, "
318  
319 Copyright (c) $COPYRIGHT ASNMTAP, Author: Alex Peeters [alex.peeters\@citap.be]
320  
321 ";
322  
323 33 ▶ exit ( (ref $_[0]) =~ /^ASNMTAP::Asnmtap::Plugins/ ? $ERRORS{UNKNOWN} : 0 ) unless ( defined $_[1] );
Branch: 2 branches
BranchTrueFalseTotal
unless defined $_[1] 24 9 33
ref($_[0]) =~ /^ASNMTAP::Asnmtap::Plugins/ ? : 24 0 24
324 }
325  
326 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
327  
328 47 ▶sub printUsage {
Subroutine printUsage: called CC=6 SCAR=18.2
Pod documented
329 47 &_checkAccObjRef ( $_[0] ); &_checkSubArgs1;
330  
331 47 print 'Usage: ', $_[0]->{_programName};
332 47 ▶ print (' ', $_[0]->{_programUsagePrefix}) if ( defined $_[0]->{_programUsagePrefix} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0]{"_programUsagePrefix"} 27 20 47
333 47 ▶ print (' ', $_[0]->{_programUsageSuffix}) if ( defined $_[0]->{_programUsageSuffix} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0]{"_programUsageSuffix"} 47 0 47
334 47 print "\n\n";
335  
336 47 ▶ if ( defined $_[1] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[1]) 38 9 47
337 38 ▶ print ($_[1], "\n") unless ($_[1] eq '.');
Branch: 1 branch
BranchTrueFalseTotal
unless $_[1] eq "." 38 0 38
338 38 ▶ exit ( (ref $_[0]) =~ /^ASNMTAP::Asnmtap::Plugins/ ? $ERRORS{UNKNOWN} : 0 );
Branch: 1 branch
BranchTrueFalseTotal
ref($_[0]) =~ /^ASNMTAP::Asnmtap::Plugins/ ? : 38 0 38
339 }
340 }
341  
342 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
343  
344 9 ▶sub printHelp {
Subroutine printHelp: called CC=4 SCAR=14.0
Pod documented
345 9 &_checkAccObjRef ( $_[0] ); &_checkSubArgs0;
346  
347 9 $_[0]->printRevision(1);
348  
349 9 $_[0]->printUsage();
350  
351 9 ▶ print $_[0]->{_programHelpPrefix}, "\n" if ( defined $_[0]->{_programHelpPrefix} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0]{"_programHelpPrefix"} 1 8 9
352 9 ▶ print $_[0]->{_programHelpSuffix}, "\n" if ( defined $_[0]->{_programHelpSuffix} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0]{"_programHelpSuffix"} 9 0 9
353  
354 9 print "Send email to $SENDEMAILTO if you have questions regarding\nuse of this software. To submit patches or suggest improvements, send\nemail to $SENDEMAILTO\n\n";
355  
356 9 ▶ exit ( (ref $_[0]) =~ /^ASNMTAP::Asnmtap::Plugins/ ? $ERRORS{UNKNOWN} : 0 );
Branch: 1 branch
BranchTrueFalseTotal
ref($_[0]) =~ /^ASNMTAP::Asnmtap::Plugins/ ? : 9 0 9
357 }
358  
359 # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
360  
361 6 ▶sub call_system {
Subroutine call_system: called CC=7 SCAR=20.3
Pod documented
362 6 &_checkAccObjRef ( $_[0] ); &_checkSubArgs1;
363  
364 6 my ($stdout, $stderr);
365  
366 6 ▶ if ( $CAPTUREOUTPUT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ASNMTAP::Asnmtap::CAPTUREOUTPUT) { } 6 0 6
367 107 ▶ use IO::CaptureOutput qw(capture_exec);
Subroutine BEGIN: called CC=1 SCAR=0.0
368 6 ($stdout, $stderr) = capture_exec ( $_[1] );
369 6 chomp($stdout); chomp($stderr);
370 } else {
371 0 $stdout = $stderr = ''; system ( $_[1] );
372 }
373  
374 6 my $exit_value = $? >> 8;
375 6 my $signal_num = $? & 127;
376 6 my $dumped_core = $? & 128;
377 6 ▶ my $status = ( $exit_value == 0 && $signal_num == 0 && $dumped_core == 0 && $stderr eq '' ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$exit_value == 0 && $signal_num == 0 && $dumped_core == 0 && $stderr eq '' ? : 3 3 6
Condition66%6/9
$exit_value == 0 and $signal_num == 0 and $dumped_core == 0 and $stderr eq ""
!ll&&!rl&&r
303
$exit_value == 0 and $signal_num == 0 and $dumped_core == 0
!ll&&!rl&&r
303
$exit_value == 0 and $signal_num == 0
!ll&&!rl&&r
303
MC/DC25%1/4
$exit_value == 0 and $signal_num == 0 and $dumped_core == 0 and $stderr eq ""
$exit_value == 0 $signal_num == 0 $dumped_core == 0 $stderr eq ""
Truth table40%2/5
A and B and C and D
A= $exit_value == 0B= $signal_num == 0C= $dumped_core == 0D= $stderr eq ""
ABCDresult
0XXX0
10XX0
110X0
11100
11111
378  
379 6 ▶ if ( $_[0]->{_debug} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]{"_debug"}) 0 6 6
380 0 print ref $_[0], ": command : $_[1]\n",
381 ref $_[0], ": exit value : $exit_value\n",
382 ref $_[0], ": signal number: $signal_num\n",
383 ref $_[0], ": dumped core : $dumped_core\n",
384 ref $_[0], ": status : $status\n",
385 ref $_[0], ": stdout : '$stdout'\n",
386 ref $_[0], ": stderr : '$stderr'\n";
387 }
388  
389 6 return ( $status, $stdout, $stderr );
390 }
391  
392 # Destructor - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
393  
394 0 ▶sub DESTROY { print (ref ($_[0]), "::DESTROY: ()\n") if ( $_[0]->{_debug} ); }
Subroutine DESTROY: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]{"_debug"} 0 0 0
395  
396 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
397  
398 107 1;
399  
400 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
401  
402 __END__
« plugins/templates/check_template-WebTransact.pl ↑ Summary blib/lib/ASNMTAP/PseudoHash.pm »