diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 62c403a812..f662f02286 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2011-07-04 Sergio Martin + + * include/functions_networkmap.php + pandoradb.sql + pandoradb.postgreSQL.sql + pandoradb.oracle.sql + operation/agentes/networkmap.topology.php + operation/agentes/ver_agente.php + operation/agentes/networkmap.php + extras/pandoradb_migrate_v3.2_to_v4.0.sql: Add to the topology + network maps a switch to show the snmp_inc modules with their + ip addresses if they have for task 3296127 + 2011-07-01 Ramon Novoa * pandoradb.sql, diff --git a/pandora_console/extras/pandoradb_migrate_v3.2_to_v4.0.sql b/pandora_console/extras/pandoradb_migrate_v3.2_to_v4.0.sql index d7c59fe9d8..f272a1ff6b 100644 --- a/pandora_console/extras/pandoradb_migrate_v3.2_to_v4.0.sql +++ b/pandora_console/extras/pandoradb_migrate_v3.2_to_v4.0.sql @@ -190,11 +190,7 @@ ALTER TABLE `tagente_modulo` ADD INDEX module(id_modulo); ALTER TABLE `tevento` ADD COLUMN (`tags` text NOT NULL); -- ----------------------------------------------------- --- Table `trecon_task` +-- Table `tnetwork_map` -- ----------------------------------------------------- -ALTER TABLE `trecon_task` ADD COLUMN (`os_detect` tinyint(1) unsigned default '0'); -ALTER TABLE `trecon_task` ADD COLUMN (`resolve_names` tinyint(1) unsigned default '0'); -ALTER TABLE `trecon_task` ADD COLUMN (`parent_detection` tinyint(1) unsigned default '0'); -ALTER TABLE `trecon_task` ADD COLUMN (`parent_recursion` tinyint(1) unsigned default '0'); - +ALTER TABLE `tnetwork_map` ADD COLUMN `show_snmp_modules` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0; diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 29706d11f8..b05f06d131 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -42,7 +42,7 @@ function networkmap_is_descendant ($node, $ascendant, $parents) { } // Generate a dot graph definition for graphviz -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) { +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) { $parents = array(); $orphans = array(); @@ -62,18 +62,45 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_ // Parse agents $nodes = array (); + $node_count = 1; + foreach ($agents as $agent) { // Save node parent information to define edges later if ($agent['id_parent'] != "0") { - $parents[$agent['id_agente']] = $agent['id_parent']; + $parents[$node_count] = $agent['id_parent']; } else { - $orphans[$agent['id_agente']] = 1; + $orphans[$node_count] = 1; } - $agent['id_node'] = $agent['id_agente']; + $agent['id_node'] = $node_count; + $agent['type'] = 'agent'; + // Add node - $nodes[$agent['id_agente']] = $agent; + $nodes[$node_count] = $agent; + + if($show_snmp_modules) { + // Get agent modules data of snmp_proc type + $modules = agents_get_modules ($agent['id_agente'], false, array('disabled' => 0, 'id_tipo_modulo' => 18), true, false); + // Parse modules + foreach ($modules as $key => $module) { + $node_count ++; + $agent_module = modules_get_agentmodule($key); + + $alerts_module = db_get_sql('SELECT count(*) as num + FROM talert_template_modules WHERE id_agent_module = '.$key); + + // Save node parent information to define edges later + $parents[$node_count] = $agent_module['parent'] = $agent['id_node']; + + $agent_module['id_node'] = $node_count; + + $agent_module['type'] = 'module'; + // Add node + $nodes[$node_count] = $agent_module; + } + } + $node_count++; } if (empty ($nodes)) { @@ -88,7 +115,14 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_ continue; } - $graph .= networkmap_create_agent_node ($node , $simple, $font_size)."\n\t\t"; + switch($node['type']){ + case 'agent': + $graph .= networkmap_create_agent_node ($node , $simple, $font_size)."\n\t\t"; + break; + case 'module': + $graph .= networkmap_create_module_node ($node , $simple, $font_size)."\n\t\t"; + break; + } } // Define edges diff --git a/pandora_console/operation/agentes/networkmap.php b/pandora_console/operation/agentes/networkmap.php index 559e18ac55..8aa7448e71 100644 --- a/pandora_console/operation/agentes/networkmap.php +++ b/pandora_console/operation/agentes/networkmap.php @@ -81,6 +81,7 @@ if($save_networkmap || $update_networkmap) { $ranksep = (float) get_parameter ('ranksep', 2.5); $simple = (int) get_parameter ('simple', 0); $regen = (int) get_parameter ('regen', 0); + $show_snmp_modules = (int) get_parameter ('show_snmp_modules', 0); $font_size = (int) get_parameter ('font_size', 12); $group = (int) get_parameter ('group', 0); $module_group = (int) get_parameter ('module_group', 0); @@ -91,7 +92,8 @@ if($save_networkmap || $update_networkmap) { $result = networkmap_update_networkmap($id_networkmap, array('name' => $name, 'type' => $activeTab, 'layout' => $layout, 'nooverlap' => $nooverlap, 'simple' => $simple, 'regenerate' => $regen, 'font_size' => $font_size, 'id_group' => $group, 'id_module_group' => $module_group, 'depth' => $depth, 'only_modules_with_alerts' => $modwithalerts, - 'hide_policy_modules' => $hidepolicymodules, 'zoom' => $zoom, 'distance_nodes' => $ranksep, 'center' => $center)); + 'hide_policy_modules' => $hidepolicymodules, 'zoom' => $zoom, 'distance_nodes' => $ranksep, 'center' => $center, + 'show_snmp_modules' => (int)$show_snmp_modules)); $message = ui_print_result_message ($result, __('Network map saved successfully'), __('Could not save network map'), '', true); @@ -129,6 +131,7 @@ if(!$update_networkmap && !$save_networkmap && $id_networkmap != 0) { $ranksep = $networkmap_data['distance_nodes']; $simple = $networkmap_data['simple']; $regen = $networkmap_data['regenerate']; + $show_snmp_modules = $networkmap_data['show_snmp_modules']; $font_size = $networkmap_data['font_size']; $group = $networkmap_data['id_group']; $module_group = $networkmap_data['id_module_group']; @@ -193,7 +196,8 @@ if(!$nomaps && $id_networkmap != 0) { &layout='.$layout.'&nooverlap='.$nooverlap.'&simple='.$simple.'&regen='.$regen.' &zoom='.$zoom.'&ranksep='.$ranksep.'&fontsize='.$font_size.'&depth='.$depth.' &modwithalerts='.$modwithalerts.'&hidepolicymodules='.$hidepolicymodules.' - &module_group='.$module_group.'&pure='.$pure.'&hidden_options='.(int)$hidden_options.'">' . + &module_group='.$module_group.'&pure='.$pure.'&hidden_options='.(int)$hidden_options.' + &show_snmp_modules='.(int)$show_snmp_modules.'">' . html_print_image("images/file.png", true, array ("title" => __('Save map'))) .''); } @@ -253,6 +257,13 @@ if($activeTab == 'groups' || $activeTab == 'policies'){ $options_form .= html_print_select_from_sql ('SELECT id_mg, name FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, true); $options_form .= ''; } + +if($activeTab == 'topology') { + $options_form .= '' . __('Show interfaces') . '
'; + $options_form .= html_print_checkbox ('show_snmp_modules', '1', $show_snmp_modules, true); + $options_form .= ''; +} + $options_form .= '' . __('Layout') . '
'; $options_form .= html_print_select ($layout_array, 'layout', $layout, '', '', '', true); $options_form .= ''; diff --git a/pandora_console/operation/agentes/networkmap.topology.php b/pandora_console/operation/agentes/networkmap.topology.php index 14e1bdebe8..5f98261d33 100644 --- a/pandora_console/operation/agentes/networkmap.topology.php +++ b/pandora_console/operation/agentes/networkmap.topology.php @@ -32,7 +32,7 @@ require_once ('include/functions_networkmap.php'); $filter = networkmap_get_filter ($layout); // Generate dot file -$graph = networkmap_generate_dot (__('Pandora FMS'), $group, $simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen, $pure, $id_networkmap); +$graph = networkmap_generate_dot (__('Pandora FMS'), $group, $simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen, $pure, $id_networkmap, $show_snmp_modules); if ($graph === false) { ui_print_error_message (__('Map could not be generated')); diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index b93c6ac5bb..4d19113e2c 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -365,6 +365,26 @@ if (is_ajax ()) { echo ''.__('Agent').': '; echo ui_print_truncate_text(modules_get_agentmodule_agent_name ($module['id_agente_modulo']),25,false,true,false).'
'; + if($module['id_tipo_modulo'] == 18) { + echo ''.__('Address').': '; + + // Get the IP/IPs from the module description + // Always the IP is the last part of the description (after the last space) + $ips = explode(' ', $module['descripcion']); + $ips = $ips[count($ips)-1]; + + $ips = explode(',', $ips); + if(count($ips) == 1) { + echo $ips[0]; + } + else { + echo ''; + } + } return; } diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql index d35804f892..a1cd9fefa1 100644 --- a/pandora_console/pandoradb.oracle.sql +++ b/pandora_console/pandoradb.oracle.sql @@ -1361,7 +1361,8 @@ CREATE TABLE tnetwork_map ( zoom BINARY_DOUBLE default 1, distance_nodes BINARY_DOUBLE default 2.5, center NUMBER(10, 0) default 0 NOT NULL, - contracted_nodes CLOB + contracted_nodes CLOB, + show_snmp_modules NUMBER(5, 0) default 0 NOT NULL ); CREATE SEQUENCE tnetwork_map_s INCREMENT BY 1 START WITH 1; diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index a9e2795685..6d8706bb03 100644 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -1111,7 +1111,8 @@ CREATE TABLE "tnetwork_map" ( "zoom" DOUBLE PRECISION default 1, "distance_nodes" DOUBLE PRECISION default 2.5, "center" INTEGER NOT NULL default 0, - "contracted_nodes" TEXT + "contracted_nodes" TEXT, + "show_snmp_modules" SMALLINT NOT NULL default 0, ); -- ----------------------------------------------------- diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 1c49b65dc1..c1f303fb78 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1178,6 +1178,7 @@ CREATE TABLE IF NOT EXISTS `tnetwork_map` ( `distance_nodes` FLOAT UNSIGNED NOT NULL DEFAULT 2.5, `center` INT UNSIGNED NOT NULL DEFAULT 0, `contracted_nodes` TEXT, + `show_snmp_modules` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`id_networkmap`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;