ASNMTAP
view release on metacpan or search on metacpan
applications/htmlroot/cgi-bin/detailedStatisticsReportGenerationAndCompareResponsetimeTrends.pl view on Meta::CPAN
$sth->finish() or $rv = error_trap_DBI("", "Cannot sth->finish", $debug, '', "", '', "", -1, '', $sessionID);
}
# General information table - - - - - - - - - - - - - - - - - - -
$infoTable = "<H1>General information</H1>\n";
$infoTable .= "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" bgcolor=\"$COLORSTABLE{TABLE}\"><tr><th width=\"200\">Entry</th><th>Value</th></tr>\n";
$infoTable .= " <tr><td bgcolor=\"$COLORSTABLE{ENDBLOCK}\">Application</td><td bgcolor=\"$COLORSTABLE{STARTBLOCK}\"> " .substr($htmlTitle, 11). " </td></tr>\n";
$infoTable .= " <tr><td bgcolor=\"$COLORSTABLE{ENDBLOCK}\">Report Type</td><td bgcolor=\"$COLORSTABLE{STARTBLOCK}\"> " .$inputType. ( defined $slaWindow ? ", " .$slaWindow : '') ." </td></tr>\n";
$infoTable .= " <tr><td bgcolor=\"$COLORSTABLE{ENDBLOCK}\">Generated on</td><td bgcolor=\"$COLORSTABLE{STARTBLOCK}\"> " .$now. "</td></tr>\n";
$infoTable .= " <tr><td colspan=\"2\"><br></td></tr>\n";
$infoTable .= " <tr><td bgcolor=\"$COLORSTABLE{ENDBLOCK}\">Average (ok only)</td><td bgcolor=\"$COLORSTABLE{STARTBLOCK}\"> " .substr($average,0,5). " seconds </td></tr>\n" if (defined $average);
if (($step >= 1) and ($numberOfDays >= 1)) {
$infoTable .= " <tr><td bgcolor=\"$COLORSTABLE{ENDBLOCK}\">Test interval</td><td bgcolor=\"$COLORSTABLE{STARTBLOCK}\"> " .($step/60). " minutes</td></tr>\n";
$infoTable .= " <tr><td bgcolor=\"$COLORSTABLE{ENDBLOCK}\">Should run 'X' tests:</td><td bgcolor=\"$COLORSTABLE{STARTBLOCK}\"> " .((86400/$step)* $numberOfDays). " </td></tr>\n";
$infoTable .= " <tr><td bgcolor=\"$COLORSTABLE{ENDBLOCK}\">Number of tests run </td><td bgcolor=\"$COLORSTABLE{STARTBLOCK}\"> " .$numbersOfTests. " (".substr(($numbersOfTests/((86400/$step)* $numberOfDays))*100,0,6)."%)</td></tr>\n";
}
$infoTable .= "</table>\n";
}
if ($comments eq 'on' and ! defined $errorMessage) {
# Comment Detail - - - - - - - - - - - - - - - - - - - - - - -
my ($activationDate, $suspentionDate, $solvedDate, $activationTime, $suspentionTime, $solvedTime, $commentData, $instability, $persistent, $downtime, $problemSolved);
$commentDetailList = "<H1>Comment Details</H1>\n";
$sqlQuery = "select SQL_NO_CACHE activationDate, suspentionDate, solvedDate, activationTime, suspentionTime, solvedTime, commentData, instability, persistent, downtime, problemSolved from $SERVERTABLCOMMENTS where catalogID = '" .$CcatalogI...
$sth = $dbh->prepare( $sqlQuery ) or $rv = error_trap_DBI("", "Cannot dbh->prepare: $sqlQuery", $debug, '', "", '', "", -1, '', $sessionID);
$sth->execute() or $rv = error_trap_DBI("", "Cannot sth->execute: $sqlQuery", $debug, '', "", '', "", -1, '', $sessionID) if $rv;
$sth->bind_columns( \$activationDate, \$suspentionDate, \$solvedDate, \$activationTime, \$suspentionTime, \$solvedTime, \$commentData, \$instability, \$persistent, \$downtime, \$problemSolved ) or $rv = error_trap_DBI("", "Cannot sth->bind_...
if ( $rv ) {
if ($sth->rows) {
$commentDetailList .= "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" bgcolor=\"$COLORSTABLE{TABLE}\"><tr><th></th><th>Activation Date/Time</th><th>Suspention Date/Time</th><th>Solved Date/Time</th><th>Instability</th><th>Persis...
while( $sth->fetch() ) {
$commentData =~ s/'/`/g;
$commentData =~ s/[\n\r]+(Updated|Edited|Closed) by: (?:.+), (?:.+) \((?:.+)\) on (\d{4}-\d\d-\d\d) (\d\d:\d\d:\d\d)/\n\r$1 on $2 $3/g;
$commentData =~ s/[\n\r]/<br>/g;
$commentData =~ s/(?:<br>)+/<br>/g;
$commentData = encode_html_entities('C', $commentData);
$commentDetailList .= "<tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td rowspan=\"2\" valign=\"top\"> </td><td>$activationDate \@ $activationTime</td><td>$suspentionDate \@ $suspentionTime</td><td>$solvedDate \@ $solvedTime</td><td>$i...
}
$commentDetailList .= "</table>\n";
} else {
$commentDetailList .= "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" bgcolor=\"$COLORSTABLE{TABLE}\"><tr><td width=\"400\">No comments for this period!</td></tr></table>";
}
$sth->finish() or $rv = error_trap_DBI("", "Cannot sth->finish", $debug, '', "", '', "", -1, '', $sessionID);
}
}
if ($perfdata eq 'on' and ! defined $errorMessage) {
# Performance Data Detail - - - - - - - - - - - - - - - - - - -
$perfdataDetailList = "<H1>Performance Data Details</H1>\n";
unless ( $PERFPARSEENABLED ) {
$perfdataDetailList .= "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" bgcolor=\"$COLORSTABLE{TABLE}\"><tr><td width=\"400\">Performance Data not enabled!</td></tr></table>";
} else {
my ($sthPERFPARSE, $metric_id, $metric, $times, $percentiles, $unit, $Unit, $periodePERFPARSE, $countPERFPARSE, $valuePERFPARSE) = ( $dbh );
my $toggle = 0;
my $sqlWherePERFDATA;
if ( $PERFPARSEVERSION eq '20' ) {
my $catalogID_uKey = ( ( $CcatalogID eq 'CID' ) ? '' : $CcatalogID .'_' ) . $uKey1;
$sqlQuery = "select service_id from $PERFPARSEDATABASE.perfdata_service where service_description = '$catalogID_uKey'";
$sqlWherePERFDATA = "where $DATABASE.$SERVERTABLREPORTSPRFDT.metric_id = $PERFPARSEDATABASE.perfdata_service_metric.metric_id and $PERFPARSEDATABASE.perfdata_service_metric.service_id in ($sqlQuery)";
} else {
$sqlWherePERFDATA = "where $DATABASE.$SERVERTABLREPORTSPRFDT.catalogID='$CcatalogID' and $DATABASE.$SERVERTABLREPORTSPRFDT.uKey='$uKey1' and $DATABASE.$SERVERTABLREPORTSPRFDT.activated='1' and $DATABASE.$SERVERTABLREPORTSPRFDT.metric_id...
}
$sqlQuery = "select $DATABASE.$SERVERTABLREPORTSPRFDT.metric_id, $PERFPARSEDATABASE.perfdata_service_metric.metric, $DATABASE.$SERVERTABLREPORTSPRFDT.times, $DATABASE.$SERVERTABLREPORTSPRFDT.percentiles, $DATABASE.$SERVERTABLREPORTSPRFDT....
$sth = $dbh->prepare( $sqlQuery ) or $rv = error_trap_DBI("", "Cannot dbh->prepare: $sqlQuery", $debug, '', "", '', "", -1, '', $sessionID);
$sth->execute() or $rv = error_trap_DBI("", "Cannot sth->execute: $sqlQuery", $debug, '', "", '', "", -1, '', $sessionID) if $rv;
$sth->bind_columns( \$metric_id, \$metric, \$times, \$percentiles, \$unit, \$Unit ) or $rv = error_trap_DBI("", "Cannot sth->bind_columns: $sqlQuery", $debug, '', "", '', "", -1, '', $sessionID) if $rv;
if ( $rv ) {
if ($sth->rows) {
my $sqlPeriodePERFDATA = $sqlPeriode;
if ( $PERFPARSEVERSION eq '20' ) {
$sqlPeriodePERFDATA =~ s/^AND startDate BETWEEN '(\d+-\d+-\d+)' AND '(\d+-\d+-\d+)'/AND FROM_UNIXTIME\(ctime\) BETWEEN '$1 00:00:00' AND '$2 23:59:59'/g;
$sqlPeriodePERFDATA =~ s/(startDate|startTime) BETWEEN/TIME\(FROM_UNIXTIME\(ctime\)\) BETWEEN/g;
$sqlPeriodePERFDATA =~ s/(startDate|startTime)/FROM_UNIXTIME\(ctime\)/g;
} else {
$sqlPeriodePERFDATA =~ s/^AND startDate BETWEEN '(\d+-\d+-\d+)' AND '(\d+-\d+-\d+)'/AND ctime BETWEEN '$1 00:00:00' AND '$2 23:59:59'/g;
$sqlPeriodePERFDATA =~ s/(startDate|startTime) BETWEEN/TIME\(ctime\) BETWEEN/g;
$sqlPeriodePERFDATA =~ s/(startDate|startTime)/ctime/g;
}
my $groupPERFDATA = ( $inputType eq 'fromto' ) ? 'dayofmonth' : $inputType; # 'dayofmonth' < 4.1.1 <= 'dayofmonth' or 'day' !!!
my $percentagePERFDATA = ( $inputType eq 'fromto' and $startDate ne $endDate ) ? 0 : 1;
$perfdataDetailList .= "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" bgcolor=\"$COLORSTABLE{TABLE}\">\n";
while( $sth->fetch() ) {
$perfdataDetailList .= "<tr><th> $groupPERFDATA </th><th align=\"left\"> $metric </th><th> Expression </th></tr>\n";
$times = ( defined $times and $times ne '' ) ? '0,'. $times : '0';
my $sqlValuePERFDATA = '';
my $countRows = 0;
if ( $unit =~ /(?:s|ms)/ and $Unit =~ /(?:s|ms)/ ) {
foreach my $time (split (/,/, $times)) {
$toggle = ( $toggle ) ? 0 : 1;
my $value = $time;
if ( $value ) {
if ( $unit ne $Unit ) {
if ( $Unit eq 'ms' ) {
$value *= 1000;
} elsif ( $Unit eq 's' ) {
$value /= 1000;
}
}
$sqlValuePERFDATA = 'and value <= '. $value;
}
my $sqlWherePERFDATA;
if ( $PERFPARSEVERSION eq '20' ) {
$sqlWherePERFDATA = "WHERE metric_id = '$metric_id'";
} else {
my $catalogID_uKey1 = ( ( $CcatalogID eq 'CID' ) ? '' : $CcatalogID .'_' ) . $uKey1;
$sqlWherePERFDATA = "WHERE host_name = '$Title' and service_description = '$catalogID_uKey1' and metric = '$metric'";
}
my $sqlPERFDATA = "SELECT ";
$sqlPERFDATA .= ( $PERFPARSEVERSION eq '20' ) ? "$groupPERFDATA(FROM_UNIXTIME(ctime))" :" $groupPERFDATA(ctime)";
$sqlPERFDATA .= ", count(ctime) FROM $PERFPARSEDATABASE.perfdata_service_bin $sqlWherePERFDATA $sqlPeriodePERFDATA $sqlValuePERFDATA group by ";
$sqlPERFDATA .= ( $PERFPARSEVERSION eq '20' ) ? "$groupPERFDATA(FROM_UNIXTIME(ctime))" : "$groupPERFDATA(ctime)";
$sthPERFPARSE = $dbh->prepare( $sqlPERFDATA ) or $rv = error_trap_DBI("", "Cannot dbh->prepare: $sqlPERFDATA", $debug, '', "", '', "", -1, '', $sessionID);
$sthPERFPARSE->execute() or $rv = error_trap_DBI("", "Cannot sth->execute: $sqlPERFDATA", $debug, '', "", '', "", -1, '', $sessionID) if $rv;
$sthPERFPARSE->bind_columns( \$periodePERFPARSE, \$countPERFPARSE ) or $rv = error_trap_DBI("", "Cannot sth->bind_columns: $sqlPERFDATA", $debug, '', "", '', "", -1, '', $sessionID) if $rv;
my $expresionPERFPARSE = ( $debug eq 'T' ? "($value $Unit) " : '' );
my $bgcolor = ( $toggle ) ? $COLORSTABLE{ENDBLOCK} : $COLORSTABLE{STARTBLOCK};
$perfdataDetailList .= "<tr bgcolor=\"$bgcolor\"><td colspan=\"2\"> $sqlPERFDATA </td><td> <= $time $unit $expresionPERFPARSE</td></tr>\n" if ( $debug eq 'T' );
if ( $rv ) {
if ($sthPERFPARSE->rows) {
while( $sthPERFPARSE->fetch() ) {
unless ( $value ) {
$countRows = $countPERFPARSE;
} else {
if ( $percentagePERFDATA ) {
my $percentage = sprintf "%.2f", ( ( $countPERFPARSE / $countRows ) * 100 );
$percentage = "( $countPERFPARSE / $countRows ) * 100 = $percentage" if ( $debug eq 'T' );
$perfdataDetailList .= "<tr bgcolor=\"$bgcolor\"><td align=\"right\"> $periodePERFPARSE </td><td align=\"right\"> $percentage % </td><td> <= $time $unit $expresionPERFPARSE</td><...
} else {
$perfdataDetailList .= "<tr bgcolor=\"$bgcolor\"><td align=\"right\"> $periodePERFPARSE </td><td align=\"right\"> $countPERFPARSE # </td><td> <= $time $unit $expresionPERFPARSE</...
}
}
}
} elsif ( $debug eq 'T' ) {
$perfdataDetailList .= "<tr bgcolor=\"$bgcolor\"><td align=\"right\"> </td><td align=\"right\"> 0 ". ( $percentagePERFDATA ? '%' : '#' ) ." </td><td> <= $time $unit $expresionPERFPARSE</td>...
}
$sthPERFPARSE->finish() or $rv = error_trap_DBI("", "Cannot sth->finish", $debug, '', "", '', "", -1, '', $sessionID);
}
}
if ( $percentagePERFDATA ) {
foreach my $percentile (split (/,/, $percentiles)) {
$toggle = ( $toggle ) ? 0 : 1;
my ($IR, $FR) = split (/\./, sprintf "%.2f", ( ( $percentile / 100 ) * ( $countRows + 1 ) ) );
my $limit = ( $FR eq '00' ) ? 1 : 2;
my $offset = $IR - 1;
$FR = sprintf "0.%d", $FR;
my $sqlWherePERFDATA;
if ( $PERFPARSEVERSION eq '20' ) {
$sqlWherePERFDATA = "WHERE metric_id = '$metric_id'";
} else {
my $catalogID_uKey1 = ( ( $CcatalogID eq 'CID' ) ? '' : $CcatalogID .'_' ) . $uKey1;
$sqlWherePERFDATA = "WHERE host_name = '$Title' and service_description = '$catalogID_uKey1' and metric = '$metric'";
}
my $sqlPERFDATA = "SELECT ";
$sqlPERFDATA .= ( $PERFPARSEVERSION eq '20' ) ? "$groupPERFDATA(FROM_UNIXTIME(ctime))" : "$groupPERFDATA(ctime)";
$sqlPERFDATA .= ", value FROM $PERFPARSEDATABASE.perfdata_service_bin $sqlWherePERFDATA $sqlPeriodePERFDATA order by value limit $offset, $limit";
$sthPERFPARSE = $dbh->prepare( $sqlPERFDATA ) or $rv = error_trap_DBI("", "Cannot dbh->prepare: $sqlPERFDATA", $debug, '', "", '', "", -1, '', $sessionID);
$sthPERFPARSE->execute() or $rv = error_trap_DBI("", "Cannot sth->execute: $sqlPERFDATA", $debug, '', "", '', "", -1, '', $sessionID) if $rv;
$sthPERFPARSE->bind_columns( \$periodePERFPARSE, \$valuePERFPARSE ) or $rv = error_trap_DBI("", "Cannot sth->bind_columns: $sqlPERFDATA", $debug, '', "", '', "", -1, '', $sessionID) if $rv;
my $bgcolor = ( $toggle ) ? $COLORSTABLE{ENDBLOCK} : $COLORSTABLE{STARTBLOCK};
$perfdataDetailList .= "<tr bgcolor=\"$bgcolor\"><td colspan=\"2\"> ( ( $percentile / 100 ) * ( $countRows + 1 ) ), IR: $IR, FR: $FR, offset: $offset, limit: $limit & # $countRows <br> $sqlPERFDATA </td><td...
if ( $rv ) {
if ($sthPERFPARSE->rows) {
my ($value1, $value2);
while( $sthPERFPARSE->fetch() ) {
$value1 = $valuePERFPARSE unless (defined $value1);
$value2 = $valuePERFPARSE if (defined $value1);
}
$value2 = $value1 unless (defined $value2);
if ( $unit ne $Unit ) {
if ( $Unit eq 'ms' ) {
$value1 /= 1000;
$value2 /= 1000;
} elsif ( $Unit eq 's' ) {
$value1 *= 1000;
$value2 *= 1000;
}
}
my $percentilePERFPARSE = sprintf "%.2f $unit", ( "$FR" * ( $value2 - $value1 ) + $value1 );
$percentilePERFPARSE = "( $FR * ( $value2 - $value1 ) + $value1 ) = $percentilePERFPARSE" if ( $debug eq 'T' );
$perfdataDetailList .= "<tr bgcolor=\"$bgcolor\"><td align=\"right\"> $periodePERFPARSE </td><td align=\"right\"> $percentilePERFPARSE </td><td> $percentile ste percentile </td></tr>...
} elsif ( $debug eq 'T' ) {
$perfdataDetailList .= "<tr bgcolor=\"$bgcolor\"><td align=\"right\"> </td><td align=\"right\"> missing data </td><td> $percentile ste percentile </td></tr>\n";
}
$sthPERFPARSE->finish() or $rv = error_trap_DBI("", "Cannot sth->finish", $debug, '', "", '', "", -1, '', $sessionID);
}
}
} else {
$perfdataDetailList .= "<tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td colspan=\"3\"> ASNMTAP/Performance Data: percentile not supported when $startDate ne $endDate </td></tr>\n";
}
} else {
$perfdataDetailList .= "<tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td colspan=\"2\"> ASNMTAP/Performance Data: unit not supported % </td><td> $unit/$Unit </td></tr>\n";
}
}
$perfdataDetailList .= "</table>\n";
} else {
$perfdataDetailList .= "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" bgcolor=\"$COLORSTABLE{TABLE}\"><tr><td width=\"400\">No Performance Data defined!</td></tr></table>";
}
$sth->finish() or $rv = error_trap_DBI("", "Cannot sth->finish", $debug, '', "", '', "", -1, '', $sessionID);
}
}
}
if ($details eq 'on' and ! defined $errorMessage) {
# Problem Detail - - - - - - - - - - - - - - - - - - - - - - - -
my ($oneblock, $block, $firstrun, $nstartDateQ, $nstartTime, $nendDateQ, $nendTime, $nseconden);
my ($test, $resultsdir, $tel, $wtel, $nstatus, $nrest, $nyear, $nmonth, $nday, $nhours, $nminuts, $nseconds, $rrest);
$errorDetailList = "<H1>Problem Details</H1>\n";
$responseTable = "<H1>Response time warnings</H1>\n";
$sqlQuery = "select SQL_NO_CACHE test, resultsdir from $SERVERTABLPLUGINS $sqlWhere";
$sth = $dbh->prepare( $sqlQuery ) or $rv = error_trap_DBI("", "Cannot dbh->prepare: $sqlQuery", $debug, '', "", '', "", -1, '', $sessionID);
$sth->execute() or $rv = error_trap_DBI("", "Cannot sth->execute: $sqlQuery", $debug, '', "", '', "", -1, '', $sessionID) if $rv;
if ( $rv ) {
($test, $resultsdir) = $sth->fetchrow_array() or $rv = error_trap_DBI("", "Cannot sth->execute: $sqlQuery", $debug, '', "", '', "", -1, '', $sessionID) if $rv;
$sth->finish() or $rv = error_trap_DBI("", "Cannot sth->execute: $sqlQuery", $debug, '', "", '', "", -1, '', $sessionID);
if ( $rv ) {
($test, undef) = split(/\.pl/, $test);
$sqlQuery = create_sql_query_events_from_range_year_month ($inputType, $sqlStartDate, $sqlEndDate, $sqlSelect, $forceIndex, $sqlWhere, $sqlPeriode, "AND status <> 'OK' AND status <> 'OFFLINE' AND status <> 'NO TEST'", '', "", "order by ...
$sth = $dbh->prepare( $sqlQuery ) or $rv = error_trap_DBI("", "Cannot dbh->prepare: $sqlQuery", $debug, '', "", '', "", -1, '', $sessionID);
$sth->execute() or $rv = error_trap_DBI("", "Cannot sth->execute: $sqlQuery", $debug, '', "", '', "", -1, '', $sessionID) if $rv;
$sth->bind_columns( \$startDateQ, \$startTime, \$endDateQ, \$endTime, \$duration, \$status, \$statusMessage ) or $rv = error_trap_DBI("", "Cannot sth->bind_columns: $sqlQuery", $debug, '', "", '', "", -1, '', $sessionID) if $rv;
}
}
if ( $rv ) {
sub createLinkToDebugFile {
my ($startDate, $startTime, $status, $statusMessage) = @_;
my ($year, $month, $day) = split (/-/, $startDate);
my ($hour, $min, $sec) = split (/:/, $startTime);
if ( $formatOutput ne 'html' or $htmlToPdf ) {
return ($statusMessage);
} else {
my $catalogID_uKey1 = ( ( $CcatalogID eq 'CID' ) ? '' : $CcatalogID .'_' ) . $uKey1;
if (-e "$PREFIXPATH/$RESULTSDIR/$resultsdir/$DEBUGDIR/$year$month$day$hour$min$sec-$test-$catalogID_uKey1-$status.htm") {
return ("<A HREF=\"$RESULTSURL/$resultsdir/$DEBUGDIR/$year$month$day$hour$min$sec-$test-$catalogID_uKey1-$status.htm\" target=\"_blank\">$statusMessage</A>");
} else {
return ($statusMessage);
}
}
( run in 0.832 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )