plugins/templates/check_template-WebTransact-XML-Monitoring-1.1.pl

filter: Statementstmt 24.2% 33 / 136 Branchbran 1.0% 1 / 96 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 91.6% 11 / 12 Podpod n/a totaltotal 16.4% 45 / 273 CC 24 SCAR 58.9
CC
24
Cov
14%
validateResultOrSubResult
552.0
BEGIN
2.5
BEGIN
1.0
CRAP 363.2
« plugins/templates/check_template-WebTransact-XML-Monitoring-1.2.pl ↑ Summary plugins/templates/check_template-mail-xml-fingerprint-xml-monitoring.pl »
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-XML-Monitoring-1.1.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 Date::Calc qw(check_date check_time);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 3 ▶use Time::Local;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
22  
23 3 ▶use ASNMTAP::Asnmtap::Plugins v3.002.003;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 3 ▶use ASNMTAP::Asnmtap::Plugins qw(:PLUGINS);
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
27  
28 3 my $schema = "1.1";
29  
30 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
31  
32 3 my $objectPlugins = ASNMTAP::Asnmtap::Plugins->new (
33 _programName => 'check_template-WebTransact-XML-Monitoring-1.1.pl',
34 _programDescription => "WebTransact XML Monitoring plugin template for testing the '$APPLICATION'",
35 _programVersion => '3.002.003',
36 _programUsagePrefix => '--message=<message> [-H|--hostname <hostname> -s|--service <service>]|[--uKey <uKey>] [--validation <validation>]',
37 _programHelpPrefix => "--message=<message>
38 --message=message
39 -H, --hostname=<Nagios Hostname>
40 -s, --service=<Nagios service name>
41 --uKey=<uKey>
42 --validation=F|T
43 F(alse) : dtd validation off (default)
44 T(true) : dtd validation on",
45 _programGetOptions => ['message=s', 'url|U=s', 'hostname|H:s', 'service|s:s', 'uKey:s', 'validation:s', 'interval|i=i', 'proxy:s', 'environment|e=s', 'trendline|T:i'],
46 _timeout => 30,
47 _debug => 0);
48  
49 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
50  
51 0 my $url = $objectPlugins->getOptionsArgv ('url');
52  
53 0 my $message = $objectPlugins->getOptionsArgv ('message');
54 0 ▶$objectPlugins->printUsage ('Missing command line argument message') unless (defined $message);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $message 0 0 0
55 0 $objectPlugins->pluginValue ( message => $message );
56  
57 0 my ($uKey, $hostname, $service);
58 0 ▶$uKey = $objectPlugins->getOptionsArgv ('uKey') ? $objectPlugins->getOptionsArgv ('uKey') : undef;
Branch: 1 branch
BranchTrueFalseTotal
$objectPlugins->getOptionsArgv('uKey') ? : 0 0 0
59  
60 0 ▶unless ( defined $uKey ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $uKey) 0 0 0
61 0 ▶ $hostname = $objectPlugins->getOptionsArgv ('hostname') ? $objectPlugins->getOptionsArgv ('hostname') : undef;
Branch: 1 branch
BranchTrueFalseTotal
$objectPlugins->getOptionsArgv('hostname') ? : 0 0 0
62 0 ▶ $objectPlugins->printUsage ('Missing command line argument uKey or hostname') unless (defined $hostname);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $hostname 0 0 0
63  
64 0 ▶ $service = $objectPlugins->getOptionsArgv ('service') ? $objectPlugins->getOptionsArgv ('service') : undef;
Branch: 1 branch
BranchTrueFalseTotal
$objectPlugins->getOptionsArgv('service') ? : 0 0 0
65 0 ▶ $objectPlugins->printUsage ('Missing command line argument service') unless ( defined $service);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $service 0 0 0
66 }
67  
68 0 ▶my $validateDTD = $objectPlugins->getOptionsArgv ('validation') ? $objectPlugins->getOptionsArgv ('validation') : 'F';
Branch: 1 branch
BranchTrueFalseTotal
$objectPlugins->getOptionsArgv('validation') ? : 0 0 0
69  
70 0 ▶if (defined $validateDTD) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $validateDTD) 0 0 0
71 0 ▶ $objectPlugins->printUsage ('Invalid validation option: '. $validateDTD) unless ($validateDTD =~ /^[FT]$/);
Branch: 1 branch
BranchTrueFalseTotal
unless $validateDTD =~ /^[FT]$/ 0 0 0
72 0 ▶ $validateDTD = ($validateDTD eq 'T') ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$validateDTD eq 'T' ? : 0 0 0
73 }
74  
75 0 my $resultOutOfDate = $objectPlugins->getOptionsArgv ('interval');
76  
77 0 ▶my $environment = $objectPlugins->getOptionsArgv ('environment') ? $objectPlugins->getOptionsArgv ('environment') : 'P';
Branch: 1 branch
BranchTrueFalseTotal
$objectPlugins->getOptionsArgv('environment') ? : 0 0 0
78 0 my $environmentText = $objectPlugins->getOptionsValue ('environment');
79  
80 0 my $debug = $objectPlugins->getOptionsValue ('debug');
81  
82 0 my $reverse = 0;
83  
84 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
85  
86 3 ▶use ASNMTAP::Asnmtap::Plugins::WebTransact;
Subroutine BEGIN: called CC=1 SCAR=0.0
87 3 ▶use ASNMTAP::Asnmtap::Plugins::XML qw(&extract_XML);
Subroutine BEGIN: called CC=1 SCAR=0.0
88  
89 3 ▶use constant HEADER => '<?xml version="1.0" encoding="UTF-8"?>';
Subroutine BEGIN: called CC=1 SCAR=0.0
90 3 ▶use constant FOOTER => '</MonitoringXML>';
Subroutine BEGIN: called CC=1 SCAR=0.0
91  
92 0 my @URLS = ();
93 0 my $objectWebTransact = ASNMTAP::Asnmtap::Plugins::WebTransact->new ( \$objectPlugins, \@URLS );
94  
95 0 my ($returnCode, $result, $xml, $debugfileMessage);
96  
97 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
98  
99 0 @URLS = (
100 { Method => 'GET', Url => $url, Qs_var => [], Qs_fixed => [], Exp => "\Q<MonitoringXML>\E", Exp_Fault => ">>>NIHIL<<<", Msg => "XML", Msg_Fault => "XML" },
101 );
102  
103 0 $returnCode = $objectWebTransact->check ( { } );
104 0 undef $objectWebTransact;
105 0 ▶$objectPlugins->exit (7) if ( $returnCode );
Branch: 1 branch
BranchTrueFalseTotal
if $returnCode 0 0 0
106  
107 0 $result = $objectPlugins->pluginValue ('result');
108 0 ($returnCode, $xml) = extract_XML ( asnmtapInherited => \$objectPlugins, resultXML => $result, headerXML => HEADER, footerXML => FOOTER, validateDTD => $validateDTD, filenameDTD => "dtd/Monitoring-$schema.dtd" );
109 0 ▶$objectPlugins->exit (3) if ( $returnCode );
Branch: 1 branch
BranchTrueFalseTotal
if $returnCode 0 0 0
110  
111 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
112  
113 0 my $currentTimeslot = timelocal ((localtime)[0,1,2,3,4,5]);
114 0 my %environment = ( P => 'PROD', S => 'SIM', A => 'ACC', T => 'TEST', D => 'DEV', L => 'LOCAL' );
115  
116 0 my $match = 0;
117  
118 0 ▶if ( defined $xml->{Monitoring}{Results}{Extension}{Element}{eName} and $xml->{Monitoring}{Results}{Extension}{Element}{eName} eq 'uKey') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xml->{'Monitoring'}{'Results'}{'Extension'}{'Element'}{'eName'} and $xml->{'Monitoring'}{'Results'}{'Extension'}{'Element'}{'eName'} eq 'uKey') { } 0 0 0
Condition0%0/3
defined $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eName"} and $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eName"} eq "uKey"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eName"} and $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eName"} eq "uKey"
defined $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eName"} $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eName"} eq "uKey"
Truth table0%0/3
A and B
A= defined $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eName"}B= $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eName"} eq "uKey"
ABresult
0X0
100
111
119 0 ▶ $match = 1 if ( defined $xml->{Monitoring}{Results}{Extension}{Element}{eValue} and $xml->{Monitoring}{Results}{Extension}{Element}{eValue} eq $uKey );
Branch: 1 branch
BranchTrueFalseTotal
if defined $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eValue"} and $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eValue"} eq $uKey 0 0 0
Condition0%0/3
defined $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eValue"} and $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eValue"} eq $uKey
!ll&&!rl&&r
000
MC/DC0%0/2
defined $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eValue"} and $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eValue"} eq $uKey
defined $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eValue"} $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eValue"} eq $uKey
Truth table0%0/3
A and B
A= defined $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eValue"}B= $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eValue"} eq $uKey
ABresult
0X0
100
111
120 } else {
121 0 ▶ $match = 1 if ( $xml->{Monitoring}{Results}{Details}{Host} eq $hostname and $xml->{Monitoring}{Results}{Details}{Service} eq $service );
Branch: 1 branch
BranchTrueFalseTotal
if $xml->{"Monitoring"}{"Results"}{"Details"}{"Host"} eq $hostname and $xml->{"Monitoring"}{"Results"}{"Details"}{"Service"} eq $service 0 0 0
Condition0%0/3
$xml->{"Monitoring"}{"Results"}{"Details"}{"Host"} eq $hostname and $xml->{"Monitoring"}{"Results"}{"Details"}{"Service"} eq $service
!ll&&!rl&&r
000
MC/DC0%0/2
$xml->{"Monitoring"}{"Results"}{"Details"}{"Host"} eq $hostname and $xml->{"Monitoring"}{"Results"}{"Details"}{"Service"} eq $service
$xml->{"Monitoring"}{"Results"}{"Details"}{"Host"} eq $hostname $xml->{"Monitoring"}{"Results"}{"Details"}{"Service"} eq $service
Truth table0%0/3
A and B
A= $xml->{"Monitoring"}{"Results"}{"Details"}{"Host"} eq $hostnameB= $xml->{"Monitoring"}{"Results"}{"Details"}{"Service"} eq $service
ABresult
0X0
100
111
122 }
123  
124 0 ▶if ($match and $xml->{Monitoring}{Schema}{Value} eq $schema and $xml->{Monitoring}{Results}{Details}{Environment} =~ /^$environment{$environment}$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($match and $xml->{'Monitoring'}{'Schema'}{'Value'} eq $schema and $xml->{'Monitoring'}{'Results'}{'Details'}{'Environment'} =~ /^$environment{$environment}$/i) { } 0 0 0
Condition0%0/6
$match and $xml->{"Monitoring"}{"Schema"}{"Value"} eq $schema and $xml->{"Monitoring"}{"Results"}{"Details"}{"Environment"} =~ /^$environment{$environment}$/i
!ll&&!rl&&r
000
$match and $xml->{"Monitoring"}{"Schema"}{"Value"} eq $schema
!ll&&!rl&&r
000
MC/DC0%0/3
$match and $xml->{"Monitoring"}{"Schema"}{"Value"} eq $schema and $xml->{"Monitoring"}{"Results"}{"Details"}{"Environment"} =~ /^$environment{$environment}$/i
$match $xml->{"Monitoring"}{"Schema"}{"Value"} eq $schema $xml->{"Monitoring"}{"Results"}{"Details"}{"Environment"} =~ /^$environment{$environment}$/i
Truth table0%0/4
A and B and C
A= $matchB= $xml->{"Monitoring"}{"Schema"}{"Value"} eq $schemaC= $xml->{"Monitoring"}{"Results"}{"Details"}{"Environment"} =~ /^$environment{$environment}$/i
ABCresult
0XX0
10X0
1100
1111
125 0 $debugfileMessage = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n<HTML><HEAD><TITLE>$message \@ $APPLICATION</TITLE><style type=\"text/css\">\n.statusOdd { font-family: arial,serif; font-size: 10pt; background-color: #DBDBDB; }\n.statusEven { font-family: arial,serif; font-size: 10pt; background-color: #C4C2C2; }\ntd.statusOK { font-family: arial,serif; font-size: 10pt; background-color: #33FF00; }\ntd.statusWARNING { font-family: arial,serif; font-size: 10pt; background-color: #FFFF00; }\ntd.statusCRITICAL { font-family: arial,serif; font-size: 10pt; background-color: #F83838; }\ntd.statusUNKNOWN { font-family: arial,serif; font-size: 10pt; background-color: #FFFFFF; }\n</style>\n</HEAD><BODY><HR><H1 style=\"margin: 0px 0px 5px; font: 125% verdana,arial,helvetica\">$message @ $APPLICATION</H1><HR>\n";
126 0 $debugfileMessage .= "\n<TABLE WIDTH=\"100%\"><TR><TD>\n<H3 style=\"margin-bottom: 0.5em; font: bold 90% verdana,arial,helvetica\">Environment: $environmentText</H3></TD></TR></TABLE>\n";
127 0 $debugfileMessage .= "\n<TABLE WIDTH=\"100%\">";
128 0 validateResultOrSubResult ( \$xml->{Monitoring}{Results}, 0, $reverse, $debug );
129  
130 0 ▶ if ( defined $xml->{Monitoring}{Results}{SubResults} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xml->{"Monitoring"}{"Results"}{"SubResults"}) 0 0 0
131 0 ▶ if ( ref $xml->{Monitoring}{Results}{SubResults} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $xml->{'Monitoring'}{'Results'}{'SubResults'} eq 'ARRAY') { } 0 0 0
132 0 foreach my $subResults (@{$xml->{Monitoring}{Results}{SubResults}}) {
133 0 validateResultOrSubResult ( \$subResults, 1, $reverse, $debug );
134 }
135 } else {
136 0 validateResultOrSubResult ( \$xml->{Monitoring}{Results}{SubResults}, 1, $reverse, $debug );
137 }
138 }
139  
140 0 $debugfileMessage .= "</TABLE>\n";
141 0 $debugfileMessage .= "<P style=\"font: normal 68% verdana,arial,helvetica;\" ALIGN=\"left\">Generated on: " .scalar(localtime()). "</P>\n</BODY>\n</HTML>";
142 0 $objectPlugins->write_debugfile ( \$debugfileMessage, 0 );
143 } else {
144 0 my $tError = 'Content Error:';
145 0 ▶ $tError .= ' - Schema: '. $xml->{Monitoring}{Schema}{Value} ." ne $schema" if ($xml->{Monitoring}{Schema}{Value} ne $schema);
Branch: 1 branch
BranchTrueFalseTotal
if $xml->{"Monitoring"}{"Schema"}{"Value"} ne $schema 0 0 0
146  
147 0 ▶ if ( $xml->{Monitoring}{Results}{Extension}{Element}{eName} eq 'uKey') {
Branch: 1 branch
BranchTrueFalseTotal
if ($xml->{'Monitoring'}{'Results'}{'Extension'}{'Element'}{'eName'} eq 'uKey') { } 0 0 0
148 0 ▶ $tError .= ' - uKey: '. $xml->{Monitoring}{Results}{Extension}{Element}{eValue} ." ne $uKey" if ($xml->{Monitoring}{Results}{Extension}{Element}{eValue} ne $uKey);
Branch: 1 branch
BranchTrueFalseTotal
if $xml->{"Monitoring"}{"Results"}{"Extension"}{"Element"}{"eValue"} ne $uKey 0 0 0
149 } else {
150 0 ▶ $tError .= ' - Host: '. $xml->{Monitoring}{Results}{Details}{Host} ." ne $hostname" if ($xml->{Monitoring}{Results}{Details}{Host} ne $hostname);
Branch: 1 branch
BranchTrueFalseTotal
if $xml->{"Monitoring"}{"Results"}{"Details"}{"Host"} ne $hostname 0 0 0
151 0 ▶ $tError .= ' - Service: '. $xml->{Monitoring}{Results}{Details}{Service} ." ne $service" if ($xml->{Monitoring}{Results}{Details}{Service} ne $service);
Branch: 1 branch
BranchTrueFalseTotal
if $xml->{"Monitoring"}{"Results"}{"Details"}{"Service"} ne $service 0 0 0
152 }
153  
154 0 ▶ $tError .= ' - Environment: ' .$xml->{Monitoring}{Results}{Details}{Environment} ." ne ". $environment{$environment} if ($xml->{Monitoring}{Results}{Details}{Environment} !~ /^$environment{$environment}$/i);
Branch: 1 branch
BranchTrueFalseTotal
unless $xml->{"Monitoring"}{"Results"}{"Details"}{"Environment"} =~ /^$environment{$environment}$/i 0 0 0
155 0 $objectPlugins->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => $tError, result => undef }, $TYPE{APPEND} );
156 }
157  
158 0 $objectPlugins->exit (3);
159  
160 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
161  
162 0 ▶sub validateResultOrSubResult {
Subroutine validateResultOrSubResult: not called CC=23 SCAR=63.1
163 0 my ($result, $subResult, $reverse, $debug) = @_;
164  
165 0 ▶ my $label = ( $subResult == 0 ? 'Details' : 'SubDetails');
Branch: 1 branch
BranchTrueFalseTotal
$subResult == 0 ? : 0 0 0
166  
167 0 ▶ if ( $debug ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug) 0 0 0
168 0 print $$result->{$label}{Host}, "\n", $$result->{$label}{Service}, "\n", $$result->{$label}{Environment}, "\n", $$result->{$label}{Date}, "\n", $$result->{$label}{Time}, "\n", $$result->{$label}{Epochtime}, "\n", $$result->{$label}{Status}, "\n", $$result->{$label}{StatusMessage}, "\n";
169 0 ▶ print $$result->{$label}{PerfData}, "\n" if (defined $$result->{$label}{PerfData});
Branch: 1 branch
BranchTrueFalseTotal
if defined $$result->{$label}{"PerfData"} 0 0 0
170 0 print "\n";
171 }
172  
173 0 my ($checkEpochtime, $checkDate, $checkTime) = ($$result->{$label}{Epochtime}, $$result->{$label}{Date}, $$result->{$label}{Time});
174  
175 # yyyy[-/]mm[-/]dd[Z|[+-]hh:mm]
176 0 ▶ $checkDate = reverse ( $checkDate ) if ($reverse);
Branch: 1 branch
BranchTrueFalseTotal
if $reverse 0 0 0
177 0 ($checkDate, my $offsetDate) = split (/(Z|[+-]\d+:\d+)/, $checkDate, 2);
178  
179 0 ▶ if ($reverse) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reverse) 0 0 0
180 0 $checkDate = reverse ( $checkDate );
181 0 ▶ $offsetDate = reverse ( $offsetDate ) if ( defined $offsetDate );
Branch: 1 branch
BranchTrueFalseTotal
if defined $offsetDate 0 0 0
182 }
183  
184 # yyyy[-/]mm[-/]dd
185 0 my ($checkYear, $checkMonth, $checkDay) = split (/[\/-]/, $checkDate);
186 0 ▶ print "$checkDate, $checkYear, $checkMonth, $checkDay\n" if ( $debug );
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
187  
188 # hh:mm:ss[Z|[+-]hh:mm]
189 0 ($checkTime, my $offsetTime) = split (/[Z+-]/, $checkTime, 2);
190 0 my ($checkHour, $checkMin, $checkSec) = split (/:/, $checkTime);
191 0 ▶ print "$checkTime, $checkHour, $checkMin, $checkSec\n" if ( $debug );
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
192  
193 0 my $xmlEpochtime = timelocal ( $checkSec, $checkMin, $checkHour, $checkDay, ($checkMonth-1), ($checkYear-1900) );
194 0 ▶ print "$checkEpochtime, $xmlEpochtime ($checkDate, $checkTime), $currentTimeslot - $checkEpochtime = ". ($currentTimeslot - $checkEpochtime) ." > $resultOutOfDate\n" if ( $objectPlugins->getOptionsValue ('debug') );
Branch: 1 branch
BranchTrueFalseTotal
if $objectPlugins->getOptionsValue("debug") 0 0 0
195  
196 0 ▶ unless ( check_date ( $checkYear, $checkMonth, $checkDay) or check_time($checkHour, $checkMin, $checkSec ) ) {
Branch: 3 branches
BranchTrueFalseTotal
if (check_date($checkYear, $checkMonth, $checkDay) or check_time($checkHour, $checkMin, $checkSec)) { } 0 0 0
if (do { $checkEpochtime != $xmlEpochtime }) { } 0 0 0
elsif ($currentTimeslot - $checkEpochtime > $resultOutOfDate) { } 0 0 0
Condition0%0/3
check_date($checkYear, $checkMonth, $checkDay) or check_time($checkHour, $checkMin, $checkSec)
l!l&&r!l&&!r
000
MC/DC0%0/2
check_date($checkYear, $checkMonth, $checkDay) or check_time($checkHour, $checkMin, $checkSec)
check_date($checkYear, $checkMonth, $checkDay) check_time($checkHour, $checkMin, $checkSec)
Truth table0%0/3
A or B
A= check_date($checkYear, $checkMonth, $checkDay)B= check_time($checkHour, $checkMin, $checkSec)
ABresult
1X1
011
000
197 0 $objectPlugins->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => "Date or Time into XML from URL '$url' are wrong: $checkDate $checkTime", result => undef }, $TYPE{APPEND} );
198 } elsif ( $checkEpochtime != $xmlEpochtime ) {
199 0 $objectPlugins->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => "Epochtime difference from Date and Time into XML from URL '$url' are wrong: $checkEpochtime != $xmlEpochtime ($checkDate $checkTime)", result => undef }, $TYPE{APPEND} );
200 } elsif ( $currentTimeslot - $checkEpochtime > $resultOutOfDate ) {
201 0 $objectPlugins->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => "Result into XML from URL '$url' are out of date: $checkDate $checkTime", result => undef }, $TYPE{APPEND} );
202 } else {
203 0 my ($errorDetail, $errorStack);
204 0 $debugfileMessage .= "<TR><TD COLSPAN=\"7\">&nbsp;</TD></TR>\n";
205  
206 0 ▶ if ( $subResult == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subResult == 0) { } 0 0 0
207 0 $debugfileMessage .= "\n<TR style=\"font: normal verdana,arial,helvetica; background:#c9c9c9;\"><TD colspan=\"7\" ALIGN=\"CENTER\" CLASS=\"status". $STATE{$$result->{$label}{Status}}. "\"><B>". $STATE{$$result->{$label}{Status}}. "</B></TD></TR>";
208 0 $debugfileMessage .= "<TR><TD COLSPAN=\"7\">&nbsp;</TD></TR>\n";
209 0 $debugfileMessage .= "\n<TR style=\"font: normal bold verdana,arial,helvetica; background:#0eeeee;\"><TD colspan=\"7\">Result: " .$$result->{$label}{Service}. "</TD></TR>";
210 0 $objectPlugins->pluginValues ( { stateError => $STATE{$$result->{$label}{Status}}, alert => $$result->{$label}{StatusMessage}, result => $$result->{$label}{content} }, $TYPE{APPEND} );
211 0 ▶ $errorDetail = $$result->{ErrorDetail} if ( $$result->{ErrorDetail} );
Branch: 1 branch
BranchTrueFalseTotal
if $$result->{"ErrorDetail"} 0 0 0
212 0 ▶ $errorStack = $$result->{ErrorStack} if ( $$result->{ErrorStack} );
Branch: 1 branch
BranchTrueFalseTotal
if $$result->{"ErrorStack"} 0 0 0
213 } else {
214 0 $debugfileMessage .= "\n<TR style=\"font: normal bold verdana,arial,helvetica; background:#0eeeee;\"><TD colspan=\"7\">Sub Result: " .$$result->{$label}{Service}. "</TD></TR>";
215 0 $objectPlugins->pluginValues( { alert => $$result->{$label}{Service} ." " . $STATE{$$result->{$label}{Status}} }, $TYPE{APPEND} );
216 0 ▶ $errorDetail = $$result->{SubErrorDetail} if ( $$result->{SubErrorDetail} );
Branch: 1 branch
BranchTrueFalseTotal
if $$result->{"SubErrorDetail"} 0 0 0
217 0 ▶ $errorStack = $$result->{SubErrorStack} if ( $$result->{SubErrorStack} );
Branch: 1 branch
BranchTrueFalseTotal
if $$result->{"SubErrorStack"} 0 0 0
218 }
219  
220 0 $debugfileMessage .= "<TR style=\"font: normal bold 68% verdana,arial,helvetica; text-align:left; background:#a6a6a6;\"><TH>Host</TH><TH>Service</TH><TH>Environment</TH><TH>Date</TH><TH>Time</TH><TH>StatusMessage</TH><TH>Status</TH></TR>\n";
221 0 $debugfileMessage .= "<TR style=\"font: normal 68% verdana,arial,helvetica; background:#e1e1ef;\"><TD>" .$$result->{$label}{Host}. "</TD><TD>" .$$result->{$label}{Service}. "</TD><TD>" .$$result->{$label}{Environment} ."</TD><TD>" .$$result->{$label}{Date} ."</TD><TD>" .$$result->{$label}{Time} ."</TD><TD>" .$$result->{$label}{StatusMessage}. "</TD><TD ALIGN=\"center\" ALIGN=\"CENTER\" CLASS=\"status" .$STATE{$$result->{$label}{Status}}. "\"><B>" .$STATE{$$result->{$label}{Status}}."</B></TD></TR>\n";
222 0 ▶ $debugfileMessage .= "<TR style=\"font: normal 68% verdana,arial,helvetica; background:#eeeee0;\"><TD valign=\"top\">Error Detail</TD><TD colspan=\"6\"><PRE>$errorDetail</PRE></TD></TR>\n" if ( $errorDetail );
Branch: 1 branch
BranchTrueFalseTotal
if $errorDetail 0 0 0
223 0 ▶ $debugfileMessage .= "<TR style=\"font: normal 68% verdana,arial,helvetica; background:#e1e1ef;\"><TD valign=\"top\">Error Stack</TD><TD colspan=\"6\"><PRE>$errorStack</PRE></TD></TR>\n" if ( $errorStack );
Branch: 1 branch
BranchTrueFalseTotal
if $errorStack 0 0 0
224 0 ▶ $debugfileMessage .= "<TR><TD COLSPAN=\"7\">&nbsp;</TD></TR>\n" if ( $subResult == 0 );
Branch: 1 branch
BranchTrueFalseTotal
if $subResult == 0 0 0 0
225  
226 0 $objectPlugins->appendPerformanceData( "'" . $$result->{$label}{Service} ."'=" . $$result->{$label}{Status} . ';1;2;0;2' );
227 0 ▶ $objectPlugins->appendPerformanceData( $$result->{$label}{PerfData} ) if ( $$result->{$label}{PerfData} );
Branch: 1 branch
BranchTrueFalseTotal
if $$result->{$label}{"PerfData"} 0 0 0
228 }
229 }
230  
231 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
232  
233 __END__
« plugins/templates/check_template-WebTransact-XML-Monitoring-1.2.pl ↑ Summary plugins/templates/check_template-mail-xml-fingerprint-xml-monitoring.pl »