Do not delete not init modules by default.
An option has been added to the Pandora FMS Console Setup to enable the deletion of these modules.
This commit is contained in:
parent
6fa1bd78a9
commit
5a8840f375
|
@ -107,6 +107,10 @@ $table_other->data[7][1] .= __('No').' '.html_print_radio_button ('agentacc
|
||||||
$table_other->data[8][0] = __('Max. recommended number of files in attachment directory') . ui_print_help_tip(__('This number is the maximum number of files in attachment directory. If this number is reached then a warning message will appear in the header notification space.'), true);
|
$table_other->data[8][0] = __('Max. recommended number of files in attachment directory') . ui_print_help_tip(__('This number is the maximum number of files in attachment directory. If this number is reached then a warning message will appear in the header notification space.'), true);
|
||||||
$table_other->data[8][1] = html_print_input_text ('num_files_attachment', $config["num_files_attachment"], '', 5, 5, true);
|
$table_other->data[8][1] = html_print_input_text ('num_files_attachment', $config["num_files_attachment"], '', 5, 5, true);
|
||||||
|
|
||||||
|
$table_other->data[9][0] = __('Delete not init modules');
|
||||||
|
$table_other->data[9][1] = __('Yes').' '.html_print_radio_button ('delete_notinit', 1, '', $config["delete_notinit"], true).' ';
|
||||||
|
$table_other->data[9][1] .= __('No').' '.html_print_radio_button ('delete_notinit', 0, '', $config["delete_notinit"], true);
|
||||||
|
|
||||||
echo '<form id="form_setup" method="post">';
|
echo '<form id="form_setup" method="post">';
|
||||||
echo "<fieldset>";
|
echo "<fieldset>";
|
||||||
echo "<legend>" . __('Database maintenance options') . "</legend>";
|
echo "<legend>" . __('Database maintenance options') . "</legend>";
|
||||||
|
|
|
@ -359,6 +359,8 @@ function config_update_config () {
|
||||||
$error_update[] = 'Deprecated compact_header';
|
$error_update[] = 'Deprecated compact_header';
|
||||||
if (!config_update_value ('num_files_attachment', (int) get_parameter ('num_files_attachment')))
|
if (!config_update_value ('num_files_attachment', (int) get_parameter ('num_files_attachment')))
|
||||||
$error_update[] = __('Max. recommended number of files in attachment directory');
|
$error_update[] = __('Max. recommended number of files in attachment directory');
|
||||||
|
if (!config_update_value ('delete_notinit', get_parameter ('delete_notinit')))
|
||||||
|
$error_update[] = __('Delete not init modules');
|
||||||
/////////////
|
/////////////
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -676,6 +678,10 @@ function config_process_config () {
|
||||||
if (!isset ($config["realtimestats"])) {
|
if (!isset ($config["realtimestats"])) {
|
||||||
config_update_value ('realtimestats', 1);
|
config_update_value ('realtimestats', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset ($config["delete_notinit"])) {
|
||||||
|
config_update_value ('delete_notinit', 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset ($config["event_purge"])) {
|
if (!isset ($config["event_purge"])) {
|
||||||
config_update_value ('event_purge', 15);
|
config_update_value ('event_purge', 15);
|
||||||
|
|
|
@ -583,6 +583,7 @@ sub pandora_load_config ($) {
|
||||||
$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->{'_log_dir'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'log_dir'");
|
$conf->{'_log_dir'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'log_dir'");
|
||||||
$conf->{'_log_max_lifetime'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'log_max_lifetime'");
|
$conf->{'_log_max_lifetime'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'log_max_lifetime'");
|
||||||
|
$conf->{'_delete_notinit'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_notinit'");
|
||||||
|
|
||||||
db_disconnect ($dbh);
|
db_disconnect ($dbh);
|
||||||
|
|
||||||
|
@ -632,61 +633,64 @@ sub pandora_checkdb_integrity {
|
||||||
# Check database consistency.
|
# Check database consistency.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
sub pandora_checkdb_consistency {
|
sub pandora_checkdb_consistency {
|
||||||
my $dbh = shift;
|
my ($conf, $dbh) = @_;
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
# 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'} == 1) {
|
||||||
log_message ('CHECKDB', "Deleting non-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
|
||||||
FROM tagente_estado
|
FROM tagente_estado
|
||||||
WHERE estado = 4');
|
WHERE estado = 4');
|
||||||
|
|
||||||
foreach my $module (@modules) {
|
|
||||||
my $id_agente_modulo = $module->{'id_agente_modulo'};
|
|
||||||
my $id_agente = $module->{'id_agente'};
|
|
||||||
|
|
||||||
# Skip policy modules
|
foreach my $module (@modules) {
|
||||||
my $is_policy_module = enterprise_hook('is_policy_module',
|
my $id_agente_modulo = $module->{'id_agente_modulo'};
|
||||||
[$dbh, $id_agente_modulo]);
|
my $id_agente = $module->{'id_agente'};
|
||||||
next if (defined($is_policy_module) && $is_policy_module);
|
|
||||||
|
# Skip policy modules
|
||||||
# Skip if agent is disabled
|
my $is_policy_module = enterprise_hook('is_policy_module',
|
||||||
my $is_agent_disabled = get_db_value ($dbh,
|
[$dbh, $id_agente_modulo]);
|
||||||
'SELECT disabled
|
next if (defined($is_policy_module) && $is_policy_module);
|
||||||
FROM tagente
|
|
||||||
WHERE id_agente = ?', $module->{'id_agente'});
|
# Skip if agent is disabled
|
||||||
next if (defined($is_agent_disabled) && $is_agent_disabled);
|
my $is_agent_disabled = get_db_value ($dbh,
|
||||||
|
'SELECT disabled
|
||||||
# Skip if module is disabled
|
FROM tagente
|
||||||
my $is_module_disabled = get_db_value ($dbh,
|
WHERE id_agente = ?', $module->{'id_agente'});
|
||||||
'SELECT disabled
|
next if (defined($is_agent_disabled) && $is_agent_disabled);
|
||||||
FROM tagente_modulo
|
|
||||||
WHERE id_agente_modulo = ?', $module->{'id_agente_modulo'});
|
# Skip if module is disabled
|
||||||
next if (defined($is_module_disabled) && $is_module_disabled);
|
my $is_module_disabled = get_db_value ($dbh,
|
||||||
|
'SELECT disabled
|
||||||
|
FROM tagente_modulo
|
||||||
#---------------------------------------------------------------
|
WHERE id_agente_modulo = ?', $module->{'id_agente_modulo'});
|
||||||
# Delete the module
|
next if (defined($is_module_disabled) && $is_module_disabled);
|
||||||
#---------------------------------------------------------------
|
|
||||||
db_do ($dbh, 'UPDATE tagente
|
|
||||||
SET notinit_count = notinit_count - 1
|
#---------------------------------------------------------------
|
||||||
WHERE id_agente = ?', $id_agente);
|
# Delete the module
|
||||||
|
#---------------------------------------------------------------
|
||||||
db_do ($dbh,
|
db_do ($dbh, 'UPDATE tagente
|
||||||
'DELETE FROM tagente_modulo
|
SET notinit_count = notinit_count - 1
|
||||||
WHERE id_agente_modulo = ?', $id_agente_modulo);
|
WHERE id_agente = ?', $id_agente);
|
||||||
|
|
||||||
# Do a nanosleep here for 0,001 sec
|
db_do ($dbh,
|
||||||
usleep (100000);
|
'DELETE FROM tagente_modulo
|
||||||
|
WHERE id_agente_modulo = ?', $id_agente_modulo);
|
||||||
# Delete any alerts associated to the module
|
|
||||||
db_do ($dbh,
|
# Do a nanosleep here for 0,001 sec
|
||||||
'DELETE FROM talert_template_modules
|
usleep (100000);
|
||||||
WHERE id_agent_module = ?', $id_agente_modulo);
|
|
||||||
|
# Delete any alerts associated to the module
|
||||||
|
db_do ($dbh,
|
||||||
|
'DELETE FROM talert_template_modules
|
||||||
|
WHERE id_agent_module = ?', $id_agente_modulo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log_message ('CHECKDB', "Ignoring not-init data.");
|
||||||
}
|
}
|
||||||
|
|
||||||
log_message ('CHECKDB',
|
log_message ('CHECKDB',
|
||||||
|
@ -730,7 +734,7 @@ sub pandora_checkdb_consistency {
|
||||||
log_message ('CHECKDB',
|
log_message ('CHECKDB',
|
||||||
"Checking database consistency (Missing status).");
|
"Checking database consistency (Missing status).");
|
||||||
|
|
||||||
@modules = get_db_rows ($dbh, 'SELECT * FROM tagente_modulo');
|
my @modules = get_db_rows ($dbh, 'SELECT * FROM tagente_modulo');
|
||||||
foreach my $module (@modules) {
|
foreach my $module (@modules) {
|
||||||
my $id_agente_modulo = $module->{'id_agente_modulo'};
|
my $id_agente_modulo = $module->{'id_agente_modulo'};
|
||||||
my $id_agente = $module->{'id_agente'};
|
my $id_agente = $module->{'id_agente'};
|
||||||
|
@ -852,7 +856,7 @@ sub pandoradb_main ($$$) {
|
||||||
pandora_purgedb ($conf, $dbh);
|
pandora_purgedb ($conf, $dbh);
|
||||||
|
|
||||||
# Consistency check
|
# Consistency check
|
||||||
pandora_checkdb_consistency ($dbh);
|
pandora_checkdb_consistency ($conf, $dbh);
|
||||||
|
|
||||||
# Maintain Referential integrity and other stuff
|
# Maintain Referential integrity and other stuff
|
||||||
pandora_checkdb_integrity ($dbh);
|
pandora_checkdb_integrity ($dbh);
|
||||||
|
|
Loading…
Reference in New Issue