Fixed disabled agent in bulk operations

This commit is contained in:
danielmaya 2018-02-12 17:14:54 +01:00
parent f71135a08e
commit 95c92efc6f
3 changed files with 8 additions and 5 deletions

View File

@ -135,9 +135,6 @@ if ($update_agents) {
$result = false;
foreach ($id_agents as $id_agent) {
if (!empty($values)) {
if ($config['metaconsole_agent_cache'] == 1) {
$values['update_module_count'] = 1; // Force an update of the agent cache.
}
$group_old = false;
if($values['id_grupo']){
$group_old = db_get_sql("SELECT id_grupo FROM tagente WHERE id_agente =" .$id_agent);
@ -146,6 +143,12 @@ if ($update_agents) {
$result = db_process_sql_update ('tagente',
$values,
array ('id_agente' => $id_agent));
if ($result && $config['metaconsole_agent_cache'] == 1) {
$server_name['server_name'] = db_get_sql("SELECT server_name FROM tagente WHERE id_agente =" .$id_agent);
// Force an update of the agent cache.
$result_metaconsole = agent_update_from_cache($id_agent,$values,$server_name);
}
if($group_old || $result){
if ($group_old && $group_old != null) {

View File

@ -293,7 +293,7 @@ sub pandora_server_tasks ($) {
if (($counter % 30) == 0) {
# Update module status and fired alert counts
my @agents = get_db_rows ($dbh, 'SELECT id_agente, nombre, update_module_count, update_alert_count FROM tagente WHERE (update_module_count=1 OR update_alert_count=1)');
my @agents = get_db_rows ($dbh, 'SELECT id_agente, nombre, update_module_count, update_alert_count FROM tagente WHERE disabled = 0 AND (update_module_count=1 OR update_alert_count=1)');
foreach my $agent (@agents) {
logger ($pa_config, "Updating module status and fired alert counts for agent " . $agent->{'nombre'}, 10);

View File

@ -5155,7 +5155,7 @@ sub pandora_update_agent_module_count ($$$) {
}; # Module counts by status.
# Retrieve and hash module status counts.
my @rows = get_db_rows ($dbh, 'SELECT estado, COUNT(*) AS total FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo AND tagente_modulo.id_agente=?GROUP BY estado', $agent_id);
my @rows = get_db_rows ($dbh, 'SELECT estado, COUNT(*) AS total FROM tagente_modulo, tagente_estado WHERE tagente_modulo.disabled=0 AND tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo AND tagente_modulo.id_agente=?GROUP BY estado', $agent_id);
foreach my $row (@rows) {
$counts->{$row->{'estado'}} = $row->{'total'};
$total += $row->{'total'};