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

filter: Statementstmt 22.3% 33 / 148 Branchbran 1.0% 1 / 100 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 84.6% 11 / 13 Podpod n/a totaltotal 15.5% 45 / 290 CC 42 SCAR 59.4
CC
42
Cov
13%
validateResultOrSubResult
600.0
processAllResult
342.0
BEGIN
2.5
CRAP 380.9
« plugins/templates/check_template-mail-xml-fingerprint-xml-monitoring-1.1.pl ↑ Summary plugins/templates/check_template-WebTransact-XML-Monitoring-1.1.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.2.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.001;
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.2";
29  
30 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
31  
32 3 my $objectPlugins = ASNMTAP::Asnmtap::Plugins->new (
33 _programName => 'check_template-WebTransact-XML-Monitoring-1.2.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 ▶if ($xml->{Monitoring}{Schema}{Value} eq $schema) {
Branch: 1 branch
BranchTrueFalseTotal
if ($xml->{'Monitoring'}{'Schema'}{'Value'} eq $schema) { } 0 0 0
117 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";
118 0 my $firstResults = 1;
119  
120 0 ▶ if ( ref $xml->{Monitoring}{Results} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $xml->{'Monitoring'}{'Results'} eq 'ARRAY') { } 0 0 0
121 0 foreach my $results (@{$xml->{Monitoring}{Results}}) {
122 0 processAllResult ( \$debugfileMessage, $firstResults, \$results, $reverse, $debug );
123 0 $firstResults = 0;
124 }
125 } else {
126 0 processAllResult ( \$debugfileMessage, $firstResults, \$xml->{Monitoring}{Results}, $reverse, $debug );
127 }
128  
129 0 $objectPlugins->write_debugfile ( \$debugfileMessage, 0 );
130 } else {
131 0 my $tError = 'Content Error: - Schema: '. $xml->{Monitoring}{Schema}{Value} ." ne $schema";
132 0 $objectPlugins->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => $tError, result => undef }, $TYPE{APPEND} );
133 }
134  
135 0 $objectPlugins->exit (3);
136  
137 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
138  
139 0 ▶sub processAllResult {
Subroutine processAllResult: not called CC=18 SCAR=58.3
140 0 my ($debugfileMessage, $firstResults, $result, $reverse, $debug) = @_;
141  
142 0 my $match = 0;
143  
144 0 ▶ if ( defined $$result->{Results}{Extension}{Element}{eName} and $$result->{Extension}{Element}{eName} eq 'uKey') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$result->{'Results'}{'Extension'}{'Element'}{'eName'} and $$result->{'Extension'}{'Element'}{'eName'} eq 'uKey') { } 0 0 0
Condition0%0/3
defined $$result->{"Results"}{"Extension"}{"Element"}{"eName"} and $$result->{"Extension"}{"Element"}{"eName"} eq "uKey"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $$result->{"Results"}{"Extension"}{"Element"}{"eName"} and $$result->{"Extension"}{"Element"}{"eName"} eq "uKey"
defined $$result->{"Results"}{"Extension"}{"Element"}{"eName"} $$result->{"Extension"}{"Element"}{"eName"} eq "uKey"
Truth table0%0/3
A and B
A= defined $$result->{"Results"}{"Extension"}{"Element"}{"eName"}B= $$result->{"Extension"}{"Element"}{"eName"} eq "uKey"
ABresult
0X0
100
111
145 0 ▶ $match = 1 if ( defined $$result->{Extension}{Element}{eValue} and $$result->{Extension}{Element}{eValue} eq $uKey );
Branch: 1 branch
BranchTrueFalseTotal
if defined $$result->{"Extension"}{"Element"}{"eValue"} and $$result->{"Extension"}{"Element"}{"eValue"} eq $uKey 0 0 0
Condition0%0/3
defined $$result->{"Extension"}{"Element"}{"eValue"} and $$result->{"Extension"}{"Element"}{"eValue"} eq $uKey
!ll&&!rl&&r
000
MC/DC0%0/2
defined $$result->{"Extension"}{"Element"}{"eValue"} and $$result->{"Extension"}{"Element"}{"eValue"} eq $uKey
defined $$result->{"Extension"}{"Element"}{"eValue"} $$result->{"Extension"}{"Element"}{"eValue"} eq $uKey
Truth table0%0/3
A and B
A= defined $$result->{"Extension"}{"Element"}{"eValue"}B= $$result->{"Extension"}{"Element"}{"eValue"} eq $uKey
ABresult
0X0
100
111
146 } else {
147 0 ▶ $match = 1 if ( $$result->{Details}{Host} eq $hostname and $$result->{Details}{Service} eq $service );
Branch: 1 branch
BranchTrueFalseTotal
if $$result->{"Details"}{"Host"} eq $hostname and $$result->{"Details"}{"Service"} eq $service 0 0 0
Condition0%0/3
$$result->{"Details"}{"Host"} eq $hostname and $$result->{"Details"}{"Service"} eq $service
!ll&&!rl&&r
000
MC/DC0%0/2
$$result->{"Details"}{"Host"} eq $hostname and $$result->{"Details"}{"Service"} eq $service
$$result->{"Details"}{"Host"} eq $hostname $$result->{"Details"}{"Service"} eq $service
Truth table0%0/3
A and B
A= $$result->{"Details"}{"Host"} eq $hostnameB= $$result->{"Details"}{"Service"} eq $service
ABresult
0X0
100
111
148 }
149  
150 0 ▶ if (! $firstResults or ($match and $$result->{Details}{Environment} =~ /^$environment{$environment}$/i)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $firstResults or $match and $$result->{'Details'}{'Environment'} =~ /^$environment{$environment}$/i) { } 0 0 0
Condition0%0/6
not $firstResults or $match and $$result->{"Details"}{"Environment"} =~ /^$environment{$environment}$/i
l!l&&r!l&&!r
000
$match and $$result->{"Details"}{"Environment"} =~ /^$environment{$environment}$/i
!ll&&!rl&&r
000
MC/DC0%0/3
not $firstResults or $match and $$result->{"Details"}{"Environment"} =~ /^$environment{$environment}$/i
not $firstResults $match $$result->{"Details"}{"Environment"} =~ /^$environment{$environment}$/i
Truth table0%0/4
not(A) or B and C
A= not $firstResultsB= $matchC= $$result->{"Details"}{"Environment"} =~ /^$environment{$environment}$/i
ABCresult
1XX1
0111
00X0
0100
151 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";
152 0 $$debugfileMessage .= "\n<TABLE WIDTH=\"100%\">";
153  
154 0 validateResultOrSubResult ( $firstResults, \$$result, 0, $reverse, $debug );
155  
156 0 ▶ if ( defined $$result->{SubResults} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$result->{"SubResults"}) 0 0 0
157 0 ▶ if ( ref $$result->{SubResults} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $$result->{'SubResults'} eq 'ARRAY') { } 0 0 0
158 0 foreach my $subResults (@{$$result->{SubResults}}) {
159 0 validateResultOrSubResult ( $firstResults, \$subResults, 1, $reverse, $debug );
160 }
161 } else {
162 0 validateResultOrSubResult ( $firstResults, \$$result->{SubResults}, 1, $reverse, $debug );
163 }
164 }
165  
166 0 $debugfileMessage .= "</TABLE>\n";
167 0 $debugfileMessage .= "<P style=\"font: normal 68% verdana,arial,helvetica;\" ALIGN=\"left\">Generated on: " .scalar(localtime()). "</P>\n</BODY>\n</HTML>";
168 } else {
169 0 my $tError = 'Content Error:';
170  
171 0 ▶ if ( $$result->{Extension}{Element}{eName} eq 'uKey') {
Branch: 1 branch
BranchTrueFalseTotal
if ($$result->{'Extension'}{'Element'}{'eName'} eq 'uKey') { } 0 0 0
172 0 ▶ $tError .= ' - uKey: '. $$result->{Extension}{Element}{eValue} ." ne $uKey" if ($$result->{Extension}{Element}{eValue} ne $uKey);
Branch: 1 branch
BranchTrueFalseTotal
if $$result->{"Extension"}{"Element"}{"eValue"} ne $uKey 0 0 0
173 } else {
174 0 ▶ $tError .= ' - Host: '. $$result->{Details}{Host} ." ne $hostname" if ($$result->{Details}{Host} ne $hostname);
Branch: 1 branch
BranchTrueFalseTotal
if $$result->{"Details"}{"Host"} ne $hostname 0 0 0
175 0 ▶ $tError .= ' - Service: '. $$result->{Details}{Service} ." ne $service" if ($$result->{Details}{Service} ne $service);
Branch: 1 branch
BranchTrueFalseTotal
if $$result->{"Details"}{"Service"} ne $service 0 0 0
176 }
177  
178 0 ▶ $tError .= ' - Environment: ' .$$result->{Details}{Environment} ." ne ". $environment{$environment} if ($$result->{Details}{Environment} !~ /^$environment{$environment}$/i);
Branch: 1 branch
BranchTrueFalseTotal
unless $$result->{"Details"}{"Environment"} =~ /^$environment{$environment}$/i 0 0 0
179 0 $objectPlugins->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => $tError, result => undef }, $TYPE{APPEND} );
180 }
181 }
182  
183 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
184  
185 0 ▶sub validateResultOrSubResult {
Subroutine validateResultOrSubResult: not called CC=24 SCAR=64.0
186 0 my ($firstResults, $result, $subResult, $reverse, $debug) = @_;
187  
188 0 ▶ my $label = ( $subResult == 0 ? 'Details' : 'SubDetails');
Branch: 1 branch
BranchTrueFalseTotal
$subResult == 0 ? : 0 0 0
189  
190 0 ▶ if ( $debug ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug) 0 0 0
191 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";
192 0 ▶ print $$result->{$label}{PerfData}, "\n" if (defined $$result->{$label}{PerfData});
Branch: 1 branch
BranchTrueFalseTotal
if defined $$result->{$label}{"PerfData"} 0 0 0
193 0 print "\n";
194 }
195  
196 0 my ($checkEpochtime, $checkDate, $checkTime) = ($$result->{$label}{Epochtime}, $$result->{$label}{Date}, $$result->{$label}{Time});
197  
198 # yyyy[-/]mm[-/]dd[Z|[+-]hh:mm]
199 0 ▶ $checkDate = reverse ( $checkDate ) if ($reverse);
Branch: 1 branch
BranchTrueFalseTotal
if $reverse 0 0 0
200 0 ($checkDate, my $offsetDate) = split (/(Z|[+-]\d+:\d+)/, $checkDate, 2);
201  
202 0 ▶ if ($reverse) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reverse) 0 0 0
203 0 $checkDate = reverse ( $checkDate );
204 0 ▶ $offsetDate = reverse ( $offsetDate ) if ( defined $offsetDate );
Branch: 1 branch
BranchTrueFalseTotal
if defined $offsetDate 0 0 0
205 }
206  
207 # yyyy[-/]mm[-/]dd
208 0 my ($checkYear, $checkMonth, $checkDay) = split (/[\/-]/, $checkDate);
209 0 ▶ print "$checkDate, $checkYear, $checkMonth, $checkDay\n" if ( $debug );
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
210  
211 # hh:mm:ss[Z|[+-]hh:mm]
212 0 ($checkTime, my $offsetTime) = split (/[Z+-]/, $checkTime, 2);
213 0 my ($checkHour, $checkMin, $checkSec) = split (/:/, $checkTime);
214 0 ▶ print "$checkTime, $checkHour, $checkMin, $checkSec\n" if ( $debug );
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
215  
216 0 my $xmlEpochtime = timelocal ( $checkSec, $checkMin, $checkHour, $checkDay, ($checkMonth-1), ($checkYear-1900) );
217 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
218  
219 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
220 0 $objectPlugins->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => "Date or Time into XML from URL '$url' are wrong: $checkDate $checkTime", result => undef }, $TYPE{APPEND} );
221 } elsif ( $checkEpochtime != $xmlEpochtime ) {
222 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} );
223 } elsif ( $currentTimeslot - $checkEpochtime > $resultOutOfDate ) {
224 0 $objectPlugins->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => "Result into XML from URL '$url' are out of date: $checkDate $checkTime", result => undef }, $TYPE{APPEND} );
225 } else {
226 0 my ($errorDetail, $errorStack);
227 0 $debugfileMessage .= "<TR><TD COLSPAN=\"7\">&nbsp;</TD></TR>\n";
228  
229 0 ▶ if ( $subResult == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subResult == 0) { } 0 0 0
230 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>";
231 0 $debugfileMessage .= "<TR><TD COLSPAN=\"7\">&nbsp;</TD></TR>\n";
232 0 $debugfileMessage .= "\n<TR style=\"font: normal bold verdana,arial,helvetica; background:#0eeeee;\"><TD colspan=\"7\">Result: " .$$result->{$label}{Service}. "</TD></TR>";
233  
234 0 ▶ if ( $firstResults ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($firstResults) { } 0 0 0
235 0 $objectPlugins->pluginValues ( { stateError => $STATE{$$result->{$label}{Status}}, alert => $$result->{$label}{StatusMessage}, result => $$result->{$label}{content} }, $TYPE{APPEND} );
236 } else {
237 0 $objectPlugins->pluginValues ( { alert => $$result->{$label}{StatusMessage}, result => $$result->{$label}{content} }, $TYPE{APPEND} );
238 }
239  
240 0 ▶ $errorDetail = $$result->{ErrorDetail} if ( $$result->{ErrorDetail} );
Branch: 1 branch
BranchTrueFalseTotal
if $$result->{"ErrorDetail"} 0 0 0
241 0 ▶ $errorStack = $$result->{ErrorStack} if ( $$result->{ErrorStack} );
Branch: 1 branch
BranchTrueFalseTotal
if $$result->{"ErrorStack"} 0 0 0
242 } else {
243 0 $debugfileMessage .= "\n<TR style=\"font: normal bold verdana,arial,helvetica; background:#0eeeee;\"><TD colspan=\"7\">Sub Result: " .$$result->{$label}{Service}. "</TD></TR>";
244 0 $objectPlugins->pluginValues( { alert => $$result->{$label}{Service} ." " . $STATE{$$result->{$label}{Status}} }, $TYPE{APPEND} );
245 0 ▶ $errorDetail = $$result->{SubErrorDetail} if ( $$result->{SubErrorDetail} );
Branch: 1 branch
BranchTrueFalseTotal
if $$result->{"SubErrorDetail"} 0 0 0
246 0 ▶ $errorStack = $$result->{SubErrorStack} if ( $$result->{SubErrorStack} );
Branch: 1 branch
BranchTrueFalseTotal
if $$result->{"SubErrorStack"} 0 0 0
247 }
248  
249 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";
250 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";
251 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
252 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
253 0 ▶ $debugfileMessage .= "<TR><TD COLSPAN=\"7\">&nbsp;</TD></TR>\n" if ( $subResult == 0 );
Branch: 1 branch
BranchTrueFalseTotal
if $subResult == 0 0 0 0
254  
255 0 $objectPlugins->appendPerformanceData( "'" . $$result->{$label}{Service} ."'=" . $$result->{$label}{Status} . ';1;2;0;2' );
256 0 ▶ $objectPlugins->appendPerformanceData( $$result->{$label}{PerfData} ) if ( $$result->{$label}{PerfData} );
Branch: 1 branch
BranchTrueFalseTotal
if $$result->{$label}{"PerfData"} 0 0 0
257 }
258 }
259  
260 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
261  
262 __END__
« plugins/templates/check_template-mail-xml-fingerprint-xml-monitoring-1.1.pl ↑ Summary plugins/templates/check_template-WebTransact-XML-Monitoring-1.1.pl »