mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
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])) {
|
if (!isset($group_um[0])) {
|
||||||
$display_all_group = false;
|
$display_all_group = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[0] .= html_print_select(
|
$data[0] .= html_print_select(
|
||||||
profile_get_profiles(
|
profile_get_profiles(
|
||||||
[
|
[
|
||||||
@ -182,8 +183,8 @@ $info_users = [];
|
|||||||
// Is admin.
|
// Is admin.
|
||||||
if (users_is_admin()) {
|
if (users_is_admin()) {
|
||||||
$info_users = users_get_info($users_order, 'id_user');
|
$info_users = users_get_info($users_order, 'id_user');
|
||||||
// has PM permission.
|
// has PM permission.
|
||||||
} elseif (check_acl($config['id_user'], 0, 'PM')) {
|
} else if (check_acl($config['id_user'], 0, 'PM')) {
|
||||||
$info_users = users_get_info($users_order, 'id_user');
|
$info_users = users_get_info($users_order, 'id_user');
|
||||||
foreach ($info_users as $id_user => $value) {
|
foreach ($info_users as $id_user => $value) {
|
||||||
if (users_is_admin($id_user)) {
|
if (users_is_admin($id_user)) {
|
||||||
@ -197,7 +198,7 @@ if (users_is_admin()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($info as $key => $value) {
|
foreach ($info as $key => $value) {
|
||||||
if (!$value['is_admin']) {
|
if (!$value['is_admin']) {
|
||||||
$info_users[$key] = $value['id_user'];
|
$info_users[$key] = $value['id_user'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,7 @@ if (check_acl($config['id_user'], 0, 'PM')) {
|
|||||||
if (!isset($group_um[0])) {
|
if (!isset($group_um[0])) {
|
||||||
$display_all_group = false;
|
$display_all_group = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[0] .= html_print_select(
|
$data[0] .= html_print_select(
|
||||||
profile_get_profiles(
|
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);
|
$historical_string_purge = get_parameter('historical_string_purge', 0);
|
||||||
|
|
||||||
$history_connect = @mysql_db_process_sql(
|
$history_connect = @mysql_db_process_sql(
|
||||||
'SELECT 1 FROM tconfig',
|
'DESCRIBE tconfig',
|
||||||
'affected_rows',
|
'affected_rows',
|
||||||
$config['history_db_connection'],
|
$config['history_db_connection'],
|
||||||
false
|
false
|
||||||
@ -390,8 +390,8 @@ if ($config['history_db_enabled'] == 1) {
|
|||||||
|
|
||||||
$config_history = false;
|
$config_history = false;
|
||||||
if ($config['history_db_connection']) {
|
if ($config['history_db_connection']) {
|
||||||
$history_connect = @mysql_db_process_sql(
|
$history_connect = mysql_db_process_sql(
|
||||||
'SELECT 1 FROM tconfig',
|
'DESCRIBE tconfig',
|
||||||
'affected_rows',
|
'affected_rows',
|
||||||
$config['history_db_connection'],
|
$config['history_db_connection'],
|
||||||
false
|
false
|
||||||
@ -408,6 +408,7 @@ if ($config['history_db_enabled'] == 1) {
|
|||||||
if (isset($config_history_array) && is_array($config_history_array)) {
|
if (isset($config_history_array) && is_array($config_history_array)) {
|
||||||
foreach ($config_history_array as $key => $value) {
|
foreach ($config_history_array as $key => $value) {
|
||||||
$config_history[$value['token']] = $value['value'];
|
$config_history[$value['token']] = $value['value'];
|
||||||
|
$config_history = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -12,7 +12,8 @@ function updateSmartValue(event) {
|
|||||||
var keyPressed = event.keyCode;
|
var keyPressed = event.keyCode;
|
||||||
if (
|
if (
|
||||||
(keyPressed <= 48 && keyPressed >= 57) ||
|
(keyPressed <= 48 && keyPressed >= 57) ||
|
||||||
(inputElement.val() < 0 || inputElement.val() > 100)
|
inputElement.val() < 0 ||
|
||||||
|
inputElement.val() > 100
|
||||||
) {
|
) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
} else {
|
} else {
|
||||||
|
@ -581,6 +581,28 @@ sub pandora_init_pdb ($) {
|
|||||||
help_screen () if ($conf->{'_pandora_path'} eq '');
|
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.
|
# Read external configuration file.
|
||||||
@ -651,7 +673,7 @@ sub pandora_load_config_pdb ($) {
|
|||||||
$conf->{'_metaconsole_events_history'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole_events_history'");
|
$conf->{'_metaconsole_events_history'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole_events_history'");
|
||||||
$conf->{'_netflow_max_lifetime'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'netflow_max_lifetime'");
|
$conf->{'_netflow_max_lifetime'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'netflow_max_lifetime'");
|
||||||
$conf->{'_netflow_nfexpire'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'netflow_nfexpire'");
|
$conf->{'_netflow_nfexpire'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'netflow_nfexpire'");
|
||||||
$conf->{'_netflow_path'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'netflow_path'");
|
$conf->{'_netflow_path'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'netflow_path'");
|
||||||
$conf->{'_delete_notinit'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_notinit'");
|
$conf->{'_delete_notinit'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_notinit'");
|
||||||
$conf->{'_session_timeout'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'session_timeout'");
|
$conf->{'_session_timeout'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'session_timeout'");
|
||||||
|
|
||||||
@ -726,7 +748,7 @@ sub pandora_checkdb_consistency {
|
|||||||
# 1. Check for modules that do not have tagente_estado but have
|
# 1. Check for modules that do not have tagente_estado but have
|
||||||
# tagente_module
|
# 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.");
|
log_message ('CHECKDB', "Deleting not-init data.");
|
||||||
my @modules = get_db_rows ($dbh,
|
my @modules = get_db_rows ($dbh,
|
||||||
'SELECT id_agente_modulo, id_agente
|
'SELECT id_agente_modulo, id_agente
|
||||||
@ -956,7 +978,7 @@ sub pandora_delete_old_module_data {
|
|||||||
sub pandora_delete_old_export_data {
|
sub pandora_delete_old_export_data {
|
||||||
my ($dbh, $ulimit_timestamp) = @_;
|
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') {
|
while((my $rc = db_delete_limit ($dbh, 'tserver_export_data', 'UNIX_TIMESTAMP(timestamp) < ?', $SMALL_OPERATION_STEP, $ulimit_timestamp)) ne '0E0') {
|
||||||
print "RC:$rc\n";
|
print "RC:$rc\n";
|
||||||
usleep (10000);
|
usleep (10000);
|
||||||
@ -1081,8 +1103,9 @@ if ($conf{'_force'} == 0 && pandora_is_master(\%conf) == 0) {
|
|||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get a lock
|
# Get a lock on dbname.
|
||||||
my $lock = db_get_lock ($dbh, 'pandora_db');
|
my $lock_name = $conf{'dbname'};
|
||||||
|
my $lock = db_get_lock ($dbh, $lock_name);
|
||||||
if ($lock == 0 && $conf{'_force'} == 0) {
|
if ($lock == 0 && $conf{'_force'} == 0) {
|
||||||
log_message ('', " [*] Another instance of DB Tool seems to be running.\n\n");
|
log_message ('', " [*] Another instance of DB Tool seems to be running.\n\n");
|
||||||
exit 1;
|
exit 1;
|
||||||
@ -1091,9 +1114,26 @@ if ($lock == 0 && $conf{'_force'} == 0) {
|
|||||||
# Main
|
# Main
|
||||||
pandoradb_main(\%conf, $dbh, $history_dbh);
|
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
|
# Release the lock
|
||||||
if ($lock == 1) {
|
if ($lock == 1) {
|
||||||
db_release_lock ($dbh, 'pandora_db');
|
db_release_lock ($dbh, $lock_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Cleanup and exit
|
# Cleanup and exit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user