mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
2014-04-01 Alejandro Gallardo <alejandro.gallardo@artica.es>
* include/functions_networkmap.php: Modified the L2 network interfaces. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9694 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
6aa08caaf6
commit
af9cf1f51a
@ -1,3 +1,8 @@
|
|||||||
|
2014-04-01 Alejandro Gallardo <alejandro.gallardo@artica.es>
|
||||||
|
|
||||||
|
* include/functions_networkmap.php: Modified the L2
|
||||||
|
network interfaces.
|
||||||
|
|
||||||
2014-03-31 Alejandro Gallardo <alejandro.gallardo@artica.es>
|
2014-03-31 Alejandro Gallardo <alejandro.gallardo@artica.es>
|
||||||
|
|
||||||
* include/functions_networkmap.php: Updated the function
|
* include/functions_networkmap.php: Updated the function
|
||||||
|
@ -281,21 +281,18 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||||||
|
|
||||||
// Parse agents
|
// Parse agents
|
||||||
$nodes = array ();
|
$nodes = array ();
|
||||||
$node_count = 1;
|
|
||||||
|
|
||||||
// Add node
|
// Add node refs
|
||||||
$node_ref = array();
|
$node_ref = array();
|
||||||
foreach ($agents as $agent) {
|
|
||||||
// Add node
|
|
||||||
$node_ref[$agent['id_agente']] = $node_count;
|
|
||||||
$node_count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$modules_node_ref = array();
|
$modules_node_ref = array();
|
||||||
|
|
||||||
$node_count = 1;
|
$node_count = 0;
|
||||||
|
|
||||||
foreach ($agents as $agent) {
|
foreach ($agents as $agent) {
|
||||||
|
$node_count++;
|
||||||
|
|
||||||
|
$node_ref[$agent['id_agente']] = $node_count;
|
||||||
|
|
||||||
// Save node parent information to define edges later
|
// Save node parent information to define edges later
|
||||||
if ($agent['id_parent'] != "0" && array_key_exists($agent['id_parent'], $node_ref)) {
|
if ($agent['id_parent'] != "0" && array_key_exists($agent['id_parent'], $node_ref)) {
|
||||||
$parents[$node_count] = $node_ref[$agent['id_parent']];
|
$parents[$node_count] = $node_ref[$agent['id_parent']];
|
||||||
@ -305,7 +302,6 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||||||
}
|
}
|
||||||
|
|
||||||
$agent['id_node'] = $node_count;
|
$agent['id_node'] = $node_count;
|
||||||
|
|
||||||
$agent['type'] = 'agent';
|
$agent['type'] = 'agent';
|
||||||
|
|
||||||
// Add node
|
// Add node
|
||||||
@ -315,7 +311,6 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||||||
|
|
||||||
$filter = array();
|
$filter = array();
|
||||||
$filter['disabled'] = 0;
|
$filter['disabled'] = 0;
|
||||||
$filter['id_tipo_modulo'] = 18; // Filter by remote_snmp_proc type
|
|
||||||
|
|
||||||
// Get agent modules data
|
// Get agent modules data
|
||||||
$modules = agents_get_modules ($agent['id_agente'], '*', $filter, true, false);
|
$modules = agents_get_modules ($agent['id_agente'], '*', $filter, true, false);
|
||||||
@ -325,7 +320,14 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||||||
// Parse modules
|
// Parse modules
|
||||||
foreach ($modules as $key => $module) {
|
foreach ($modules as $key => $module) {
|
||||||
|
|
||||||
|
if ($module['id_tipo_modulo'] != 18 && (!$l2_network || $module['id_tipo_modulo'] != 6)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$node_count ++;
|
$node_count ++;
|
||||||
|
$modules_node_ref[$module['id_agente_modulo']] = $node_count;
|
||||||
|
$module['id_node'] = $node_count;
|
||||||
|
$module['type'] = 'module';
|
||||||
|
|
||||||
// Try to get the interface name
|
// Try to get the interface name
|
||||||
if (preg_match ("/_(.+)$/" , (string)$module['nombre'], $matches)) {
|
if (preg_match ("/_(.+)$/" , (string)$module['nombre'], $matches)) {
|
||||||
@ -337,24 +339,37 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||||||
// Save node parent information to define edges later
|
// Save node parent information to define edges later
|
||||||
$parents[$node_count] = $module['parent'] = $agent['id_node'];
|
$parents[$node_count] = $module['parent'] = $agent['id_node'];
|
||||||
|
|
||||||
$modules_node_ref[$module['id_agente_modulo']] = $module['id_node'] = $node_count;
|
|
||||||
|
|
||||||
$module['type'] = 'module';
|
|
||||||
// Add node
|
// Add node
|
||||||
$nodes[$node_count] = $module;
|
$nodes[$node_count] = $module;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$node_count++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop the modules without a partner if l2_network is true
|
// Drop the modules without a partner if l2_network is true
|
||||||
// and the snmp interfaces token is false
|
// and the snmp interfaces token is false
|
||||||
if ($l2_network && ! $show_snmp_modules) {
|
if ($l2_network) {
|
||||||
foreach ($modules_node_ref as $id_module => $node_count) {
|
foreach ($modules_node_ref as $id_module => $node_count) {
|
||||||
if (! modules_relation_exists($id_module, array_keys($modules_node_ref))) {
|
if (! modules_relation_exists($id_module, array_keys($modules_node_ref))) {
|
||||||
|
if ($show_snmp_modules) {
|
||||||
|
$module_type = modules_get_agentmodule_type($id_module);
|
||||||
|
if ($module_type != 18) {
|
||||||
unset($nodes[$node_count]);
|
unset($nodes[$node_count]);
|
||||||
|
unset($orphans[$node_id]);
|
||||||
unset($parents[$node_count]);
|
unset($parents[$node_count]);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
unset($nodes[$node_count]);
|
||||||
|
unset($orphans[$node_id]);
|
||||||
|
unset($parents[$node_count]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$module_type = modules_get_agentmodule_type($id_module);
|
||||||
|
if ($module_type != 18) {
|
||||||
|
unset($nodes[$node_count]);
|
||||||
|
unset($orphans[$node_id]);
|
||||||
|
unset($parents[$node_count]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,16 +411,35 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||||||
// Define edges for the module interfaces relations
|
// Define edges for the module interfaces relations
|
||||||
if ($l2_network) {
|
if ($l2_network) {
|
||||||
// Get the remote_snmp_proc relations
|
// Get the remote_snmp_proc relations
|
||||||
$relations = modules_get_relations(array('modules_type' => 'remote_snmp_proc'));
|
$relations = modules_get_relations();
|
||||||
if ($relations === false)
|
if ($relations === false)
|
||||||
$relations = array();
|
$relations = array();
|
||||||
foreach ($relations as $key => $relation) {
|
foreach ($relations as $key => $relation) {
|
||||||
$module_a = $relation['module_a'];
|
$module_a = $relation['module_a'];
|
||||||
|
$module_a_type = modules_get_agentmodule_type($module_a);
|
||||||
|
$agent_a = modules_get_agentmodule_agent($module_a);
|
||||||
$module_b = $relation['module_b'];
|
$module_b = $relation['module_b'];
|
||||||
|
$module_b_type = modules_get_agentmodule_type($module_b);
|
||||||
|
$agent_b = modules_get_agentmodule_agent($module_b);
|
||||||
|
|
||||||
|
if ($module_a_type == 18 && $module_b_type == 18) {
|
||||||
if (isset($modules_node_ref[$module_a]) && isset($modules_node_ref[$module_b])) {
|
if (isset($modules_node_ref[$module_a]) && isset($modules_node_ref[$module_b])) {
|
||||||
$graph .= networkmap_create_edge ($modules_node_ref[$module_a], $modules_node_ref[$module_b], $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'topology', $id_networkmap);
|
$graph .= networkmap_create_edge ($modules_node_ref[$module_a], $modules_node_ref[$module_b], $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'topology', $id_networkmap);
|
||||||
}
|
}
|
||||||
|
} elseif ($module_a_type == 6 && $module_b_type == 6) {
|
||||||
|
if (isset($node_ref[$agent_a]) && isset($node_ref[$agent_b])) {
|
||||||
|
$graph .= networkmap_create_edge ($node_ref[$agent_a], $node_ref[$agent_b], $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'topology', $id_networkmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
} elseif ($module_a_type == 6 && $module_b_type == 18) {
|
||||||
|
if (isset($node_ref[$agent_a]) && isset($modules_node_ref[$module_b])) {
|
||||||
|
$graph .= networkmap_create_edge ($node_ref[$agent_a], $modules_node_ref[$module_b], $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'topology', $id_networkmap);
|
||||||
|
}
|
||||||
|
} elseif ($module_b_type == 6 && $module_a_type == 18) {
|
||||||
|
if (isset($node_ref[$agent_b]) && isset($modules_node_ref[$module_a])) {
|
||||||
|
$graph .= networkmap_create_edge ($node_ref[$agent_b], $modules_node_ref[$module_a], $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'topology', $id_networkmap);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Define edges for the orphan nodes
|
// Define edges for the orphan nodes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user