plugins/templates/check_template-WebTransact.pl

filter: Statementstmt 63.2% 43 / 68 Branchbran 14.2% 2 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 12 / 16 Podpod n/a totaltotal 55.3% 57 / 103 CC 9 SCAR 24.6
CC
9
Cov
53%
customWebTransact
42.0
__ANON__
3.0
__ANON__
3.0
CRAP 11.7
« t/Asnmtap/Plugins/WebTransact.t ↑ Summary blib/lib/ASNMTAP/Asnmtap.pm »
1 #!/usr/bin/env perl
2 # ----------------------------------------------------------------------------------------------------------
3 # © Copyright 2003-2011 by Alex Peeters [alex.peeters@citap.be]
4 # ----------------------------------------------------------------------------------------------------------
5 # 2011/mm/dd, v3.002.003, check_template-WebTransact.pl
6 # ----------------------------------------------------------------------------------------------------------
7  
8 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use warnings; # Must be used in test mode only. This reduces a little process speed
Subroutine BEGIN: called CC=1 SCAR=0.0
10 #use diagnostics; # Must be used in test mode only. This reduces a lot of process speed
11  
12 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
13  
14 0 ▶BEGIN { if ( $ENV{ASNMTAP_PERL5LIB} ) { eval 'use lib ( "$ENV{ASNMTAP_PERL5LIB}" )'; } }
Subroutine BEGIN: called CC=2 SCAR=9.2
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"ASNMTAP_PERL5LIB"}) 0 3 3
15  
16 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
17  
18 3 ▶use ASNMTAP::Asnmtap::Plugins v3.002.003;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 3 ▶use ASNMTAP::Asnmtap::Plugins qw(:PLUGINS);
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
22  
23 3 my $objectPlugins = ASNMTAP::Asnmtap::Plugins->new (
24 _programName => 'check_template-WebTransact.pl',
25 _programDescription => "WebTransact plugin template for testing the '$APPLICATION'",
26 _programVersion => '3.002.003',
27 _programGetOptions => ['environment|e:s', 'proxy:s', 'timeout|t:i', 'trendline|T:i'],
28 _timeout => 30,
29 _debug => 0);
30  
31 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
32  
33 3 ▶use ASNMTAP::Asnmtap::Plugins::WebTransact;
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 1 my @URLS = ();
36 1 my $objectWebTransact = ASNMTAP::Asnmtap::Plugins::WebTransact->new ( \$objectPlugins, \@URLS );
37  
38 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
39 # Start plugin - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
40 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
41  
42 1 $objectPlugins->pluginValue ( message => 'www.citap.be/www.citap.com' );
43  
44 1 @URLS = (
45 { Method => 'GET', Url => 'http://www.citap.be/', Qs_var => [], Qs_fixed => [], Exp => "", Exp_Fault => ">>>NIHIL<<<", Msg => "Consulting Internet Technology Alex Peeters", Msg_Fault => "Consulting Internet Technology Alex Peeters", Perfdata_Label => 'Label 1' },
46 { Method => 'GET', Url => 'http://www.citap.be/', Qs_var => [], Qs_fixed => [], Exp => "Consulting Internet Technology Alex Peeters", Exp_Fault => ">>>NIHIL<<<", Msg => "Consulting Internet Technology Alex Peeters", Msg_Fault => "Consulting Internet Technology Alex Peeters", Perfdata_Label => 'Label 1' },
47 );
48  
49 1 my $returnCode = $objectWebTransact->check ( { } );
50  
51 1 ▶unless ( $returnCode ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($returnCode) 0 1 1
52 3 ▶ use constant EXP_TITLE_1 => "\Q<TITLE>\E(Consulting Internet Technology Alex Peeters)\Q</TITLE>\E";
Subroutine BEGIN: called CC=1 SCAR=0.0
53 3 ▶ use constant EXP_TITLE_2 => "\Q<TITLE>\E(Consulting) (Internet) (Technology) (Alex Peeters)\Q</TITLE>\E";
Subroutine BEGIN: called CC=1 SCAR=0.0
54  
55 3 ▶ use constant EXP_SUBMAIN => "\Q<FRAME NAME=\"NO_INFO\" SRC=\"\E(submain.htm)\Q\" SCROLLING=\"No\" FRAMEBORDER=\"0\" NORESIZE>\E";
Subroutine BEGIN: called CC=1 SCAR=0.0
56 0 ▶ use constant VAL_SUBMAIN => [0, sub { my %pages = ( 'index.htm' => 'InDeX', 'submain.htm' => 'subMAIN' ); $pages { $_[0] }; } ];
Subroutine BEGIN: called CC=1 SCAR=0.6
Subroutine __ANON__: not called CC=1 SCAR=0.6
57 0 ▶ use constant RET_SUBMAIN => [0, sub { my %returns = %{ $objectWebTransact->returns() }; defined $returns { 'submain' } ? $returns { 'submain' } : ''; } ];
Subroutine BEGIN: called CC=1 SCAR=2.2
Subroutine __ANON__: not called CC=2 SCAR=10.9
Branch: 1 branch
BranchTrueFalseTotal
defined $returns{'submain'} ? : 0 0 0
58 0 ▶ use constant RET_TITLE1 => [0, sub { my %returns = %{ $objectWebTransact->returns() }; defined $returns { 'title1' } ? $returns { 'title1' } : ''; } ];
Subroutine BEGIN: called CC=1 SCAR=2.2
Subroutine __ANON__: not called CC=2 SCAR=10.9
Branch: 1 branch
BranchTrueFalseTotal
defined $returns{'title1'} ? : 0 0 0
59  
60 0 @URLS = (
61 { Method => 'GET', Url => 'http://www.citap.com/', Qs_var => [], Qs_fixed => [], Exp => [EXP_SUBMAIN, 'Consulting Internet Technology Alex Peeters'], Exp_Fault => ">>>NIHIL<<<", Msg => "Consulting Internet Technology Alex Peeters", Msg_Fault => "Consulting Internet Technology Alex Peeters", Perfdata_Label => 'Label 2' },
62 { Method => 'GET', Url => 'http://www.citap.com/', Qs_var => [parameter => 0], Qs_fixed => [], Exp => [EXP_SUBMAIN, 'Consulting Internet Technology Alex Peeters'], Exp_Fault => ">>>NIHIL<<<", Exp_Return => { title1 => EXP_TITLE_1 }, Msg => "Consulting Internet Technology Alex Peeters", Msg_Fault => "Consulting Internet Technology Alex Peeters", Perfdata_Label => 'Label 2' },
63 { Method => 'GET', Url => 'http://www.citap.com/', Qs_var => [parameter => VAL_SUBMAIN, submain => RET_SUBMAIN, title1 => RET_TITLE1], Qs_fixed => [], Exp => 'Consulting Internet Technology Alex Peeters', Exp_Fault => ">>>NIHIL<<<", Exp_Return => { title2 => EXP_TITLE_2, submain => EXP_SUBMAIN }, Msg => "Consulting Internet Technology Alex Peeters", Msg_Fault => "Consulting Internet Technology Alex Peeters", Perfdata_Label => 'Label 3' },
64 );
65  
66 0 $returnCode = $objectWebTransact->check ( { }, custom => \&customWebTransact );
67 0 my %returns = %{ $objectWebTransact->returns() };
68 0 $objectPlugins->pluginValues ( { alert => $returns {title1} .' - '. $returns {submain} .' - '. $returns {title2}[0] .' - '. $returns {title2}[1] .' - '. $returns {title2}[2] .' - '. $returns {title2}[3] }, $TYPE{REPLACE} );
69 }
70  
71 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
72 # End plugin - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
73 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
74  
75 1 undef $objectWebTransact;
76 1 $objectPlugins->exit (7);
77  
78 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
79  
80 0 ▶sub customWebTransact {
Subroutine customWebTransact: not called CC=6 SCAR=37.4
81 0 for ( $_[0] ) {
82 /Failure of server APACHE bridge/ &&
83 0 ▶ do { return ( $ERRORS{CRITICAL}, 1, 'Failure of server APACHE bridge' ); last; };
Branch: 1 branch
BranchTrueFalseTotal
/Failure of server APACHE bridge/ and do { return $main::ERRORS{"CRITICAL"}, 1, "Failure of server APACHE bridge"; last } 0 0 0
84 /Message from the NSAPI plugin:/ && /No backend server available for connection:/ &&
85 0 ▶ do { return ( $ERRORS{CRITICAL}, 1, "'KBOWI - Message from the NSAPI plugin - No backend server available for connection'" ); last; };
Branch: 1 branch
BranchTrueFalseTotal
/Message from the NSAPI plugin:/ and /No backend server available for connection:/ and do { return $main::ERRORS{"CRITICAL"}, 1, "'KBOWI - Message from the NSAPI plugin - No backend server available for connection'"; last } 0 0 0
Condition0%0/3
/Message from the NSAPI plugin:/ and /No backend server available for connection:/
!ll&&!rl&&r
000
MC/DC0%0/2
/Message from the NSAPI plugin:/ and /No backend server available for connection:/
/Message from the NSAPI plugin:/ /No backend server available for connection:/
Truth table0%0/3
A and B
A= /Message from the NSAPI plugin:/B= /No backend server available for connection:/
ABresult
0X0
100
111
86 /\Q<FRAME NAME="NO_INFO" SRC="submain.html" SCROLLING="No" FRAMEBORDER="0" NORESIZE>\E/ &&
87 0 ▶ do { return ( $ERRORS{CRITICAL}, 0, '+submain+' ); last; };
Branch: 1 branch
BranchTrueFalseTotal
/\<FRAME\ NAME\=\"NO_INFO\"\ SRC\=\"submain\.html\"\ SCROLLING\=\"No\"\ FRAMEBORDER\=\"0\"\ NORESIZE\>/ and do { return $main::ERRORS{"CRITICAL"}, 0, "+submain+"; last } 0 0 0
88 0 return ( $ERRORS{OK}, 0, undef );
89 }
90 }
91  
92 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
93  
94 __END__
« t/Asnmtap/Plugins/WebTransact.t ↑ Summary blib/lib/ASNMTAP/Asnmtap.pm »