blib/lib/ASNMTAP/Asnmtap/Plugins/SOAP.pm

filter: Statementstmt 61.8% 154 / 249 Branchbran 35.2% 48 / 136 Conditioncond 20.0% 3 / 15 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 87.5% 21 / 24 Podpod 100% 1 / 1 totaltotal 52.1% 227 / 435 CC 77 SCAR 57.9
CC
77
Cov
51%
get_soap_request
540.7
_soapCheckFault
56.0
_soapCheckTransportStatus
23.1
CRAP 325.7
« plugins/templates/check_template-mail-xml.pl ↑ Summary blib/lib/ASNMTAP/Asnmtap/Plugins/Nagios.pm »
1 # ----------------------------------------------------------------------------------------------------------
2 # © Copyright 2000-2011 by Alex Peeters [alex.peeters@citap.be]
3 # ----------------------------------------------------------------------------------------------------------
4 # 2011/mm/dd, v3.002.003, package ASNMTAP::Asnmtap::Plugins::SOAP Object-Oriented Perl
5 # ----------------------------------------------------------------------------------------------------------
6  
7 # Class name - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
8 package ASNMTAP::Asnmtap::Plugins::SOAP;
9  
10 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
11  
12 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use warnings; # Must be used in test mode only. This reduces a little process speed
Subroutine BEGIN: called CC=1 SCAR=0.0
14 #use diagnostics; # Must be used in test mode only. This reduces a lot of process speed
15  
16 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
17  
18 4 ▶use Carp qw(cluck);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
21  
22 4 ▶use ASNMTAP::Asnmtap qw(%ERRORS %TYPE);
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25  
26 4 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
27 4 ▶ use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 4 @ASNMTAP::Asnmtap::Plugins::SOAP::ISA = qw(Exporter ASNMTAP::Asnmtap);
30  
31 4 %ASNMTAP::Asnmtap::Plugins::SOAP::EXPORT_TAGS = ( ALL => [ qw(&get_soap_request) ] );
32  
33 4 @ASNMTAP::Asnmtap::Plugins::SOAP::EXPORT_OK = ( @{ $ASNMTAP::Asnmtap::Plugins::SOAP::EXPORT_TAGS{ALL} } );
34  
35 4 $ASNMTAP::Asnmtap::Plugins::SOAP::VERSION = do { my @r = (q$Revision: 3.002.003$ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r };
36 }
37  
38 # Utility methods - - - - - - - - - - - - - - - - - - - - - - - - - - - -
39  
40 24 ▶sub get_soap_request {
Subroutine get_soap_request: called CC=59 SCAR=62.9
Pod documented
41 24 my %defaults = ( asnmtapInherited => undef,
42 custom => undef,
43 customArguments => undef,
44 proxy => undef,
45 credentials => undef,
46 namespace => undef,
47 registerNamespace => undef,
48 method => undef,
49 soapaction => undef,
50 xmlContent => undef,
51 params => undef,
52 envprefix => 'soapenv',
53 encprefix => 'soapenc',
54 encodingStyle => undef,
55 readable => 1,
56 cookies => undef,
57 perfdataLabel => undef,
58  
59 PATCH_HTTP_KEEPALIVE => 0,
60 WSRF => 0,
61  
62 TYPE_ERROR_RETURN => 'REPLACE'
63 );
64  
65 24 my %parms = (%defaults, @_);
66  
67 24 my $asnmtapInherited = $parms{asnmtapInherited};
68 0 ▶ unless ( defined $asnmtapInherited ) { cluck ( 'ASNMTAP::Asnmtap::Plugins::SOAP: asnmtapInherited missing' ); exit $ERRORS{UNKNOWN} }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $asnmtapInherited) 0 24 24
69  
70 24 ▶ unless ( defined $parms{proxy} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $parms{"proxy"}) 1 23 24
71 1 $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing SOAP parameter proxy' }, $TYPE{APPEND} );
72 1 return ( $ERRORS{UNKNOWN} );
73 }
74  
75 23 my $namespace = $parms{namespace};
76  
77 23 ▶ unless ( defined $namespace ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $namespace) 1 22 23
78 1 $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing SOAP parameter namespace' }, $TYPE{APPEND} );
79 1 return ( $ERRORS{UNKNOWN} );
80 }
81  
82 22 my $registerNamespace = $parms{registerNamespace};
83  
84 22 ▶ if ( defined $registerNamespace ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $registerNamespace) 21 1 22
85 21 ▶ unless ( ref $registerNamespace eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $registerNamespace eq "HASH") 1 20 21
86 1 $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing SOAP parameter registerNamespace' }, $TYPE{APPEND} );
87 1 return ( $ERRORS{UNKNOWN} );
88 }
89 }
90  
91 21 ▶ unless ( defined $parms{method} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $parms{"method"}) 1 20 21
92 1 $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing SOAP parameter method' }, $TYPE{APPEND} );
93 1 return ( $ERRORS{UNKNOWN} );
94 }
95  
96 20 my $soapaction = $parms{soapaction};
97  
98 20 my $xmlContent = $parms{xmlContent};
99  
100 20 my $params = $parms{params};
101  
102 20 my $readable = $parms{readable};
103  
104 20 my $envprefix = $parms{envprefix};
105  
106 20 my $encprefix = $parms{envprefix};
107  
108 20 my $encodingStyle = $parms{encodingStyle};
109  
110 20 ▶ unless ( $readable =~ /^[01]$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($readable =~ /^[01]$/) 1 19 20
111 1 $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'SOAP parameter readable must be 0 or 1' }, $TYPE{APPEND} );
112 1 return ( $ERRORS{UNKNOWN} );
113 }
114  
115 19 my $cookies = $parms{cookies};
116  
117 19 ▶ unless ( $cookies =~ /^[01]$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cookies =~ /^[01]$/) 1 18 19
118 1 $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'SOAP parameter cookies must be 0 or 1' }, $TYPE{APPEND} );
119 1 return ( $ERRORS{UNKNOWN} );
120 }
121  
122 18 ▶ unless ( defined $parms{perfdataLabel} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $parms{"perfdataLabel"}) 1 17 18
123 1 $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing SOAP parameter perfdataLabel' }, $TYPE{APPEND} );
124 1 return ( $ERRORS{UNKNOWN} );
125 }
126  
127 17 my $PATCH_HTTP_KEEPALIVE = $parms{PATCH_HTTP_KEEPALIVE};
128  
129 17 ▶ unless ( $PATCH_HTTP_KEEPALIVE =~ /^[01]$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($PATCH_HTTP_KEEPALIVE =~ /^[01]$/) 1 16 17
130 1 $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'SOAP parameter PATCH_HTTP_KEEPALIVE must be 0 or 1' }, $TYPE{APPEND} );
131 1 return ( $ERRORS{UNKNOWN} );
132 }
133  
134 16 my $WSRF = $parms{WSRF};
135  
136 16 ▶ unless ( $WSRF =~ /^[01]$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($WSRF =~ /^[01]$/) 1 15 16
137 1 $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'SOAP parameter WSRF must be 0 or 1' }, $TYPE{APPEND} );
138 1 return ( $ERRORS{UNKNOWN} );
139 }
140  
141 15 my $TYPE_ERROR_RETURN = $parms{TYPE_ERROR_RETURN};
142  
143 15 ▶ unless ( $TYPE_ERROR_RETURN =~ /^(?:REPLACE|APPEND|INSERT|COMMA_APPEND|COMMA_INSERT)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($TYPE_ERROR_RETURN =~ /^(?:REPLACE|APPEND|INSERT|COMMA_APPEND|COMMA_INSERT)$/) 1 14 15
144 1 $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'SOAP parameter TYPE_ERROR_RETURN must be [REPLACE|APPEND|INSERT|COMMA_APPEND|COMMA_INSERT]' }, $TYPE{APPEND} );
145 1 return ( $ERRORS{UNKNOWN} );
146 }
147  
148 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
149  
150 14 my $browseragent = $$asnmtapInherited->browseragent ();
151 14 my $timeout = $$asnmtapInherited->timeout ();
152  
153 14 my $proxySettings = $$asnmtapInherited->getOptionsArgv ( 'proxy' );
154  
155 14 my $debug = $$asnmtapInherited->getOptionsValue ( 'debug' );
156  
157 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
158  
159 14 ▶ sub _soapCheckTransportStatus {
Subroutine _soapCheckTransportStatus: called CC=9 SCAR=31.4
160 14 my ($asnmtapInherited, $service, $TYPE_ERROR_RETURN, $debug) = @_;
161  
162 14 my $transportStatus = $service->transport->status;
163 14 ▶ print "ASNMTAP::Asnmtap::Plugins::SOAP::_soapCheckTransportStatus: $transportStatus\n" if ($debug);
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 14 14
164  
165 14 ▶ if ( $service->transport->is_success ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($service->transport->is_success) 0 14 14
166 0 $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{OK}, alert => $transportStatus }, $TYPE{APPEND} );
167 0 return $ERRORS{OK};
168 };
169  
170 14 for ( $transportStatus ) {
171 /500 Can_t connect to/ &&
172 0 ▶ do { $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => $transportStatus }, $TYPE{$TYPE_ERROR_RETURN} ); return $ERRORS{UNKNOWN}; last; };
Branch: 1 branch
BranchTrueFalseTotal
/500 Can_t connect to/ and do { $$asnmtapInherited->pluginValues({"stateValue", $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"UNKNOWN"}, "error", $transportStatus}, $ASNMTAP::Asnmtap::Plugins::SOAP::TYPE{$TYPE_ERROR_RETURN}); return $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"UNKNOWN"}; last } 0 14 14
173 /500 configure certs failed/ &&
174 0 ▶ do { $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => $transportStatus }, $TYPE{$TYPE_ERROR_RETURN} ); return $ERRORS{UNKNOWN}; last; };
Branch: 1 branch
BranchTrueFalseTotal
/500 configure certs failed/ and do { $$asnmtapInherited->pluginValues({"stateValue", $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"UNKNOWN"}, "error", $transportStatus}, $ASNMTAP::Asnmtap::Plugins::SOAP::TYPE{$TYPE_ERROR_RETURN}); return $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"UNKNOWN"}; last } 0 14 14
175 /500 Connect failed/ &&
176 0 ▶ do { $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => $transportStatus }, $TYPE{$TYPE_ERROR_RETURN} ); return $ERRORS{UNKNOWN}; last; };
Branch: 1 branch
BranchTrueFalseTotal
/500 Connect failed/ and do { $$asnmtapInherited->pluginValues({"stateValue", $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"UNKNOWN"}, "error", $transportStatus}, $ASNMTAP::Asnmtap::Plugins::SOAP::TYPE{$TYPE_ERROR_RETURN}); return $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"UNKNOWN"}; last } 0 14 14
177 /500 proxy connect failed/ &&
178 0 ▶ do { $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => $transportStatus }, $TYPE{$TYPE_ERROR_RETURN} ); return $ERRORS{UNKNOWN}; last; };
Branch: 1 branch
BranchTrueFalseTotal
/500 proxy connect failed/ and do { $$asnmtapInherited->pluginValues({"stateValue", $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"UNKNOWN"}, "error", $transportStatus}, $ASNMTAP::Asnmtap::Plugins::SOAP::TYPE{$TYPE_ERROR_RETURN}); return $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"UNKNOWN"}; last } 0 14 14
179 /500 Internal Server Error/ &&
180 0 ▶ do { $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => $transportStatus }, $TYPE{$TYPE_ERROR_RETURN} ); return $ERRORS{UNKNOWN}; last; };
Branch: 1 branch
BranchTrueFalseTotal
/500 Internal Server Error/ and do { $$asnmtapInherited->pluginValues({"stateValue", $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"UNKNOWN"}, "error", $transportStatus}, $ASNMTAP::Asnmtap::Plugins::SOAP::TYPE{$TYPE_ERROR_RETURN}); return $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"UNKNOWN"}; last } 0 14 14
181 }
182  
183 14 $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{CRITICAL}, alert => $transportStatus }, $TYPE{$TYPE_ERROR_RETURN} );
184 14 return $ERRORS{CRITICAL};
185 }
186  
187 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
188  
189 0 ▶ sub _soapCheckFault {
Subroutine _soapCheckFault: not called CC=7 SCAR=40.3
190 0 my ($asnmtapInherited, $som, $debug) = @_;
191  
192 0 my $faultcode = $som->faultcode; $faultcode =~ s/^\s+//g; $faultcode =~ s/\s+$//g;
193 0 my $faultdetail = $som->faultdetail;
194 0 my $faultstring = $som->faultstring;
195 0 my $faultactor = $som->faultactor;
196  
197 0 ▶ if ( $debug ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug) 0 0 0
198 0 ▶ print "ASNMTAP::Asnmtap::Plugins::SOAP::_soapCheckFault->faultcode : ", $faultcode, "\n" if (defined $faultcode);
Branch: 1 branch
BranchTrueFalseTotal
if defined $faultcode 0 0 0
199 0 ▶ print "ASNMTAP::Asnmtap::Plugins::SOAP::_soapCheckFault->faultdetail : ", $faultdetail, "\n" if (defined $faultdetail);
Branch: 1 branch
BranchTrueFalseTotal
if defined $faultdetail 0 0 0
200 0 ▶ print "ASNMTAP::Asnmtap::Plugins::SOAP::_soapCheckFault->faultstring : ", $faultstring, "\n" if (defined $faultstring);
Branch: 1 branch
BranchTrueFalseTotal
if defined $faultstring 0 0 0
201 0 ▶ print "ASNMTAP::Asnmtap::Plugins::SOAP::_soapCheckFault->faultactor : ", $faultactor, "\n" if (defined $faultactor);
Branch: 1 branch
BranchTrueFalseTotal
if defined $faultactor 0 0 0
202 }
203  
204 0 ▶ $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => $faultcode. ( defined $faultstring ? ' - ' .$faultstring : '' ) }, $TYPE{APPEND} );
Branch: 1 branch
BranchTrueFalseTotal
defined $faultstring ? : 0 0 0
205 0 return $ERRORS{UNKNOWN};
206 }
207  
208 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
209  
210 14 my ($service, $alert, $error, $result);
211  
212 14 ▶ if ( $WSRF ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($WSRF) { } 0 14 14
213 0 ▶ if ( $debug >= 4 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($debug >= 4) { } 0 0 0
elsif ($debug == 1) { } 0 0 0
214 0 eval "use WSRF::Lite +trace => 'all'";
215 } elsif ($debug == 1) {
216 0 eval "use WSRF::Lite +trace => qw( debug )";
217 } else {
218 0 eval "use WSRF::Lite";
219 }
220  
221 $service = new WSRF::Lite
222 -> wsaddress ( WSRF::WS_Address->new()->Address( $parms{proxy} ) )
223 -> autotype ( 1 )
224 -> readable ( $readable )
225 -> envprefix ( $envprefix )
226 -> encprefix ( $encprefix )
227 -> xmlschema ( 'http://www.w3.org/2001/XMLSchema' )
228 -> uri ( $namespace )
229 0 ▶ -> on_action ( sub { my $uri = $_[0]; $uri =~ s/\/$//; my $method = (defined $soapaction ? ( $soapaction eq '' ? '' : $soapaction ) : $uri .'/'. $_[1]) } )
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 2 branches
BranchTrueFalseTotal
defined $soapaction ? : 0 0 0
$soapaction eq '' ? : 0 0 0
230 0 ▶ -> on_fault ( sub { } )
Subroutine __ANON__: not called CC=1 SCAR=0.0
231 0 ;
232 } else {
233 14 ▶ if ( $debug >= 4 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($debug >= 4) { } 0 14 14
elsif ($debug == 1) { } 0 14 14
234 0 eval "use SOAP::Lite +trace => 'all'";
235 } elsif ($debug == 1) {
236 0 eval "use SOAP::Lite +trace => qw( debug )";
237 } else {
238 2 ▶ eval "use SOAP::Lite";
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
239 }
240  
241 $service = new SOAP::Lite
242 -> autotype ( 1 )
243 -> readable ( $readable )
244 -> envprefix ( $envprefix )
245 -> encprefix ( $encprefix )
246 -> xmlschema ( 'http://www.w3.org/2001/XMLSchema' )
247 -> uri ( $namespace )
248 14 ▶ -> on_action ( sub { my $uri = $_[0]; $uri =~ s/\/$//; my $method = (defined $soapaction ? ( $soapaction eq '' ? '' : $soapaction ) : $uri .'/'. $_[1]) } )
Subroutine __ANON__: called CC=3 SCAR=13.1
Branch: 2 branches
BranchTrueFalseTotal
defined $soapaction ? : 0 14 14
$soapaction eq '' ? : 0 0 0
249 14 ▶ -> on_fault ( sub { } )
Subroutine __ANON__: called CC=1 SCAR=0.0
250 14 ;
251 }
252  
253 14 ▶ $service->serializer->encodingStyle ( $encodingStyle ) if ( defined $encodingStyle );
Branch: 1 branch
BranchTrueFalseTotal
if defined $encodingStyle 0 14 14
254 14 $SOAP::Constants::PATCH_HTTP_KEEPALIVE = $PATCH_HTTP_KEEPALIVE;
255  
256 14 ▶ if ( defined $parms{registerNamespace} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parms{"registerNamespace"}) 14 0 14
257 14 ▶ while ( my ($key, $value) = each( %{ $parms{registerNamespace} } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$parms{"registerNamespace"};}) 28 14 42
258 28 $service->serializer->register_ns($key, $value);
259 }
260 }
261  
262 14 ▶ if ( defined $proxySettings ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proxySettings) { } 0 14 14
263 0 $service->proxy ( $parms{proxy}, timeout => $timeout, proxy => ['http' => "http://$proxySettings"] );
264 } else {
265 14 $service->proxy ( $parms{proxy}, timeout => $timeout );
266 }
267  
268 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
269  
270 0 ▶ $service->transport->credentials( @{$parms{credentials}} ) if ( defined $parms{credentials} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $parms{"credentials"} 0 14 14
271  
272 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
273 # $service->proxy ( 'https://USERNAME:PASSWORD@secure.citap.be/authorization/hibye.cgi' );
274 # or
275 # $service->proxy ( 'https://secure.citap.be/authorization/hibye.cgi', credentials => [ 'secure.citap.be:443', "ASNMTAP's Authorization Access", 'USERNAME' => 'PASSWORD' ], timeout => $timeout );
276 # or
277 # $service->transport->credentials( 'secure.citap.be:443', "ASNMTAP's Authorization Access", 'USERNAME' => 'PASSWORD' );
278 # or
279 # use MIME::Base64;
280 # $service->transport->http_request->header( 'Authorization' => 'Basic '. MIME::Base64::encode ( 'USERNAME' .':'. 'PASSWORD', '' ) );
281 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
282  
283 14 $service->transport->agent( $browseragent );
284 14 $service->transport->timeout( $timeout );
285  
286 4 ▶ use HTTP::Cookies;
Subroutine BEGIN: called CC=1 SCAR=0.0
287 14 ▶ $service->transport->cookie_jar( HTTP::Cookies->new ) if ( $cookies );
Branch: 1 branch
BranchTrueFalseTotal
if $cookies 14 0 14
288  
289 14 $service->transport->default_headers->push_header( 'Accept-Language' => "no, en" );
290 14 $service->transport->default_headers->push_header( 'Accept-Charset' => "iso-8859-1,*,utf-8" );
291 14 $service->transport->default_headers->push_header( 'Accept-Encoding' => "gzip, deflate" );
292
293 14 ▶ print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: () -->\n" if ( $debug );
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 14 14
294 14 $$asnmtapInherited->setEndTime_and_getResponsTime ( $$asnmtapInherited->pluginValue ('endTime') );
295  
296 14 ▶ my $som = (defined $params and $params ne '') ? (ref $params eq 'ARRAY' ? $service->call( $parms{method} => @$params ) : $service->call( $parms{method} => $params )) : $service->call( $parms{method} );
Branch: 2 branches
BranchTrueFalseTotal
defined $params && $params ne '' ? : 0 14 14
ref $params eq 'ARRAY' ? : 0 0 0
Condition33%1/3
defined $params and $params ne ""
!ll&&!rl&&r
1400
MC/DC0%0/2
defined $params and $params ne ""
defined $params $params ne ""
Truth table33%1/3
A and B
A= defined $paramsB= $params ne ""
ABresult
0X0
100
111
297  
298 14 my $responseTime = $$asnmtapInherited->setEndTime_and_getResponsTime ( $$asnmtapInherited->pluginValue ('endTime') );
299 14 $$asnmtapInherited->appendPerformanceData ( "'". $parms{perfdataLabel} ."'=". $responseTime ."ms;;;;" );
300 14 ▶ print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: () <->\n" if ( $debug );
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 14 14
301  
302 14 my $returnCode = _soapCheckTransportStatus ($asnmtapInherited, $service, $TYPE_ERROR_RETURN, $debug);
303  
304 14 ▶ unless ( $returnCode ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($returnCode) { } 14 0 14
305 0 ▶ unless ( defined $som and defined $som->fault ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $som and defined $som->fault) { } 0 0 0
Condition0%0/3
defined $som and defined $som->fault
!ll&&!rl&&r
000
MC/DC0%0/2
defined $som and defined $som->fault
defined $som defined $som->fault
Truth table0%0/3
A and B
A= defined $somB= defined $som->fault
ABresult
0X0
100
111
306 0 ▶ $result = UNIVERSAL::isa($som => ($WSRF ? 'WSRF::SOM' : 'SOAP::SOM')) ? (wantarray ? $som->paramsall : $som->result) : $som;
Branch: 3 branches
BranchTrueFalseTotal
UNIVERSAL::isa($som, $WSRF ? 'WSRF::SOM' : 'SOAP::SOM') ? : 0 0 0
$WSRF ? : 0 0 0
wantarray ? : 0 0 0
307  
308 0 ▶ if ( $debug ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug) 0 0 0
309 0 for ( ref $result ) {
310 /^REF$/ &&
311 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
/^REF$/ and do { foreach $_ (ref $$result) { /^ARRAY$/ and do { print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: REF ARRAY: @$$result\n"; last }; /^HASH$/ and do { print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: REF HASH: "; while (() = each %{$$result;}) { do { print "$key => $value " }; } ; print "\n"; last }; } ; last } 0 0 0
312 0 for ( ref $$result ) {
313 /^ARRAY$/ &&
314 0 ▶ do { print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: REF ARRAY: @$$result\n"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/^ARRAY$/ and do { print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: REF ARRAY: @$$result\n"; last } 0 0 0
315 /^HASH$/ &&
316 0 ▶ do { print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: REF HASH: "; while (my ($key, $value) = each %{ $$result } ) { print "$key => $value "; }; print "\n"; last; };
Branch: 2 branches
BranchTrueFalseTotal
/^HASH$/ and do { print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: REF HASH: "; while (() = each %{$$result;}) { do { print "$key => $value " }; } ; print "\n"; last } 0 0 0
if (() = each %{$$result;}) 0 0 0
317 }
318  
319 0 last;
320 };
321 /^ARRAY$/ &&
322 0 ▶ do { print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: ARRAY: @$result\n"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/^ARRAY$/ and do { print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: ARRAY: @$result\n"; last } 0 0 0
323 /^HASH$/ &&
324 0 ▶ do { print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: HASH: "; while (my ($key, $value) = each %{ $result } ) { print "$key => $value "; }; print "\n"; last; };
Branch: 2 branches
BranchTrueFalseTotal
/^HASH$/ and do { print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: HASH: "; while (() = each %{$result;}) { do { print "$key => $value " }; } ; print "\n"; last } 0 0 0
if (() = each %{$result;}) 0 0 0
325 /^SCALAR$/ &&
326 0 ▶ do { print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: REF SCALAR: ", $$result, "\n"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/^SCALAR$/ and do { print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: REF SCALAR: ", $$result, "\n"; last } 0 0 0
327 0 print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: SCALAR: ", $result, "\n";
328 }
329 }
330  
331 0 ▶ if ( $returnCode == $ERRORS{OK} and defined $parms{custom} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($returnCode == $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"OK"} and defined $parms{"custom"}) 0 0 0
Condition0%0/3
$returnCode == $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"OK"} and defined $parms{"custom"}
!ll&&!rl&&r
000
MC/DC0%0/2
$returnCode == $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"OK"} and defined $parms{"custom"}
$returnCode == $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"OK"} defined $parms{"custom"}
Truth table0%0/3
A and B
A= $returnCode == $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"OK"}B= defined $parms{"custom"}
ABresult
0X0
100
111
332 0 my $root = $som->dataof ('/Envelope/Body');
333  
334 0 ▶ if ( defined $root ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $root) { } 0 0 0
335 0 ▶ $returnCode = ( defined $parms{customArguments} ) ? $parms{custom}->($$asnmtapInherited, $som, $parms{customArguments}) : $parms{custom}->($$asnmtapInherited, $som);
Branch: 1 branch
BranchTrueFalseTotal
defined $parms{'customArguments'} ? : 0 0 0
336 } else {
337 0 ▶ print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: Missing SOAP Envelope or Body", "\n" if ( $debug );
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
338 0 $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing SOAP Envelope or Body' }, $TYPE{APPEND} );
339 0 return ($returnCode, undef);
340 }
341 }
342 } else {
343 0 $returnCode = _soapCheckFault ($asnmtapInherited, $som, $debug);
344 }
345 } else {
346 14 ▶ $returnCode = _soapCheckFault ($asnmtapInherited, $som, $debug) if ( defined $som and defined $som->fault );
Branch: 1 branch
BranchTrueFalseTotal
if defined $som and defined $som->fault 0 14 14
Condition33%1/3
defined $som and defined $som->fault
!ll&&!rl&&r
1400
MC/DC0%0/2
defined $som and defined $som->fault
defined $som defined $som->fault
Truth table33%1/3
A and B
A= defined $somB= defined $som->fault
ABresult
0X0
100
111
347 }
348  
349 14 ▶ print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: () <--\n" if ( $debug );
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 14 14
350 14 ▶ return ($returnCode, undef) unless ( $returnCode == $ERRORS{OK} and defined $xmlContent );
Branch: 1 branch
BranchTrueFalseTotal
unless $returnCode == $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"OK"} and defined $xmlContent 14 0 14
Condition33%1/3
$returnCode == $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"OK"} and defined $xmlContent
!ll&&!rl&&r
1400
MC/DC0%0/2
$returnCode == $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"OK"} and defined $xmlContent
$returnCode == $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"OK"} defined $xmlContent
Truth table33%1/3
A and B
A= $returnCode == $ASNMTAP::Asnmtap::Plugins::SOAP::ERRORS{"OK"}B= defined $xmlContent
ABresult
0X0
100
111
351  
352 4 ▶ use XML::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
353 0 my $xml = XMLin($result);
354  
355 0 ▶ unless ( defined $xml ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $xml) 0 0 0
356 0 ▶ print "ASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: Error parsing XML formatted data", "\n" if ( $debug );
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
357 0 $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{CRITICAL}, error => 'Error parsing XML formatted data' }, $TYPE{APPEND} );
358 0 return ($returnCode, undef);
359 }
360  
361 0 ▶ if ( $debug >= 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug >= 2) 0 0 0
362 0 print "\nASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: Start XML dump\n";
363 4 ▶ use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
364 0 print Dumper($xml);
365 0 print "\nASNMTAP::Asnmtap::Plugins::SOAP::get_soap_request: End XML dump\n";
366 }
367  
368 0 $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{OK}, alert => 'SOAP OK' }, $TYPE{APPEND} );
369 0 return ($returnCode, $xml);
370 }
371  
372 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
373  
374 4 1;
375  
376 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
377  
378 __END__
« plugins/templates/check_template-mail-xml.pl ↑ Summary blib/lib/ASNMTAP/Asnmtap/Plugins/Nagios.pm »