un po' di roba
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
prova.pl
|
prova.pl
|
||||||
prova_mail.pl
|
prova_mail.pl
|
||||||
UnitCSVReceiver
|
UnitCSVReceiver
|
||||||
prova.log
|
prova.log
|
||||||
|
.vstags
|
||||||
|
|||||||
@@ -121,17 +121,18 @@ if ($sth->rows < 0) {
|
|||||||
print getLoggingTime() . " - No rows from TOOLS & UNITS.\n";
|
print getLoggingTime() . " - No rows from TOOLS & UNITS.\n";
|
||||||
} else {
|
} else {
|
||||||
while (my $results = $sth->fetchrow_hashref) {
|
while (my $results = $sth->fetchrow_hashref) {
|
||||||
$ToolName{$results->{'ToolNameID'}}{'idCompany'} = $results->{'idCompany'};
|
$ToolName{$results->{UnitNameId} . $results->{'ToolNameID'}}{'idCompany'} = $results->{'idCompany'};
|
||||||
$ToolName{$results->{'ToolNameID'}}{'CompanyNameShort'} = $results->{'CompanyNameShort'};
|
$ToolName{$results->{UnitNameId} . $results->{'ToolNameID'}}{'CompanyNameShort'} = $results->{'CompanyNameShort'};
|
||||||
$ToolName{$results->{'ToolNameID'}}{'SiteName'} = $results->{'SiteName'};
|
$ToolName{$results->{UnitNameId} . $results->{'ToolNameID'}}{'SiteName'} = $results->{'SiteName'};
|
||||||
$ToolName{$results->{'idCompany'}}{'CompanyEmail'} = $results->{'CompanyEmail'};
|
$ToolName{$results->{'idCompany'}}{'CompanyEmail'} = $results->{'CompanyEmail'};
|
||||||
$ToolName{$results->{'idCompany'}}{'SendAlarm'} = $results->{'SendAlarm'};
|
$ToolName{$results->{'idCompany'}}{'SendAlarm'} = $results->{'SendAlarm'};
|
||||||
$ToolName{$results->{'ToolNameID'}}{'UnitNameId'} = $results->{'UnitNameId'};
|
$ToolName{$results->{UnitNameId} . $results->{'ToolNameID'}}{'UnitNameId'} = $results->{'UnitNameId'};
|
||||||
$ToolName{$results->{'ToolNameID'}}{'ToolState'} = $results->{'ToolState'};
|
$ToolName{$results->{UnitNameId} . $results->{'ToolNameID'}}{'ToolNameID'} = $results->{'ToolNameID'};
|
||||||
$ToolName{$results->{'ToolNameID'}}{'LettureNodi'} = "--";
|
$ToolName{$results->{UnitNameId} . $results->{'ToolNameID'}}{'ToolState'} = $results->{'ToolState'};
|
||||||
$ToolName{$results->{'ToolNameID'}}{'LettureCatene'} = "--";
|
$ToolName{$results->{UnitNameId} . $results->{'ToolNameID'}}{'LettureNodi'} = "--";
|
||||||
$ToolName{$results->{'ToolNameID'}}{'NumeroNodi'} = "--";
|
$ToolName{$results->{UnitNameId} . $results->{'ToolNameID'}}{'LettureCatene'} = "--";
|
||||||
$ToolName{$results->{'ToolNameID'}}{'ErroriTotaliLetture'} = "--";
|
$ToolName{$results->{UnitNameId} . $results->{'ToolNameID'}}{'NumeroNodi'} = "--";
|
||||||
|
$ToolName{$results->{UnitNameId} . $results->{'ToolNameID'}}{'ErroriTotaliLetture'} = "--";
|
||||||
if ($results->{'ToolState'} eq "Active" ){
|
if ($results->{'ToolState'} eq "Active" ){
|
||||||
$act_tool++;
|
$act_tool++;
|
||||||
}
|
}
|
||||||
@@ -145,7 +146,7 @@ $dbh->disconnect;
|
|||||||
$dbh = DBI->connect("DBI:mysql:$database;host=$server", $username, $password)
|
$dbh = DBI->connect("DBI:mysql:$database;host=$server", $username, $password)
|
||||||
or die getLoggingTime() . " - Could not connect to database: $DBI::errstr";
|
or die getLoggingTime() . " - Could not connect to database: $DBI::errstr";
|
||||||
|
|
||||||
my $stw = $dbh->prepare("select ToolNameID, EventDate, count(EventTime) 'LettureNodi', truncate(Count(EventTime)/max(NodeNum),1) 'LettureCatene', max(NodeNum) 'NumeroNodi' from RAWDATACOR where EventDate = subdate(curdate(),1) group by ToolNameID")
|
my $stw = $dbh->prepare("select UnitName, ToolNameID, EventDate, count(EventTime) 'LettureNodi', truncate(Count(EventTime)/max(NodeNum),1) 'LettureCatene', max(NodeNum) 'NumeroNodi' from RAWDATACOR where EventDate = subdate(curdate(),1) group by UnitName, ToolNameID")
|
||||||
or die getLoggingTime() . " - $DBI::errstr";
|
or die getLoggingTime() . " - $DBI::errstr";
|
||||||
$stw->execute();
|
$stw->execute();
|
||||||
|
|
||||||
@@ -154,9 +155,9 @@ if ($stw->rows == 0) {
|
|||||||
$email_obj = "ATTENZIONE: nessuna lettura pervenuta!!!"
|
$email_obj = "ATTENZIONE: nessuna lettura pervenuta!!!"
|
||||||
} else {
|
} else {
|
||||||
while (my $results = $stw->fetchrow_hashref) {
|
while (my $results = $stw->fetchrow_hashref) {
|
||||||
$ToolName{$results->{'ToolNameID'}}{'LettureNodi'} = $results->{'LettureNodi'};
|
$ToolName{$results->{'UnitName'} . $results->{'ToolNameID'}}{'LettureNodi'} = $results->{'LettureNodi'};
|
||||||
$ToolName{$results->{'ToolNameID'}}{'LettureCatene'} = $results->{'LettureCatene'};
|
$ToolName{$results->{'UnitName'} . $results->{'ToolNameID'}}{'LettureCatene'} = $results->{'LettureCatene'};
|
||||||
$ToolName{$results->{'ToolNameID'}}{'NumeroNodi'} = $results->{'NumeroNodi'};
|
$ToolName{$results->{'UnitName'} . $results->{'ToolNameID'}}{'NumeroNodi'} = $results->{'NumeroNodi'};
|
||||||
$ref_date = $results->{'EventDate'};
|
$ref_date = $results->{'EventDate'};
|
||||||
if (substr($results->{'ToolNameID'},0,2) eq "GD" ){
|
if (substr($results->{'ToolNameID'},0,2) eq "GD" ){
|
||||||
$gd_tool++;
|
$gd_tool++;
|
||||||
@@ -172,12 +173,12 @@ if ($stw->rows == 0) {
|
|||||||
|
|
||||||
$stw->finish;
|
$stw->finish;
|
||||||
|
|
||||||
my $ste = $dbh->prepare("select ToolNameID, count(val0) 'ErroriTotaliLetture' from RAWDATACOR where EventDate = ? and val0 = 'Err1' group by ToolNameID")
|
my $ste = $dbh->prepare("select UnitName, ToolNameID, count(val0) 'ErroriTotaliLetture' from RAWDATACOR where EventDate = ? and val0 = 'Err1' group by ToolNameID")
|
||||||
or die getLoggingTime() . " - $DBI::errstr";
|
or die getLoggingTime() . " - $DBI::errstr";
|
||||||
$ste->bind_param(1, $ref_date);
|
$ste->bind_param(1, $ref_date);
|
||||||
$ste->execute();
|
$ste->execute();
|
||||||
while (my $results = $ste->fetchrow_hashref) {
|
while (my $results = $ste->fetchrow_hashref) {
|
||||||
$ToolName{$results->{'ToolNameID'}}{'ErroriTotaliLetture'} = $results->{'ErroriTotaliLetture'};
|
$ToolName{$results->{'UnitName'} . $results->{'ToolNameID'}}{'ErroriTotaliLetture'} = $results->{'ErroriTotaliLetture'};
|
||||||
}
|
}
|
||||||
|
|
||||||
$ste->finish;
|
$ste->finish;
|
||||||
@@ -193,7 +194,7 @@ foreach my $tool (sort grep { /DT|PT/ } keys %ToolName){
|
|||||||
}
|
}
|
||||||
|
|
||||||
my $tool_part = "<td>" . $ToolName{$tool}{'CompanyNameShort'} . "</td><td>". $ToolName{$tool}{'SiteName'} . "</td>";
|
my $tool_part = "<td>" . $ToolName{$tool}{'CompanyNameShort'} . "</td><td>". $ToolName{$tool}{'SiteName'} . "</td>";
|
||||||
$tool_part .= "<td align=\"center\">" . $ToolName{$tool}{'UnitNameId'} . "</td><td align=\"center\">" . $tool . "</td>";
|
$tool_part .= "<td align=\"center\">" . $ToolName{$tool}{'UnitNameId'} . "</td><td align=\"center\">" . $ToolName{$tool}{ToolNameID} . "</td>";
|
||||||
$tool_part .= "<td align=\"right\">" . $ToolName{$tool}{'LettureNodi'} . "</td><td align=\"right\">" . $ToolName{$tool}{'NumeroNodi'} . "</td>";
|
$tool_part .= "<td align=\"right\">" . $ToolName{$tool}{'LettureNodi'} . "</td><td align=\"right\">" . $ToolName{$tool}{'NumeroNodi'} . "</td>";
|
||||||
$tool_part .= "<td align=\"right\">" . $ToolName{$tool}{'LettureCatene'} . "</td>";
|
$tool_part .= "<td align=\"right\">" . $ToolName{$tool}{'LettureCatene'} . "</td>";
|
||||||
$tool_part .= "<td align=\"center\">" . $ToolName{$tool}{'ErroriTotaliLetture'} . "</td><td align=\"center\">" . $ToolName{$tool}{'ToolState'} . "</td></tr>\n";
|
$tool_part .= "<td align=\"center\">" . $ToolName{$tool}{'ErroriTotaliLetture'} . "</td><td align=\"center\">" . $ToolName{$tool}{'ToolState'} . "</td></tr>\n";
|
||||||
|
|||||||
@@ -41,9 +41,10 @@ my ($fileDate, $fileTime);
|
|||||||
my $matlab_rt = "/usr/local/MATLAB/MATLAB_Runtime/v93";
|
my $matlab_rt = "/usr/local/MATLAB/MATLAB_Runtime/v93";
|
||||||
my $matlab_func_dir = "/usr/local/matlab_func/";
|
my $matlab_func_dir = "/usr/local/matlab_func/";
|
||||||
my $matlab_error = '';
|
my $matlab_error = '';
|
||||||
my $matlab_timeout = '1200';
|
my $matlab_timeout = '1800';
|
||||||
my $email_addr = 'andrea.carri@aseltd.eu,roberto.savi@aseltd.eu,alessandro.battilani@gmail.com';
|
my $email_addr = 'andrea.carri@aseltd.eu,roberto.savi@aseltd.eu,edoardo.cavalca@aseltd.eu,alessandro.battilani@gmail.com,alessandro.valletta@aseltd.eu';
|
||||||
my ($email_msg, $email_obj);
|
my ($email_msg, $email_obj);
|
||||||
|
my $G201_fcheck = 0;
|
||||||
|
|
||||||
|
|
||||||
sub getTimeStamp{ # parm [ts] => timestamp for filename; log => timestamp for log
|
sub getTimeStamp{ # parm [ts] => timestamp for filename; log => timestamp for log
|
||||||
@@ -411,20 +412,17 @@ if ( $db_name ne 'asega' ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my ( $filecsvname, $path, $suffix ) = fileparse( $filename, qr/\.[^.]*/ );
|
my ( $filecsvname, $path, $suffix ) = fileparse( $filename, qr/\.[^.]*/ );
|
||||||
|
|
||||||
if ( $filecsvname =~ m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d.*|GD\d*)_\d*$/i ) {
|
if ( $filecsvname =~ m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d.*|GD\d*)_\d*$/i ) {
|
||||||
($fileDate, $fileTime) = split( /\s/, <FILE> );
|
($fileDate, $fileTime) = split( /\s/, <FILE> );
|
||||||
($unittype, $unit ) = split( /\s/, uc <FILE> );
|
($unittype, $unit ) = split( /\s/, uc <FILE> );
|
||||||
$unit =~ s/;+$//;
|
$unit =~ s/;+$//;
|
||||||
} elsif ( $filecsvname =~ m/^(\d\d_\d\d\d\d_|)(\d\d\d\d\d\d\d\d\d\d\d\d\d\d_)(G201_ID\d\d\d\d_DT\d\d\d\d)_\d*$/i ) {
|
} elsif ( $filecsvname =~ m/^G201_ID\d\d\d\d_DT\d\d\d\d_\d*_\d*$/i ) {
|
||||||
|
my @strings = $filecsvname =~ /(.{1,4})_(.{1,6})_(.{1,6})_(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2}).*/;
|
||||||
# da mettere il controllo ^^^^^^^^^^^^^^^ se ha mese ed anno all'inivio
|
$unittype = $strings[0];
|
||||||
my @strings = $filecsvname =~ /(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2})_(.{1,4})_(.{1,6})_(.{1,6}).*/;
|
$unit = $strings[1];
|
||||||
$fileDate = $strings[0] . "/" . $strings[1] . "/" . $strings[2];
|
$tool = $strings[2];
|
||||||
$fileTime = $strings[3] . ":" . $strings[4] . ":" . $strings[5];
|
$fileDate = $strings[3] . "/" . $strings[4] . "/" . $strings[5];;
|
||||||
$unittype = $strings[6];
|
$fileTime = $strings[6] . ":" . $strings[7] . ":" . $strings[8];
|
||||||
$unit = $strings[7];
|
|
||||||
$tool = $strings[8];
|
|
||||||
$tooltype = 'MUX';
|
$tooltype = 'MUX';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,6 +452,11 @@ while ( my $line = <FILE> ) {
|
|||||||
$NodeData =~ s/;+$//;
|
$NodeData =~ s/;+$//;
|
||||||
|
|
||||||
#$NodeData =~ s/\r\n\z//;
|
#$NodeData =~ s/\r\n\z//;
|
||||||
|
if ($unittype eq 'G201' and $G201_fcheck eq 0) {
|
||||||
|
print getTimeStamp("log"). " - pid $$ >> Found $tooltype tool name: $tool\n";
|
||||||
|
getNodesType();
|
||||||
|
$G201_fcheck = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if ( $tooltype eq "MUX" ) {
|
if ( $tooltype eq "MUX" ) {
|
||||||
|
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ sub getUnitName { # parm => file received ($trfile)
|
|||||||
my ( $fileDate, $fileTime );
|
my ( $fileDate, $fileTime );
|
||||||
my ( $unittype, $unit );
|
my ( $unittype, $unit );
|
||||||
my ( $filenamecsv, $path, $suffix ) = fileparse( $filename, qr/\.[^.]*/ );
|
my ( $filenamecsv, $path, $suffix ) = fileparse( $filename, qr/\.[^.]*/ );
|
||||||
if ( $filenamecsv =~ m/^(\d\d_\d\d\d\d_|)(\d\d\d\d\d\d\d\d\d\d\d\d\d\d_)(G201_ID\d\d\d\d_DT\d\d\d\d)$/i ) { # GD201
|
if ( $filenamecsv =~ m/^G201_ID\d\d\d\d_DT\d\d\d\d_\d*$/i ) { # GD201
|
||||||
my @strings = $filenamecsv =~ /(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2})_(.{1,4})_(.{1,6})_(.{1,6}).*/;
|
my @strings = $filenamecsv =~ /(.{1,4})_(.{1,6})_(.{1,6})_(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2}).*/;
|
||||||
$fileDate = $strings[0] . "/" . $strings[1] . "/" . $strings[2];;
|
$unittype = $strings[0];
|
||||||
$fileTime = $strings[3] . ":" . $strings[4] . ":" . $strings[5];
|
$unit = $strings[1];
|
||||||
$unittype = $strings[6];
|
$fileDate = $strings[3] . "/" . $strings[4] . "/" . $strings[5];;
|
||||||
$unit = $strings[7];
|
$fileTime = $strings[6] . ":" . $strings[7] . ":" . $strings[8];
|
||||||
} else {
|
} else {
|
||||||
open FILE, $filename
|
open FILE, $filename
|
||||||
or warn getTimeStamp("log") . " >> Error: opening input file $filename\n";
|
or warn getTimeStamp("log") . " >> Error: opening input file $filename\n";
|
||||||
@@ -69,15 +69,13 @@ while ( my $line = $tail->GetLine() ) {
|
|||||||
or warn getTimeStamp("log") . " >> $truser not in passwd file.\n";
|
or warn getTimeStamp("log") . " >> $truser not in passwd file.\n";
|
||||||
|
|
||||||
my ( $filename, $path, $suffix ) = fileparse( $trfile, qr/\.[^.]*/ );
|
my ( $filename, $path, $suffix ) = fileparse( $trfile, qr/\.[^.]*/ );
|
||||||
if ( $path eq "/" ) {
|
$path = "/home/" . $truser . "/";
|
||||||
$path = "/home/" . $truser . "/";
|
$trfile = "/home/" . $truser . $trfile;
|
||||||
$trfile = "/home/" . $truser . $trfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ( ( uc $suffix ) eq ( uc $ext ) )
|
if ( ( ( uc $suffix ) eq ( uc $ext ) )
|
||||||
and
|
and
|
||||||
( $filename =~ m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d*|GD\d*)$/i
|
( $filename =~ m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d*|GD\d*)$/i
|
||||||
or $filename =~ m/^(\d\d_\d\d\d\d_|)(\d\d\d\d\d\d\d\d\d\d\d\d\d\d_)(G201_ID\d\d\d\d_DT\d\d\d\d)$/i) )
|
or $filename =~ m/^G201_ID\d\d\d\d_DT\d\d\d\d_\d*$/i) )
|
||||||
{
|
{
|
||||||
my $unit = getUnitName($trfile);
|
my $unit = getUnitName($trfile);
|
||||||
print getTimeStamp("log") . " >> Unit $unit - Filename $trfile\n";
|
print getTimeStamp("log") . " >> Unit $unit - Filename $trfile\n";
|
||||||
@@ -109,7 +107,7 @@ while ( my $line = $tail->GetLine() ) {
|
|||||||
my @fname = ($dest);
|
my @fname = ($dest);
|
||||||
chown $uid, $gid, @fname;
|
chown $uid, $gid, @fname;
|
||||||
if ( ($filename =~ m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d.*|GD\d*)$/i
|
if ( ($filename =~ m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d.*|GD\d*)$/i
|
||||||
or $filename =~ m/^(\d\d_\d\d\d\d_|)(\d\d\d\d\d\d\d\d\d\d\d\d\d\d_)(G201_ID\d\d\d\d_DT\d\d\d\d)$/i)
|
or $filename =~ m/^G201_ID\d\d\d\d_DT\d\d\d\d_\d*$/i)
|
||||||
and ( $unit ne 'ID9999' )
|
and ( $unit ne 'ID9999' )
|
||||||
and ( $truser ne 'corra' ) )
|
and ( $truser ne 'corra' ) )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user