Merge branch 'ent-6652-pandora_db-en-historico' into 'develop'
Fixes in history db settings and improved pandora_db tool See merge request artica/pandorafms!3640
This commit is contained in:
commit
54c768984a
|
@ -132,6 +132,7 @@ if (check_acl($config['id_user'], 0, 'PM')) {
|
|||
if (!isset($group_um[0])) {
|
||||
$display_all_group = false;
|
||||
}
|
||||
|
||||
$data[0] .= html_print_select(
|
||||
profile_get_profiles(
|
||||
[
|
||||
|
|
|
@ -133,6 +133,7 @@ if (check_acl($config['id_user'], 0, 'PM')) {
|
|||
if (!isset($group_um[0])) {
|
||||
$display_all_group = false;
|
||||
}
|
||||
|
||||
$data[0] .= html_print_select(
|
||||
profile_get_profiles(
|
||||
[
|
||||
|
|
|
@ -64,7 +64,7 @@ if ($update_config == 1 && $config['history_db_enabled'] == 1) {
|
|||
$historical_string_purge = get_parameter('historical_string_purge', 0);
|
||||
|
||||
$history_connect = @mysql_db_process_sql(
|
||||
'SELECT 1 FROM tconfig',
|
||||
'DESCRIBE tconfig',
|
||||
'affected_rows',
|
||||
$config['history_db_connection'],
|
||||
false
|
||||
|
@ -390,8 +390,8 @@ if ($config['history_db_enabled'] == 1) {
|
|||
|
||||
$config_history = false;
|
||||
if ($config['history_db_connection']) {
|
||||
$history_connect = @mysql_db_process_sql(
|
||||
'SELECT 1 FROM tconfig',
|
||||
$history_connect = mysql_db_process_sql(
|
||||
'DESCRIBE tconfig',
|
||||
'affected_rows',
|
||||
$config['history_db_connection'],
|
||||
false
|
||||
|
@ -408,6 +408,7 @@ if ($config['history_db_enabled'] == 1) {
|
|||
if (isset($config_history_array) && is_array($config_history_array)) {
|
||||
foreach ($config_history_array as $key => $value) {
|
||||
$config_history[$value['token']] = $value['value'];
|
||||
$config_history = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -12,7 +12,8 @@ function updateSmartValue(event) {
|
|||
var keyPressed = event.keyCode;
|
||||
if (
|
||||
(keyPressed <= 48 && keyPressed >= 57) ||
|
||||
(inputElement.val() < 0 || inputElement.val() > 100)
|
||||
inputElement.val() < 0 ||
|
||||
inputElement.val() > 100
|
||||
) {
|
||||
event.preventDefault();
|
||||
} else {
|
||||
|
|
|
@ -581,6 +581,28 @@ sub pandora_init_pdb ($) {
|
|||
help_screen () if ($conf->{'_pandora_path'} eq '');
|
||||
}
|
||||
|
||||
########################################################################
|
||||
# Prepares conf read from historical database settings.
|
||||
########################################################################
|
||||
sub pandoradb_load_history_conf($) {
|
||||
my $dbh = shift;
|
||||
|
||||
my @options = get_db_rows($dbh, 'SELECT * FROM `tconfig`');
|
||||
|
||||
my %options = map
|
||||
{
|
||||
'_' . $_->{'token'} => $_->{'value'}
|
||||
} @options;
|
||||
|
||||
$options{'_days_autodisable_deletion'} = 0 unless defined ($options{'_days_autodisable_deletion'});
|
||||
$options{'_num_past_special_days'} = 0 unless defined($options{'_num_past_special_days'});
|
||||
$options{'_delete_old_network_matrix'} = 0 unless defined($options{'_delete_old_network_matrix'});
|
||||
$options{'_delete_old_messages'} = 0 unless defined($options{'_delete_old_messages'});
|
||||
$options{'_netflow_max_lifetime'} = 0 unless defined($options{'_netflow_max_lifetime'});
|
||||
$options{'claim_back_snmp_modules'} = 0 unless defined($options{'claim_back_snmp_modules'});
|
||||
|
||||
return \%options;
|
||||
}
|
||||
|
||||
########################################################################
|
||||
# Read external configuration file.
|
||||
|
@ -726,7 +748,7 @@ sub pandora_checkdb_consistency {
|
|||
# 1. Check for modules that do not have tagente_estado but have
|
||||
# tagente_module
|
||||
#-------------------------------------------------------------------
|
||||
if (defined($conf->{'_delete_notinit'}) && $conf->{'_delete_notinit'} ne "" && $conf->{'_delete_notinit'} == 1) {
|
||||
if (defined($conf->{'_delete_notinit'}) && $conf->{'_delete_notinit'} ne "" && $conf->{'_delete_notinit'} eq "1") {
|
||||
log_message ('CHECKDB', "Deleting not-init data.");
|
||||
my @modules = get_db_rows ($dbh,
|
||||
'SELECT id_agente_modulo, id_agente
|
||||
|
@ -956,7 +978,7 @@ sub pandora_delete_old_module_data {
|
|||
sub pandora_delete_old_export_data {
|
||||
my ($dbh, $ulimit_timestamp) = @_;
|
||||
|
||||
log_message ('PURGE', "Deleting old export data from tserver_export_data\n");
|
||||
log_message ('PURGE', "Deleting old export data from tserver_export_data");
|
||||
while((my $rc = db_delete_limit ($dbh, 'tserver_export_data', 'UNIX_TIMESTAMP(timestamp) < ?', $SMALL_OPERATION_STEP, $ulimit_timestamp)) ne '0E0') {
|
||||
print "RC:$rc\n";
|
||||
usleep (10000);
|
||||
|
@ -1081,8 +1103,9 @@ if ($conf{'_force'} == 0 && pandora_is_master(\%conf) == 0) {
|
|||
exit 1;
|
||||
}
|
||||
|
||||
# Get a lock
|
||||
my $lock = db_get_lock ($dbh, 'pandora_db');
|
||||
# Get a lock on dbname.
|
||||
my $lock_name = $conf{'dbname'};
|
||||
my $lock = db_get_lock ($dbh, $lock_name);
|
||||
if ($lock == 0 && $conf{'_force'} == 0) {
|
||||
log_message ('', " [*] Another instance of DB Tool seems to be running.\n\n");
|
||||
exit 1;
|
||||
|
@ -1091,9 +1114,26 @@ if ($lock == 0 && $conf{'_force'} == 0) {
|
|||
# Main
|
||||
pandoradb_main(\%conf, $dbh, $history_dbh);
|
||||
|
||||
# history_dbh is unset in pandoradb_main if not in use.
|
||||
if (defined($history_dbh)) {
|
||||
log_message('', " [>] DB Tool running on historical database.\n");
|
||||
my $h_conf = pandoradb_load_history_conf($history_dbh);
|
||||
|
||||
# Keep base settings.
|
||||
$h_conf->{'_onlypurge'} = $conf{'_onlypurge'};
|
||||
|
||||
# Re-launch maintenance process for historical database.
|
||||
pandoradb_main(
|
||||
$h_conf,
|
||||
$history_dbh,
|
||||
undef
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
# Release the lock
|
||||
if ($lock == 1) {
|
||||
db_release_lock ($dbh, 'pandora_db');
|
||||
db_release_lock ($dbh, $lock_name);
|
||||
}
|
||||
|
||||
# Cleanup and exit
|
||||
|
|
Loading…
Reference in New Issue