diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e7675aaca9..95a6948452 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,15 @@ +2014-07-17 Miguel de Dios + + * include/functions_groups.php: added parameter to avoid the check + the propagation in the function "groups_get_childrens". + + * include/functions_networkmap.php, + operation/agentes/networkmap.php, + operation/agentes/networkmap.topology.php: added feature to show the + agents in subgroups (or not). + + INCIDENT: #1018 + 2014-07-14 Vanessa Gil * godmode/admin_access_log.php diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 74f4cf4cc8..e3d5907e13 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -236,7 +236,7 @@ function groups_check_used($idGroup) { * @param integer $parent The id_group parent to search the childrens. * @param array $groups The groups, its for optimize the querys to DB. */ -function groups_get_childrens($parent, $groups = null) { +function groups_get_childrens($parent, $groups = null, $onlyPropagate = false) { if (empty($groups)) { $groups = db_get_all_rows_in_table('tgrupo'); } @@ -248,7 +248,7 @@ function groups_get_childrens($parent, $groups = null) { continue; } - if ($group['propagate']) { + if ($group['propagate'] || $onlyPropagate) { if ($group['parent'] == $parent) { $return = $return + array($group['id_grupo'] => $group) + groups_get_childrens($group['id_grupo'], $groups); } diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 36d250689b..21a588c04f 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -233,7 +233,8 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0, $zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0, $id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true, - $relative = false, $text_filter = '', $l2_network = false, $ip_mask = null) { + $relative = false, $text_filter = '', $l2_network = false, $ip_mask = null, + $dont_show_subgroups = false) { global $config; @@ -262,7 +263,20 @@ function networkmap_generate_dot ($pandora_name, $group = 0, } if ($group >= 1) { - $filter['id_grupo'] = $group; + if ($dont_show_subgroups) + $filter['id_grupo'] = $group; + else { + $childrens = groups_get_childrens($group, null, true); + if (!empty($childrens)) { + $childrens = array_keys($childrens); + + $filter['id_grupo'] = $childrens; + $filter['id_grupo'][] = $group; + } + else { + $filter['id_grupo'] = $group; + } + } //Order by id_parent ascendant for to avoid the bugs //because the first agents to process in the next @@ -589,7 +603,13 @@ function networkmap_generate_dot ($pandora_name, $group = 0, } // Generate a dot graph definition for graphviz with groups -function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0, $zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0, $modwithalerts = 0, $module_group = 0, $hidepolicymodules = 0, $depth = 'all', $id_networkmap = 0, $dont_show_subgroups = 0, $text_filter = '') { +function networkmap_generate_dot_groups ($pandora_name, $group = 0, + $simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0, + $zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0, + $modwithalerts = 0, $module_group = 0, $hidepolicymodules = 0, + $depth = 'all', $id_networkmap = 0, $dont_show_subgroups = 0, + $text_filter = '') { + global $config; $parents = array(); @@ -682,7 +702,8 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, // Get agents data $agents = agents_get_agents ($filter, array ('id_grupo, nombre, id_os, id_agente, - normal_count, warning_count, critical_count, unknown_count, total_count, notinit_count')); + normal_count, warning_count, critical_count, + unknown_count, total_count, notinit_count')); if ($agents === false) $agents = array(); diff --git a/pandora_console/operation/agentes/networkmap.php b/pandora_console/operation/agentes/networkmap.php index f799675f3f..d0bd1f6500 100644 --- a/pandora_console/operation/agentes/networkmap.php +++ b/pandora_console/operation/agentes/networkmap.php @@ -230,14 +230,14 @@ if (check_acl ($config['id_user'], 0, "AW")) { $buttons['addmap'] = array('active' => $activeTab == false, 'text' => '' . html_print_image("images/add_mc.png", true, array ("title" => __('Add map'))) .''); - + if (!$nomaps && $id_networkmap != 0) { $buttons['deletemap'] = array('active' => $activeTab == false, 'text' => '' . html_print_image("images/delete_mc.png", true, array ("title" => __('Delete map'))) .''); - + $buttons['savemap'] = array('active' => $activeTab == false, - 'text' => 'width = '98%'; $table->class = 'databox'; $table->data = array(); $table->data[0][] = __('Name:') . ' ' . @@ -329,7 +329,9 @@ $table->data[0][] = __('Group:') . ' ' . html_print_select_groups(false, 'AR', false, 'group', $group, '', 'All', 0, true); if ($activeTab == 'groups' || $activeTab == 'policies') { $table->data[0][] = __('Module group') . ' ' . - html_print_select_from_sql ('SELECT id_mg, name FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, true); + html_print_select_from_sql (' + SELECT id_mg, name + FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, true); } if ($activeTab == 'topology') { @@ -411,7 +413,7 @@ if ($activeTab != 'dinamic') { $table->data[2][] = __('Free text for search (*):') . ' ' . html_print_input_text('text_filter', $text_filter, '', 30, 100, true); -if ($activeTab == 'groups') { +if (($activeTab == 'groups') || ($activeTab == 'topology')) { $table->data[2][] = __('Don\'t show subgroups:') . ui_print_help_tip(__('Only run with it is filter for any group'), true) . ' ' . diff --git a/pandora_console/operation/agentes/networkmap.topology.php b/pandora_console/operation/agentes/networkmap.topology.php index 1b92297469..1f5cba4339 100644 --- a/pandora_console/operation/agentes/networkmap.topology.php +++ b/pandora_console/operation/agentes/networkmap.topology.php @@ -39,7 +39,7 @@ if (!isset($text_filter)) { $graph = networkmap_generate_dot(__('Pandora FMS'), $group, $simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen, $pure, $id_networkmap, $show_snmp_modules, true, true, - $text_filter, $l2_network); + $text_filter, $l2_network, null, $dont_show_subgroups); if ($graph === false) { ui_print_error_message (__('Map could not be generated'));