diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index 016af0f09f..eead79c04e 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -306,7 +306,7 @@ sub pandora_server_tasks ($) { } if ($agent->{'update_alert_count'} == 1) { - pandora_update_agent_alert_count ($dbh, $agent->{'id_agente'}); + pandora_update_agent_alert_count ($pa_config, $dbh, $agent->{'id_agente'}); } } diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 9d6535807e..d81edc1b55 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -4806,12 +4806,15 @@ sub pandora_update_agent_module_count ($$$) { ########################################################################## # Update the fired alert count of an agent. ########################################################################## -sub pandora_update_agent_alert_count ($$) { - my ($dbh, $agent_id) = @_; +sub pandora_update_agent_alert_count ($$$) { + my ($pa_config, $dbh, $agent_id) = @_; db_do ($dbh, 'UPDATE tagente SET update_alert_count=0, fired_count=(SELECT COUNT(*) FROM tagente_modulo, talert_template_modules WHERE tagente_modulo.disabled=0 AND tagente_modulo.id_agente_modulo=talert_template_modules.id_agent_module AND talert_template_modules.disabled=0 AND times_fired>0 AND id_agente=' . $agent_id . ') WHERE id_agente = ' . $agent_id); + + # Sync the agent cache every time the module count is updated. + enterprise_hook('update_agent_cache', [$pa_config, $dbh, $agent_id]) if ($pa_config->{'metaconsole_agent_cache'} == 1); } ########################################################################