ASNMTAP
view release on metacpan or search on metacpan
applications/bin/generateReports.pl view on Meta::CPAN
$urlAccessParameters .= "&topx=on" if($showTop20SlowTests);
$urlAccessParameters .= "&pf=on" if($printerFriendlyOutput);
$sql = "select test, resultsdir from $SERVERTABLPLUGINS where catalogID = '$catalogID' and ukey = '$uKey' order by uKey";
my $sth = $dbh->prepare( $sql ) or $rv = DBI_error_trap(*EMAILREPORT, "Cannot dbh->prepare: $sql", \$logger, $debug);
$sth->execute() or $rv = DBI_error_trap(*EMAILREPORT, "Cannot sth->execute: $sql", \$logger, $debug) if $rv;
if ( $rv ) {
($test, $resultsdir) = $sth->fetchrow_array() or $rv = DBI_error_trap(*EMAILREPORT, "Cannot sth->execute: $sql", \$logger, $debug) if $rv;
$sth->finish() or $rv = DBI_error_trap(*EMAILREPORT, "Cannot sth->execute: $sql", \$logger, $debug);
}
my $logging = $RESULTSPATH .'/'. $resultsdir;
create_dir ($logging);
my $reports = $logging .'/'. $REPORTDIR;
create_dir ($reports);
$logging .= "/";
create_header ($logging."HEADER.html");
create_footer ($logging."FOOTER.html");
$reports .= "/";
create_header ($reports."HEADER.html");
create_footer ($reports."FOOTER.html");
my $dayReportMonthPdf = ($dayReportMonth < 10) ? "0$dayReportMonth" : $dayReportMonth;
my $dayReportDayPdf = ($dayReportDay < 10) ? "0$dayReportDay" : $dayReportDay;
my $catalogID_uKey = ( ( $catalogID eq 'CID' ) ? '' : $catalogID .'_' ) . $uKey;
my $pdfFilename = "$RESULTSPATH/$resultsdir/$REPORTDIR/$dayReportYear$dayReportMonthPdf$dayReportDayPdf-$test-$catalogID_uKey-$periodeMessage-id_$id.pdf";
my $encodedUrlAccessParameters = encode_html_entities('U', $urlAccessParameters);
my $user_password = (defined $userPassword and $userPassword ne '' ? '--user-password '. $userPassword : '');
my $command = "$HTMLTOPDFPRG -f '$pdfFilename' $user_password $HTMLTOPDFOPTNS 'http://${REMOTE_HOST}$HTTPSURL/cgi-bin/detailedStatisticsReportGenerationAndCompareResponsetimeTrends.pl?$encodedUrlAccessParameters'";
if ( -e "$pdfFilename" ) {
$emailMessage .= " > $pdfFilename already generated\n";
} else {
$emailMessage .= " > $pdfFilename will be generated\n";
push (@commands, $command);
push (@pdfFilenames, $pdfFilename);
}
}
if ( $debug ) { print $emailMessage; } else { print EMAILREPORT $emailMessage; }
}
}
$sth->finish() or $rv = DBI_error_trap(*EMAILREPORT, "Cannot sth->finish: $sql", \$logger, $debug);
}
$dbh->disconnect or $rv = DBI_error_trap(*EMAILREPORT, "Sorry, the database was unable to add your entry.", \$logger, $debug);
my $teller = 0;
$emailMessage .= "\n";
foreach my $command (@commands) {
if ($HTMLTOPDFPRG eq 'HTMLDOC') {
$ENV{HTMLDOC_NOCGI} = 1;
select(STDOUT); $| = 1;
}
my ($status, $stdout, $stderr) = call_system ("$command", $debug);
unless ( $status == 0 and $stdout eq '' and $stderr eq '' ) {
$emailMessage .= $pdfFilenames[$teller]. " generation failed\n";
$emailMessage .= "call_system: command: $command, status: $status, stdout: $stdout, stderr: $stderr\n" if ( $debug );
} else {
$emailMessage .= $pdfFilenames[$teller]. " generated\n";
}
$teller++;
}
if ( $debug ) { print $emailMessage; } else { print EMAILREPORT $emailMessage; }
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my ($rc) = send_email_report (*EMAILREPORT, $emailReport, $rvOpen, $prgtext, $debug);
exit;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub create_dir {
my ($directory) = @_;
unless ( -e "$directory" ) { # create $directory
my ($status, $stdout, $stderr) = call_system ("mkdir $directory", $debug);
if (!$status and ($stdout ne '' or $stderr ne '')) {
my $error = " > create_dir: mkdir $directory: status: $status, stdout: $stdout, stderr: $stderr\n";
if ( $debug ) { print $error; } else { print EMAILREPORT $error; }
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_usage () {
print "Usage: $PROGNAME [-y <year>] [-m <month>] [-d <day>] [-a <days after>] [-u <uKey>] [-D <debug>] [-V version] [-h help]\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help () {
print_revision($PROGNAME, $version);
print "ASNMTAP Generate Reports for the '$APPLICATION'
-y, --year=<year> (default: current year)
-m, --month=<month> (default: current month)
-d, --day=<day> (default: current day)
-a, --daysAfter=<days after|F(alse)> (default: 3)
-u, --uKey=<uKey plugin> (default: all plugins)
-D, --debug=F|T|L
F(alse) : screendebugging off (default)
T(true) : normal screendebugging on
L(ong) : long screendebugging on
-V, --version
-h, --help
Send email to $SENDEMAILTO if you have questions regarding
use of this software. To submit patches or suggest improvements, send
email to $SENDEMAILTO
";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
( run in 0.532 second using v1.01-cache-2.11-cpan-99c4e6809bf )