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 @warnings;
|
||||||
my $MatlabErrors = '';
|
my $MatlabErrors = '';
|
||||||
my $MatlabWarnings = '';
|
my $MatlabWarnings = '';
|
||||||
|
my $tool_status = '';
|
||||||
|
|
||||||
sub uniq {
|
sub uniq {
|
||||||
my %seen;
|
my %seen;
|
||||||
@@ -122,67 +123,75 @@ sub writeOutSql {
|
|||||||
|
|
||||||
sub matlabCalc {
|
sub matlabCalc {
|
||||||
getMatlabCmd();
|
getMatlabCmd();
|
||||||
$matlab_timestamp = getTimeStamp("db_ts");
|
if ( $tool_status eq 'Monitoring Completed' ) {
|
||||||
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")
|
print getTimeStamp("log")
|
||||||
. " - pid $$ >> current dir: $matlab_func_dir\n";
|
. " - pid $$ >> $unit - $tool - Monitoring completed: MatLab calc by-passed.\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 {
|
else {
|
||||||
$matlab_cmd = 'matlab_' . uc $matlab_cmd . '.cmd';
|
$matlab_timestamp = getTimeStamp("db_ts");
|
||||||
my @out_matlab = `ssh1 $matlab_ip 'cmd /c $matlab_cmd ' $tool`;
|
print getTimeStamp("log")
|
||||||
if ( index( $out_matlab[-1], "Failure" ) != -1 ) {
|
. " - 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")
|
print getTimeStamp("log")
|
||||||
. " - pid $$ >> $unit - $tool MatLab calc failed.\n";
|
. " - pid $$ >> current dir: $matlab_func_dir\n";
|
||||||
makeEmailMsg();
|
my @args = (
|
||||||
emailSend();
|
'timeout', $matlab_timeout, $matlab_cmd, $matlab_rt, $unit,
|
||||||
print getTimeStamp("log") . " - pid $$ >> Execution ended.\n";
|
$tool
|
||||||
exit(1);
|
);
|
||||||
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,9 +305,10 @@ sub getMatlabCmd {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while ( my $results = $sth->fetchrow_hashref ) {
|
while ( my $results = $sth->fetchrow_hashref ) {
|
||||||
$matlab_cmd = $results->{'matcall'};
|
$matlab_cmd = $results->{'matcall'};
|
||||||
$ftp_send = $results->{'ftp_send'};
|
$ftp_send = $results->{'ftp_send'};
|
||||||
$unit_id = $results->{'unit_id'};
|
$unit_id = $results->{'unit_id'};
|
||||||
|
$tool_status = $results->{'statustools'};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user