2011-07-04 Sergio Martin <sergio.martin@artica.es>

* 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



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4509 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2011-07-04 13:07:04 +00:00
parent fa842b0472
commit b2c7b96366
9 changed files with 94 additions and 17 deletions

View File

@ -1,3 +1,16 @@
2011-07-04 Sergio Martin <sergio.martin@artica.es>
* 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 <rnovoa@artica.es>
* pandoradb.sql,

View File

@ -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;

View File

@ -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

View File

@ -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) {
&amp;layout='.$layout.'&amp;nooverlap='.$nooverlap.'&amp;simple='.$simple.'&amp;regen='.$regen.'
&amp;zoom='.$zoom.'&amp;ranksep='.$ranksep.'&amp;fontsize='.$font_size.'&amp;depth='.$depth.'
&amp;modwithalerts='.$modwithalerts.'&amp;hidepolicymodules='.$hidepolicymodules.'
&amp;module_group='.$module_group.'&amp;pure='.$pure.'&amp;hidden_options='.(int)$hidden_options.'">' .
&amp;module_group='.$module_group.'&amp;pure='.$pure.'&amp;hidden_options='.(int)$hidden_options.'
&amp;show_snmp_modules='.(int)$show_snmp_modules.'">' .
html_print_image("images/file.png", true, array ("title" => __('Save map'))) .'</a>');
}
@ -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 .= '</td>';
}
if($activeTab == 'topology') {
$options_form .= '<td valign="top">' . __('Show interfaces') . '<br />';
$options_form .= html_print_checkbox ('show_snmp_modules', '1', $show_snmp_modules, true);
$options_form .= '</td>';
}
$options_form .= '<td valign="top">' . __('Layout') . '<br />';
$options_form .= html_print_select ($layout_array, 'layout', $layout, '', '', '', true);
$options_form .= '</td>';

View File

@ -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'));

View File

@ -365,6 +365,26 @@ if (is_ajax ()) {
echo '<strong>'.__('Agent').':</strong> ';
echo ui_print_truncate_text(modules_get_agentmodule_agent_name ($module['id_agente_modulo']),25,false,true,false).'<br />';
if($module['id_tipo_modulo'] == 18) {
echo '<strong>'.__('Address').':</strong> ';
// 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 '<ul style="display:inline;">';
foreach ($ips as $ip) {
echo "<li>$ip</li>";
}
echo '</ul>';
}
}
return;
}

View File

@ -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;

View File

@ -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,
);
-- -----------------------------------------------------

View File

@ -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;