Merge branch 'ent-1495-que-el-pandora_server-error-muestre-timestamp-itwerke' into 'develop'

Ent-1495-que-el-pandora_server-error-muestre-timestamp-itwerke

Closes pandora_enterprise#1495

See merge request artica/pandorafms!6274
This commit is contained in:
Rafael Ameijeiras 2023-07-26 05:03:24 +00:00
commit 6045d92fa4
1 changed files with 20 additions and 0 deletions

View File

@ -1252,6 +1252,9 @@ sub pandoradb_main {
# Maintain Referential integrity and other stuff
pandora_checkdb_integrity ($conf, $dbh);
# Close and open error log blocks
handle_error_log_block($conf, $dbh);
# Move old data to the history DB
if (defined ($history_dbh)) {
undef ($history_dbh) unless defined (enterprise_hook ('pandora_historydb', [$dbh, $history_dbh, $conf->{'_history_db_days'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}, $conf->{'_history_db_string_days'}, $conf->{'_history_db_adv'}]));
@ -1327,6 +1330,23 @@ sub pandora_check_forgotten_discovery_tasks {
log_message('FORGOTTEN DISCOVERY TASKS', 'Step ended');
}
###############################################################################
# Opening and closing of error log blocks
###############################################################################
sub handle_error_log_block {
my ($conf, $dbh) = @_;
my $is_open = get_db_value ($dbh,"SELECT `value` FROM `tconfig` WHERE `token` = 'open_error_log'");
open (STDERR, ">> " . $conf->{'errorlog_file'}) or die " [ERROR] " . pandora_get_initial_product_name() . " can't write to Errorlog. Aborting : \n $! \n";
if (!defined ($is_open)) {
db_do($dbh, "INSERT INTO `tconfig`(`token`, `value`) VALUES ('open_error_log', 1)");
} elsif ($is_open eq 1){
print STDERR strftime ("%Y-%m-%d %H:%M:%S", localtime()) . ' - ' . $conf->{'servername'} . " pandora_db: pandora_db maintenance tasks ends\n";
}
print STDERR strftime ("%Y-%m-%d %H:%M:%S", localtime()) . ' - ' . $conf->{'servername'} . " pandora_db: pandora_db maintenance tasks starts\n";
close (STDERR);
}
# Init
pandora_init_pdb(\%conf);