diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 06d5fdbf76..7d9122dbe5 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -4161,33 +4161,91 @@ function networkmap_get_new_nodes_and_links($networkmap, $x, $y) $agents = get_discovery_agents($id_recon, true); $relations_discovery = modules_get_relations(['id_rt' => $id_recon, 'distinct' => true]); - $relations_maps = db_get_all_rows_sql( - sprintf( - 'SELECT * FROM trel_item WHERE id_map = %s AND parent_type = 1 AND child_type = 1', - $id_networkmap - ) - ); + $array_aux = $relations_discovery; + $target_aux = $relations_discovery; - $id_recon = $id_networkmap; + foreach ($relations_discovery as $key => $rel) { + foreach ($array_aux as $key2 => $rel2) { + if ($key2 <= $key) { + continue; + } - foreach ($relations_discovery as $key => $discovery) { - foreach ($relations_maps as $key2 => $map) { - if ($map['id_parent_source_data'] == $discovery['module_a'] - && $map['id_child_source_data'] == $discovery['module_b'] - ) { - unset($relations_discovery[$key]); - unset($relations_maps[$key2]); - continue 2; - } else if ($map['id_parent_source_data'] == $discovery['module_b'] - && $map['id_child_source_data'] == $discovery['module_a'] - ) { - unset($relations_discovery[$key]); - unset($relations_maps[$key2]); - continue 2; + if ($rel['module_a'] === $rel2['module_a']) { + $agent1 = modules_get_agentmodule_agent($rel['module_b']); + $agent2 = modules_get_agentmodule_agent($rel2['module_b']); + + if ($agent1 === $agent2) { + $name1 = modules_get_agentmodule_name($rel['module_b']); + $name2 = modules_get_agentmodule_name($rel2['module_b']); + if ($name1 == 'Host Alive') { + unset($target_aux[$key]); + } else if ($name2 == 'Host Alive') { + unset($target_aux[$key2]); + } + + continue; + } + } + + if ($rel['module_b'] === $rel2['module_b']) { + $agent1 = modules_get_agentmodule_agent($rel['module_a']); + $agent2 = modules_get_agentmodule_agent($rel2['module_a']); + + if ($agent1 === $agent2) { + $name1 = modules_get_agentmodule_name($rel['module_a']); + $name2 = modules_get_agentmodule_name($rel2['module_a']); + if ($name1 == 'Host Alive') { + unset($target_aux[$key]); + } else if ($name2 == 'Host Alive') { + unset($target_aux[$key2]); + } + + continue; + } + } + + if ($rel['module_a'] === $rel2['module_b']) { + $agent1 = modules_get_agentmodule_agent($rel['module_b']); + $agent2 = modules_get_agentmodule_agent($rel2['module_a']); + + if ($agent1 === $agent2) { + $name1 = modules_get_agentmodule_name($rel['module_b']); + $name2 = modules_get_agentmodule_name($rel2['module_a']); + if ($name1 == 'Host Alive') { + unset($target_aux[$key]); + } else if ($name2 == 'Host Alive') { + unset($target_aux[$key2]); + } + + continue; + } + } + + if ($rel['module_b'] === $rel2['module_a']) { + $agent1 = modules_get_agentmodule_agent($rel['module_a']); + $agent2 = modules_get_agentmodule_agent($rel2['module_b']); + + if ($agent1 === $agent2) { + $name1 = modules_get_agentmodule_name($rel['module_a']); + $name2 = modules_get_agentmodule_name($rel2['module_b']); + if ($name1 == 'Host Alive') { + unset($target_aux[$key]); + } else if ($name2 == 'Host Alive') { + unset($target_aux[$key2]); + } + + continue; + } } } } + $relations_discovery = $target_aux; + + db_process_sql_delete('trel_item', ['id_map' => $id_networkmap, 'parent_type' => 1, 'child_type' => 1]); + + $id_recon = $id_networkmap; + // Relations Module <-> Module. foreach ($relations_discovery as $key => $relation) { $module_a = $relation['module_a']; @@ -4351,8 +4409,6 @@ function networkmap_get_new_nodes_and_links($networkmap, $x, $y) GROUP BY source_data'; $nodes = db_get_all_rows_sql($sql); - hd($nodes, true); - foreach ($nodes as $node) { // First the relation parents without l2 interfaces. $parent = db_get_value_filter( diff --git a/pandora_console/include/javascript/functions_pandora_networkmap.js b/pandora_console/include/javascript/functions_pandora_networkmap.js index 4882ccad2b..300d3f23a6 100644 --- a/pandora_console/include/javascript/functions_pandora_networkmap.js +++ b/pandora_console/include/javascript/functions_pandora_networkmap.js @@ -2505,7 +2505,7 @@ function refresh() { if (array_nodes.length === 0 && array_links.length === 0) { update_networkmap(); $("#spinner_networkmap").css("display", "none"); - startCountDown(refresh_time); + window.location = location; } else { if (array_nodes.length > 0) { $.ajax({ @@ -2531,6 +2531,7 @@ function refresh() { }, error: function(e) { $("#spinner_networkmap").css("display", "none"); + window.location = location; } }); } diff --git a/pandora_console/operation/agentes/pandora_networkmap.view.php b/pandora_console/operation/agentes/pandora_networkmap.view.php index ac888a13fa..edc3a15dd1 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.view.php +++ b/pandora_console/operation/agentes/pandora_networkmap.view.php @@ -1057,7 +1057,7 @@ if (is_ajax() === true) { if (preg_match('/(.+)_ifOperStatus$/', (string) $source_text, $matches)) { if ($matches[1]) { - $source_text = $matches[1]; + $source_text = $matches[1]; } } } else {