by pass matlab elab on monitoring completed
This commit is contained in:
126
LoadCSVData.pl
126
LoadCSVData.pl
@@ -59,6 +59,7 @@ my @errors;
|
||||
my @warnings;
|
||||
my $MatlabErrors = '';
|
||||
my $MatlabWarnings = '';
|
||||
my $tool_status = '';
|
||||
|
||||
sub uniq {
|
||||
my %seen;
|
||||
@@ -122,67 +123,75 @@ sub writeOutSql {
|
||||
|
||||
sub matlabCalc {
|
||||
getMatlabCmd();
|
||||
$matlab_timestamp = getTimeStamp("db_ts");
|
||||
print getTimeStamp("log")
|
||||
. " - pid $$ >> $unit - $tool MatLab calc started...\n";
|
||||
if ( $matlab_cmd =~ /_lnx$/ ) {
|
||||
$matlab_cmd = './run_' . $matlab_cmd . '.sh';
|
||||
$MatlabErrorFilename .= "${unit}${tool}_output_error.txt";
|
||||
|
||||
#print $ENV{"HOME"} . "\n";
|
||||
$ENV{"HOME"} = "/" . $ENV{"HOME"};
|
||||
chdir($matlab_func_dir)
|
||||
or die "cannot change: $!\n";
|
||||
if ( $tool_status eq 'Monitoring Completed' ) {
|
||||
print getTimeStamp("log")
|
||||
. " - pid $$ >> current dir: $matlab_func_dir\n";
|
||||
my @args =
|
||||
( 'timeout', $matlab_timeout, $matlab_cmd, $matlab_rt, $unit, $tool );
|
||||
if ( system(@args) != 0 ) {
|
||||
open( my $fh, '<', $MatlabErrorFilename )
|
||||
or warn print getTimeStamp("log")
|
||||
. " - pid $$ >> Cannot open Matlab output error file: ${MatlabErrorFilename}\n";
|
||||
{
|
||||
chomp( @matlabOutputErrorArray = <$fh> );
|
||||
}
|
||||
close($fh);
|
||||
@matlabOutputErrorArray = grep( /\S/, @matlabOutputErrorArray );
|
||||
@errors = grep( /^Error/, @matlabOutputErrorArray );
|
||||
@warnings = grep( !/^Error/, @matlabOutputErrorArray );
|
||||
$MatlabErrors = join( "<br/>", @errors );
|
||||
$MatlabWarnings = join( "<br/>", uniq(@warnings) );
|
||||
my $exit_value = $? >> 8;
|
||||
|
||||
if ( $exit_value == 124 ) {
|
||||
print getTimeStamp("log")
|
||||
. " - pid $$ >> system @args excessive duration: killed after $matlab_timeout seconds\n";
|
||||
$matlab_error =
|
||||
"Matlab elab excessive duration: killed after $matlab_timeout seconds";
|
||||
}
|
||||
else {
|
||||
print getTimeStamp("log")
|
||||
. " - pid $$ >> system @args failed: return code $exit_value - $?\n";
|
||||
$matlab_error = "Matlab elab failed: $exit_value - $?";
|
||||
}
|
||||
makeEmailMsg();
|
||||
emailSend();
|
||||
print getTimeStamp("log") . " - pid $$ >> Execution ended.\n";
|
||||
exit(1);
|
||||
}
|
||||
. " - pid $$ >> $unit - $tool - Monitoring completed: MatLab calc by-passed.\n";
|
||||
}
|
||||
else {
|
||||
$matlab_cmd = 'matlab_' . uc $matlab_cmd . '.cmd';
|
||||
my @out_matlab = `ssh1 $matlab_ip 'cmd /c $matlab_cmd ' $tool`;
|
||||
if ( index( $out_matlab[-1], "Failure" ) != -1 ) {
|
||||
$matlab_timestamp = getTimeStamp("db_ts");
|
||||
print getTimeStamp("log")
|
||||
. " - pid $$ >> $unit - $tool MatLab calc started...\n";
|
||||
if ( $matlab_cmd =~ /_lnx$/ ) {
|
||||
$matlab_cmd = './run_' . $matlab_cmd . '.sh';
|
||||
$MatlabErrorFilename .= "${unit}${tool}_output_error.txt";
|
||||
|
||||
#print $ENV{"HOME"} . "\n";
|
||||
$ENV{"HOME"} = "/" . $ENV{"HOME"};
|
||||
chdir($matlab_func_dir)
|
||||
or die "cannot change: $!\n";
|
||||
print getTimeStamp("log")
|
||||
. " - pid $$ >> $unit - $tool MatLab calc failed.\n";
|
||||
makeEmailMsg();
|
||||
emailSend();
|
||||
print getTimeStamp("log") . " - pid $$ >> Execution ended.\n";
|
||||
exit(1);
|
||||
. " - pid $$ >> current dir: $matlab_func_dir\n";
|
||||
my @args = (
|
||||
'timeout', $matlab_timeout, $matlab_cmd, $matlab_rt, $unit,
|
||||
$tool
|
||||
);
|
||||
if ( system(@args) != 0 ) {
|
||||
open( my $fh, '<', $MatlabErrorFilename )
|
||||
or warn print getTimeStamp("log")
|
||||
. " - pid $$ >> Cannot open Matlab output error file: ${MatlabErrorFilename}\n";
|
||||
{
|
||||
chomp( @matlabOutputErrorArray = <$fh> );
|
||||
}
|
||||
close($fh);
|
||||
@matlabOutputErrorArray = grep( /\S/, @matlabOutputErrorArray );
|
||||
@errors = grep( /^Error/, @matlabOutputErrorArray );
|
||||
@warnings = grep( !/^Error/, @matlabOutputErrorArray );
|
||||
$MatlabErrors = join( "<br/>", @errors );
|
||||
$MatlabWarnings = join( "<br/>", uniq(@warnings) );
|
||||
my $exit_value = $? >> 8;
|
||||
|
||||
if ( $exit_value == 124 ) {
|
||||
print getTimeStamp("log")
|
||||
. " - pid $$ >> system @args excessive duration: killed after $matlab_timeout seconds\n";
|
||||
$matlab_error =
|
||||
"Matlab elab excessive duration: killed after $matlab_timeout seconds";
|
||||
}
|
||||
else {
|
||||
print getTimeStamp("log")
|
||||
. " - pid $$ >> system @args failed: return code $exit_value - $?\n";
|
||||
$matlab_error = "Matlab elab failed: $exit_value - $?";
|
||||
}
|
||||
makeEmailMsg();
|
||||
emailSend();
|
||||
print getTimeStamp("log") . " - pid $$ >> Execution ended.\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$matlab_cmd = 'matlab_' . uc $matlab_cmd . '.cmd';
|
||||
my @out_matlab = `ssh1 $matlab_ip 'cmd /c $matlab_cmd ' $tool`;
|
||||
if ( index( $out_matlab[-1], "Failure" ) != -1 ) {
|
||||
print getTimeStamp("log")
|
||||
. " - pid $$ >> $unit - $tool MatLab calc failed.\n";
|
||||
makeEmailMsg();
|
||||
emailSend();
|
||||
print getTimeStamp("log") . " - pid $$ >> Execution ended.\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
print getTimeStamp("log")
|
||||
. " - pid $$ >> $unit - $tool MatLab calc executed.\n";
|
||||
}
|
||||
print getTimeStamp("log")
|
||||
. " - pid $$ >> $unit - $tool MatLab calc executed.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -296,9 +305,10 @@ sub getMatlabCmd {
|
||||
}
|
||||
else {
|
||||
while ( my $results = $sth->fetchrow_hashref ) {
|
||||
$matlab_cmd = $results->{'matcall'};
|
||||
$ftp_send = $results->{'ftp_send'};
|
||||
$unit_id = $results->{'unit_id'};
|
||||
$matlab_cmd = $results->{'matcall'};
|
||||
$ftp_send = $results->{'ftp_send'};
|
||||
$unit_id = $results->{'unit_id'};
|
||||
$tool_status = $results->{'statustools'};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user