This commit is contained in:
2021-07-05 22:14:13 +02:00
parent 5e4fe01a4d
commit cdb350bc23

View File

@@ -99,17 +99,21 @@ sub emailSend {
);
$msg->attr( "content-type" => "text/html" );
if ($msg->send(
if (
$msg->send(
'smtp', "smtps.aruba.it",
AuthUser => "alert\@aseltd.eu",
AuthPass => "Ase#2013!20\@bat",
Port => 465,
SSL => 1,
Debug => 0
)) {
)
)
{
print getLoggingTime() . " - $email_obj\n";
print getLoggingTime() . " - Mail sent to: $email_addr.\n";
} else {
}
else {
print getLoggingTime() . " - Error in sending mail to: $email_addr.\n";
}
}
@@ -124,7 +128,7 @@ my $dbh = DBI->connect( "DBI:mysql:$db_lar;host=$server", $username, $password )
or die getLoggingTime() . " - Could not connect to database: $DBI::errstr";
my $sth = $dbh->prepare(
'select idCompany, CompanyNameShort, idSite, SiteName, CompanyEmail, SiteAlarmEmail, SendAlarm, UnitNameId, ToolNameID, ToolState from mail_view where SiteName <> "Vobarno";'
'select idCompany, CompanyNameShort, idSite, SiteName, CompanyEmail, SiteAlarmEmail, SendAlarm, UnitNameId, ToolNameID, ToolState, ToolType from mail_view where SiteName <> "Vobarno";'
) or die getLoggingTime() . " - $DBI::errstr";
$sth->execute();
@@ -226,13 +230,49 @@ while ( my $results = $ste->fetchrow_hashref ) {
$ste->finish;
# Inizio G-FLOW
my $stwg = $dbh->prepare(
"select unit_name, tool_name, date(EventDateTime) as EventDate, count(EventDateTime) 'LettureNodi', Count(EventDateTime) 'LettureCatene', 1 'NumeroNodi' from ELABDATAGFLOW where date(EventDateTime) = subdate(curdate(),1) group by unit_name, tool_name"
) or die getLoggingTime() . " - $DBI::errstr";
$stwg->execute();
while ( my $results = $stwg->fetchrow_hashref ) {
$ToolName{ $results->{'unit_name'} . $results->{'tool_name'} }
{'LettureNodi'} = $results->{'LettureNodi'};
$ToolName{ $results->{'unit_name'} . $results->{'tool_name'} }
{'LettureCatene'} = $results->{'LettureCatene'};
$ToolName{ $results->{'unit_name'} . $results->{'tool_name'} }{'NumeroNodi'}
= $results->{'NumeroNodi'};
$ref_date = $results->{'EventDate'};
}
$stwg->finish;
my $steg = $dbh->prepare(
"select unit_name, tool_name, count(xacc) 'ErroriTotaliLetture' from ELABDATAGFLOW
where date(EventDateTime) = ? and xacc = 'Err1' group by tool_name"
) or die getLoggingTime() . " - $DBI::errstr";
$steg->bind_param( 1, $ref_date );
$steg->execute();
while ( my $results = $steg->fetchrow_hashref ) {
$ToolName{ $results->{'unit_name'} . $results->{'tool_name'} }
{'ErroriTotaliLetture'} = $results->{'ErroriTotaliLetture'};
}
$steg->finish;
# Fine G-FLOW
# Disconnect
$dbh->disconnect;
# Ciclo x email totale rilevazioni
foreach my $tool ( sort grep { /DT|PT/ } keys %ToolName ) {
if ( ! defined $ToolName{$tool}{'ToolState'} or ($ToolName{$tool}{'ToolState'} eq 'Monitoring Completed') ) {
if ( !defined $ToolName{$tool}{'ToolState'}
or ( $ToolName{$tool}{'ToolState'} eq 'Monitoring Completed' ) )
{
next; #skip dei tool nello stato del test
}