« 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | unless ( defined $uKey ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $hostname = $objectPlugins->getOptionsArgv ('hostname') ? $objectPlugins->getOptionsArgv ('hostname') : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | $objectPlugins->printUsage ('Missing command line argument uKey or hostname') unless (defined $hostname); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | $service = $objectPlugins->getOptionsArgv ('service') ? $objectPlugins->getOptionsArgv ('service') : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | $objectPlugins->printUsage ('Missing command line argument service') unless ( defined $service); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | my $validateDTD = $objectPlugins->getOptionsArgv ('validation') ? $objectPlugins->getOptionsArgv ('validation') : 'F'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if (defined $validateDTD) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | $objectPlugins->printUsage ('Invalid validation option: '. $validateDTD) unless ($validateDTD =~ /^[FT]$/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | $validateDTD = ($validateDTD eq 'T') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my $resultOutOfDate = $objectPlugins->getOptionsArgv ('interval'); | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | my $environment = $objectPlugins->getOptionsArgv ('environment') ? $objectPlugins->getOptionsArgv ('environment') : 'P'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
defined $$result->{"Results"}{"Extension"}{"Element"}{"eName"} and $$result->{"Extension"}{"Element"}{"eName"} eq "uKey"
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"
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | $match = 1 if ( defined $$result->{Extension}{Element}{eValue} and $$result->{Extension}{Element}{eValue} eq $uKey ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $$result->{"Extension"}{"Element"}{"eValue"} and $$result->{"Extension"}{"Element"}{"eValue"} eq $uKey
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
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | $match = 1 if ( $$result->{Details}{Host} eq $hostname and $$result->{Details}{Service} eq $service ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$$result->{"Details"}{"Host"} eq $hostname and $$result->{"Details"}{"Service"} eq $service
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
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if (! $firstResults or ($match and $$result->{Details}{Environment} =~ /^$environment{$environment}$/i)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $firstResults or $match and $$result->{"Details"}{"Environment"} =~ /^$environment{$environment}$/i
$match and $$result->{"Details"}{"Environment"} =~ /^$environment{$environment}$/i
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | if ( ref $$result->{SubResults} eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | $tError .= ' - uKey: '. $$result->{Extension}{Element}{eValue} ." ne $uKey" if ($$result->{Extension}{Element}{eValue} ne $uKey); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | $tError .= ' - Host: '. $$result->{Details}{Host} ." ne $hostname" if ($$result->{Details}{Host} ne $hostname); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | $tError .= ' - Service: '. $$result->{Details}{Service} ." ne $service" if ($$result->{Details}{Service} ne $service); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | $tError .= ' - Environment: ' .$$result->{Details}{Environment} ." ne ". $environment{$environment} if ($$result->{Details}{Environment} !~ /^$environment{$environment}$/i); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | if ( $debug ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ($checkDate, my $offsetDate) = split (/(Z|[+-]\d+:\d+)/, $checkDate, 2); | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if ($reverse) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $checkDate = reverse ( $checkDate ); | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | $offsetDate = reverse ( $offsetDate ) if ( defined $offsetDate ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | unless ( check_date ( $checkYear, $checkMonth, $checkDay) or check_time($checkHour, $checkMin, $checkSec ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
check_date($checkYear, $checkMonth, $checkDay) or check_time($checkHour, $checkMin, $checkSec)
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)
| |||||||||||||||||||||||||||||||||||||||||||
| 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\"> </TD></TR>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | if ( $subResult == 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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\"> </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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | $errorStack = $$result->{ErrorStack} if ( $$result->{ErrorStack} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | $errorStack = $$result->{SubErrorStack} if ( $$result->{SubErrorStack} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | $debugfileMessage .= "<TR><TD COLSPAN=\"7\"> </TD></TR>\n" if ( $subResult == 0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | __END__ | ||||||||||||||||||||||||||||||||||||||||||