Modified the function "pandora_checkdb_consistency" to force the server to update the values of the modules status of an agent after a module deletion

This commit is contained in:
Alejandro Gallardo Escobar 2014-10-17 17:58:04 +02:00
parent 0a72ae3032
commit bf8cdcf666
1 changed files with 15 additions and 2 deletions

View File

@ -677,10 +677,13 @@ sub pandora_checkdb_consistency {
#---------------------------------------------------------------
# Delete the module
#---------------------------------------------------------------
db_do ($dbh, 'UPDATE tagente
SET notinit_count = notinit_count - 1
# Mark the agent for module and alert counters update
db_do ($dbh,
'UPDATE tagente
SET update_module_count = 1, update_alert_count = 1
WHERE id_agente = ?', $id_agente);
# Delete the module
db_do ($dbh,
'DELETE FROM tagente_modulo
WHERE id_agente_modulo = ?', $id_agente_modulo);
@ -710,6 +713,7 @@ sub pandora_checkdb_consistency {
86400 * $conf{'_days_delete_unknown'});
foreach my $module (@modules) {
my $id_agente = $module->{'id_agente'};
my $id_agente_modulo = $module->{'id_agente_modulo'};
# Skip policy modules
@ -717,12 +721,21 @@ sub pandora_checkdb_consistency {
[$dbh, $id_agente_modulo]);
next if (defined($is_policy_module) && $is_policy_module);
# Mark the agent for module and alert counters update
db_do ($dbh,
'UPDATE tagente
SET update_module_count = 1, update_alert_count = 1
WHERE id_agente = ?', $id_agente);
# Delete the module
db_do ($dbh,
'DELETE FROM tagente_modulo
WHERE disabled = 0
AND id_agente_modulo = ?', $id_agente_modulo);
# Do a nanosleep here for 0,001 sec
usleep (100000);
# Delete any alerts associated to the module
db_do ($dbh, 'DELETE FROM talert_template_modules
WHERE id_agent_module = ?