Compare commits

..

3 Commits

Author SHA1 Message Date
e4f62ea960 allineati a cr1000x 2021-12-19 16:43:34 +01:00
1a1183fa41 g301 unit 2021-11-13 23:00:45 +01:00
9645a35746 haproxy ip 2021-11-13 15:36:23 +01:00
2 changed files with 16 additions and 41 deletions

View File

@@ -17,7 +17,7 @@ my $username = 'ase_lar';
my $password = 'laravel';
my $db_lar = 'ase_lar';
my $db_sp = 'ase_lar';
my $server = 'localhost';
my $server = '80.211.107.201';
my $db_name = "ase_lar";
my $table = "RAWDATACOR";
my ( @CSVData, @sql );
@@ -28,9 +28,8 @@ my (
$tool, $toolbatt, $tooltemp, $tooltype, @channels,
@NewData, @ain, @din, @nodetype, $GDEventDate
);
my $matlab_proxy_ssh = "localhost"; #"80.211.107.201";
my $matlab_proxy_ssh_port = 22; #2222;
my $matlab_exec_user = 'asega';
my $matlab_proxy_ssh = "80.211.107.201";
my $matlab_proxy_ssh_port = 2222;
my $matlab_cmd = "";
my $matlab_timestamp = "";
my $ftp_send = 1;
@@ -44,7 +43,7 @@ my $duedate = '';
my ( $unit_id, $unit, $unittype );
my ( $fileDate, $fileTime );
my $matlab_rt = "/usr/local/MATLAB/MATLAB_Runtime/v93";
my $matlab_func_dir = "/usr/local/matlab_func/";
my $matlab_func_dir = "/mnt/elab-storage";
my $matlab_error = '';
my $matlab_timeout = '1800';
my $email_addr =
@@ -54,11 +53,9 @@ my ( $email_msg, $email_obj );
my $G201_fcheck = 0;
my $D2W_fcheck = 0;
my $G301_fcheck = 0;
my $CR1000X_fcheck = 0;
my $FtpToCustomerCmd = 'SendFtpElabData.pl';
my ( $scriptname, $scriptpath );
my $MatlabErrorPath = "/tmp/";
my $MatlabErrorFilename = $MatlabErrorPath;
my $MatlabErrorFilename = "/mnt/elab-error";
my @matlabOutputErrorArray;
my @errors;
my @warnings;
@@ -138,17 +135,15 @@ sub matlabCalc {
#print $ENV{"HOME"} . "\n";
$ENV{"HOME"} = "/" . $ENV{"HOME"};
chdir($matlab_func_dir)
or die "cannot change: $!\n";
print getTimeStamp("log")
. " - pid $$ >> current dir: $matlab_func_dir\n";
my $args = "timeout $matlab_timeout $matlab_cmd $matlab_rt $unit $tool";
my $cmd_elab =
"timeout $matlab_timeout $matlab_cmd $matlab_rt $unit $tool";
#my $args = "sh -c \'cd $matlab_func_dir; pwd; $cmd_elab\'";
my $args =
"ssh $matlab_proxy_ssh -p $matlab_proxy_ssh_port \"sh -c \'cd $matlab_func_dir; $cmd_elab\'\"";
if ( system($args) != 0 ) {
my $argscat =
"cd $MatlabErrorPath; cat _${unit}_${tool}*_\*_output_error.txt > ${unit}${tool}_output_error.txt";
system($argscat);
open( my $fh, '<', $MatlabErrorFilename )
or warn print getTimeStamp("log")
. " - pid $$ >> Cannot open Matlab output error file: ${MatlabErrorFilename}\n";
@@ -454,9 +449,7 @@ elsif ( $filecsvname =~ m/^(\d*_|)(G301_ID\d\d\d\d_DT\d\d\d\d_\d*)$/i ) {
}
while ( my $line = <FILE> ) {
#if ( $line =~ m/\A [[:ascii:]]* \Z/xms ) {
if ( $line !~ /\x00/ ) {
if ( $line =~ m/\A [[:ascii:]]* \Z/xms ) {
$line =~ tr /\,/\;/ if ( $line =~ m/^\"\d\d\d\d.*/i ); #CR1000X
$line =~ s/\"//g;
my ( $first, $NodeData ) = split( /;/, $line, 2 );
@@ -553,6 +546,9 @@ while ( my $line = <FILE> ) {
elsif ( $tooltype eq "CR1000X" )
{ # può essere tolto per attivarlo
@CSVData = split( /\|/, $NodeData );
print getTimeStamp("log")
. " - pid $$ >> TEST CR1000X Execution ended.\n";
exit;
}
elsif ( $tooltype eq "MUSA" ) {

View File

@@ -202,27 +202,6 @@ while ( my $line = $tail->GetLine() ) {
}
exit(0);
}
if ( ( $truser ne 'asega' ) and ( $truser ne 'corra' ) ) {
print getTimeStamp("log")
. " >> Sender user $truser: duplicate as asega user -> load data into DB.\n";
my $realtruser = $truser;
$truser = "asega";
$outpath =~ s/$realtruser/$truser/;
my ( $login, $pass, $uid, $gid ) = getpwnam($truser)
or warn getTimeStamp("log")
. " >> $truser not in passwd file.\n";
unless ( fork() ) {
setgid($gid);
setuid($uid);
$ENV{"HOME"} = 'home/' . $truser;
exec( $scriptpath
. "LoadCSVData.pl -f \"$dest\" -s \"$outpath/SQL/$filename"
. "_"
. "$timestamp.sql\" -d $truser >> /home/$truser/log/loadcsvdata.log 2>&1"
);
exit(0);
}
}
}
}
}