New networkmaps in progress... (hells commit with magic to fix the interface links)
This commit is contained in:
parent
c576134821
commit
446063dd51
|
@ -42,7 +42,6 @@ function networkmap_is_descendant ($node, $ascendant, $parents) {
|
|||
return networkmap_is_descendant ($parents[$node], $ascendant, $parents);
|
||||
}
|
||||
|
||||
|
||||
function networkmap_print_jsdata($graph, $js_tags = true) {
|
||||
if ($js_tags) {
|
||||
echo "<script type='text/javascript'>";
|
||||
|
@ -237,12 +236,16 @@ function networkmap_get_nodes_and_links($pandora_name, $group = 0,
|
|||
|
||||
global $config;
|
||||
|
||||
$l2_network = true;
|
||||
$l2_network_or_mixed == "mix_l2_l3";
|
||||
/*
|
||||
if ($l2_network_or_mixed === 'mix_l2_l3') {
|
||||
$l2_network = true;
|
||||
}
|
||||
else {
|
||||
$l2_network = $l2_network_or_mixed;
|
||||
}
|
||||
*/
|
||||
|
||||
if ($l2_network) {
|
||||
$nooverlap = 1;
|
||||
|
@ -475,15 +478,12 @@ function networkmap_get_nodes_and_links($pandora_name, $group = 0,
|
|||
if ($show_agents) {
|
||||
// Parse agents
|
||||
|
||||
|
||||
// Add node refs
|
||||
$node_ref = array();
|
||||
$modules_node_ref = array();
|
||||
|
||||
$module_groups = array();
|
||||
|
||||
|
||||
|
||||
foreach ($agents as $agent) {
|
||||
$node_count++;
|
||||
|
||||
|
@ -531,9 +531,6 @@ function networkmap_get_nodes_and_links($pandora_name, $group = 0,
|
|||
|
||||
$module_groups[$agent['id_node']] = array();
|
||||
|
||||
|
||||
|
||||
|
||||
// Parse modules
|
||||
foreach ($modules as $key => $module) {
|
||||
|
||||
|
@ -569,8 +566,6 @@ function networkmap_get_nodes_and_links($pandora_name, $group = 0,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// Show module groups
|
||||
if ($show_modulegroup) {
|
||||
|
||||
|
@ -606,8 +601,6 @@ function networkmap_get_nodes_and_links($pandora_name, $group = 0,
|
|||
$module_group['parent'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Change the status to module group to worst
|
||||
//~ $status = modules_get_agentmodule_status(
|
||||
//~ $module['id_agente_modulo'],
|
||||
|
@ -657,9 +650,6 @@ function networkmap_get_nodes_and_links($pandora_name, $group = 0,
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$module['parent'] = $id_node_module_group;
|
||||
|
||||
$parents[$module['id_node']] =
|
||||
|
@ -683,8 +673,7 @@ function networkmap_get_nodes_and_links($pandora_name, $group = 0,
|
|||
}
|
||||
} // End if ($show_agents)
|
||||
|
||||
|
||||
|
||||
$l2_network_or_mixed = 'mix_l2_l3';
|
||||
// Drop the modules without a partner if l2_network is true
|
||||
// and the snmp interfaces token is false
|
||||
if ($l2_network_or_mixed === 'mix_l2_l3') {
|
||||
|
@ -697,10 +686,7 @@ function networkmap_get_nodes_and_links($pandora_name, $group = 0,
|
|||
if ($show_snmp_modules) {
|
||||
$module_type = modules_get_agentmodule_type($id_module);
|
||||
if ($module_type != 18) {
|
||||
|
||||
|
||||
unset($nodes[$node_count]);
|
||||
unset($orphans[$node_count]);
|
||||
unset($parents[$node_count]);
|
||||
}
|
||||
}
|
||||
|
@ -731,7 +717,6 @@ function networkmap_get_nodes_and_links($pandora_name, $group = 0,
|
|||
if ($agent['id_parent'] != "0" &&
|
||||
array_key_exists($agent['id_parent'], $node_ref)) {
|
||||
|
||||
|
||||
$parents[$node_ref[$agent['id_agente']]] = $node_ref[$agent['id_parent']];
|
||||
}
|
||||
else {
|
||||
|
@ -775,7 +760,6 @@ function networkmap_get_nodes_and_links($pandora_name, $group = 0,
|
|||
if ($agent['id_parent'] != "0" &&
|
||||
array_key_exists($agent['id_parent'], $node_ref)) {
|
||||
|
||||
|
||||
$parents[$node_ref[$agent['id_agente']]] = $node_ref[$agent['id_parent']];
|
||||
}
|
||||
else {
|
||||
|
@ -784,9 +768,6 @@ function networkmap_get_nodes_and_links($pandora_name, $group = 0,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$stats = array();
|
||||
$edges = array();
|
||||
|
||||
|
@ -817,10 +798,6 @@ function networkmap_get_nodes_and_links($pandora_name, $group = 0,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Define edges
|
||||
foreach ($parents as $node => $parent_id) {
|
||||
// Verify that the parent is in the graph
|
||||
|
@ -1096,43 +1073,263 @@ 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_or_mixed = false,
|
||||
$ip_mask = null, $dont_show_subgroups = false, $strict_user = false,
|
||||
$size_canvas = null, $old_mode = false, $id_tag = 0,
|
||||
$show_all_modules = false, $only_modules_alerts = false,
|
||||
$filter_module_group = 0, $show_modulegroup = false,
|
||||
$show_groups = false, $show_agents = true, $show_policies = false) {
|
||||
$relative = false, $text_filter = '', $l2_network = false, $ip_mask = null,
|
||||
$dont_show_subgroups = false, $strict_user = false, $size_canvas = null,
|
||||
$old_mode = false) {
|
||||
|
||||
$networkmap_data = networkmap_get_nodes_and_links($pandora_name,
|
||||
$group, $simple, $font_size, $layout, $nooverlap, $zoom,
|
||||
$ranksep, $center, $regen, $pure, $id_networkmap,
|
||||
$show_snmp_modules, $cut_names, $relative, $text_filter,
|
||||
$l2_network_or_mixed, $ip_mask, $dont_show_subgroups,
|
||||
$strict_user, $size_canvas, $old_mode, $id_tag,
|
||||
$show_all_modules, $only_modules_alerts, $filter_module_group,
|
||||
$show_modulegroup, $show_groups, $show_agents, $show_policies);
|
||||
|
||||
if ($l2_network_or_mixed === 'mix_l2_l3') {
|
||||
$l2_network = true;
|
||||
}
|
||||
else {
|
||||
$l2_network = $l2_network_or_mixed;
|
||||
}
|
||||
global $config;
|
||||
|
||||
if ($l2_network) {
|
||||
$nooverlap = 1;
|
||||
}
|
||||
$parents = array();
|
||||
$orphans = array();
|
||||
|
||||
$filter = array ();
|
||||
$filter['disabled'] = 0;
|
||||
|
||||
if (!empty($text_filter)) {
|
||||
switch ($config['dbtype']) {
|
||||
case "mysql":
|
||||
case "postgresql":
|
||||
$filter[] =
|
||||
'(nombre COLLATE utf8_general_ci LIKE "%' . $text_filter . '%")';
|
||||
break;
|
||||
case "oracle":
|
||||
$filter[] =
|
||||
'(upper(nombre) LIKE upper(\'%' . $text_filter . '%\'))';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($group >= 1) {
|
||||
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
|
||||
//foreach loop are without parent (id_parent = 0)
|
||||
|
||||
// Get agents data
|
||||
if ($strict_user) {
|
||||
if ($dont_show_subgroups)
|
||||
$filter['id_group'] = $group;
|
||||
else {
|
||||
if (!empty($childrens)) {
|
||||
foreach ($childrens as $children) {
|
||||
$filter_id_groups[$children] = $children;
|
||||
}
|
||||
}
|
||||
$filter_id_groups[$group] = $group;
|
||||
$filter['id_group'] = implode(',', $filter_id_groups);
|
||||
}
|
||||
|
||||
$filter['group_by'] = 'tagente.id_agente';
|
||||
$fields = array ('tagente.id_grupo, tagente.nombre, tagente.id_os, tagente.id_parent, tagente.id_agente,
|
||||
tagente.normal_count, tagente.warning_count, tagente.critical_count,
|
||||
tagente.unknown_count, tagente.total_count, tagente.notinit_count');
|
||||
$acltags = tags_get_user_module_and_tags ($config['id_user'],'AR', $strict_user);
|
||||
$agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
|
||||
}
|
||||
else {
|
||||
$agents = agents_get_agents ($filter,
|
||||
array ('id_grupo, nombre, id_os, id_parent, id_agente,
|
||||
normal_count, warning_count, critical_count,
|
||||
unknown_count, total_count, notinit_count'), 'AR',
|
||||
array('field' => 'id_parent', 'order' => 'ASC'));
|
||||
}
|
||||
|
||||
}
|
||||
else if ($group == -666) {
|
||||
$agents = false;
|
||||
}
|
||||
else if (!empty($ip_mask)) {
|
||||
$agents = networkmap_get_new_nodes_from_ip_mask($ip_mask,
|
||||
array ('id_grupo, nombre, id_os, id_parent, id_agente,
|
||||
normal_count, warning_count, critical_count,
|
||||
unknown_count, total_count, notinit_count'), $strict_user);
|
||||
}
|
||||
else {
|
||||
//Order by id_parent ascendant for to avoid the bugs
|
||||
//because the first agents to process in the next
|
||||
//foreach loop are without parent (id_parent = 0)
|
||||
|
||||
if ($strict_user) {
|
||||
$filter['group_by'] = 'tagente.id_agente';
|
||||
$fields = array ('tagente.id_grupo, tagente.nombre, tagente.id_os, tagente.id_parent, tagente.id_agente,
|
||||
tagente.normal_count, tagente.warning_count, tagente.critical_count,
|
||||
tagente.unknown_count, tagente.total_count, tagente.notinit_count');
|
||||
$acltags = tags_get_user_module_and_tags ($config['id_user'],'AR', $strict_user);
|
||||
$agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
|
||||
}
|
||||
else {
|
||||
$agents = agents_get_agents ($filter,
|
||||
array ('id_grupo, nombre, id_os, id_parent, id_agente,
|
||||
normal_count, warning_count, critical_count,
|
||||
unknown_count, total_count, notinit_count'), 'AR',
|
||||
array('field' => 'id_parent', 'order' => 'ASC'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($agents === false)
|
||||
//return false;
|
||||
$agents = array();
|
||||
|
||||
// Open Graph
|
||||
$graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom,
|
||||
$ranksep, $font_size, $size_canvas);
|
||||
|
||||
//The orphans
|
||||
// Parse agents
|
||||
$nodes = array ();
|
||||
|
||||
// Add node refs
|
||||
$node_ref = array();
|
||||
$modules_node_ref = array();
|
||||
|
||||
$node_count = 0;
|
||||
|
||||
foreach ($agents as $agent) {
|
||||
$node_count++;
|
||||
|
||||
$node_ref[$agent['id_agente']] = $node_count;
|
||||
|
||||
$agent['id_node'] = $node_count;
|
||||
$agent['type'] = 'agent';
|
||||
|
||||
// Add node
|
||||
$nodes[$node_count] = $agent;
|
||||
|
||||
if ($l2_network || $show_snmp_modules) {
|
||||
|
||||
$filter = array();
|
||||
$filter['disabled'] = 0;
|
||||
|
||||
// Get agent modules data
|
||||
if ($strict_user) {
|
||||
$modules = tags_get_agent_modules ($agent['id_agente'], false, $acltags, false, $filter, false);
|
||||
}
|
||||
else {
|
||||
$modules = agents_get_modules($agent['id_agente'], '*', $filter, true, true);
|
||||
}
|
||||
|
||||
if ($modules === false)
|
||||
$modules = array();
|
||||
|
||||
// Parse modules
|
||||
foreach ($modules as $key => $module) {
|
||||
|
||||
if ($module['id_tipo_modulo'] != 18 &&
|
||||
(!$l2_network || $module['id_tipo_modulo'] != 6)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$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
|
||||
if (preg_match ("/_(.+)$/" , (string)$module['nombre'], $matches)) {
|
||||
if ($matches[1]) {
|
||||
$module['nombre'] = $matches[1];
|
||||
}
|
||||
}
|
||||
|
||||
// Save node parent information to define edges later
|
||||
$parents[$node_count] = $module['parent'] = $agent['id_node'];
|
||||
|
||||
// Add node
|
||||
$nodes[$node_count] = $module;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Drop the modules without a partner if l2_network is true
|
||||
// and the snmp interfaces token is false
|
||||
if ($l2_network) {
|
||||
foreach ($modules_node_ref as $id_module => $node_count) {
|
||||
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($orphans[$node_count]);
|
||||
unset($parents[$node_count]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
unset($nodes[$node_count]);
|
||||
unset($orphans[$node_count]);
|
||||
unset($parents[$node_count]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$module_type = modules_get_agentmodule_type($id_module);
|
||||
if ($module_type != 18) {
|
||||
unset($nodes[$node_count]);
|
||||
unset($orphans[$node_count]);
|
||||
unset($parents[$node_count]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Addded the relationship of parents of agents
|
||||
foreach ($agents as $agent) {
|
||||
if ($agent['id_parent'] != "0" &&
|
||||
array_key_exists($agent['id_parent'], $node_ref)) {
|
||||
|
||||
$parents[$node_ref[$agent['id_agente']]] = $node_ref[$agent['id_parent']];
|
||||
}
|
||||
else {
|
||||
$orphans[$node_ref[$agent['id_agente']]] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create void statistics array
|
||||
$stats = array();
|
||||
|
||||
// Create nodes
|
||||
foreach ($nodes as $node_id => $node) {
|
||||
if ($center > 0 && ! networkmap_is_descendant ($node_id, $center, $parents)) {
|
||||
unset ($parents[$node_id]);
|
||||
unset ($orphans[$node_id]);
|
||||
unset ($nodes[$node_id]);
|
||||
continue;
|
||||
}
|
||||
|
||||
switch ($node['type']) {
|
||||
case 'agent':
|
||||
$graph .= networkmap_create_agent_node($node, $simple,
|
||||
$font_size, $cut_names, $relative) . "\n\t\t";
|
||||
$stats['agents'][] = $node['id_agente'];
|
||||
break;
|
||||
case 'module':
|
||||
$graph .= networkmap_create_module_node($node, $simple,
|
||||
$font_size) . "\n\t\t";
|
||||
$stats['modules'][] = $node['id_agente_modulo'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($l2_network || $old_mode) {
|
||||
$count = 0;
|
||||
$group_nodes = 10;
|
||||
$graph .= networkmap_create_transparent_node($count);
|
||||
foreach (array_keys($networkmap_data['orphans']) as $node) {
|
||||
foreach (array_keys($orphans) as $node) {
|
||||
if ($group_nodes == 0) {
|
||||
$count++;
|
||||
$graph .= networkmap_create_transparent_node($count);
|
||||
|
@ -1148,58 +1345,22 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||
}
|
||||
else {
|
||||
// Create a central node if orphan nodes exist
|
||||
if (count ($networkmap_data['$orphans']) || empty ($nodes)) {
|
||||
if (count ($orphans) || empty ($nodes)) {
|
||||
$graph .= networkmap_create_pandora_node ($pandora_name, $font_size, $simple, $stats);
|
||||
}
|
||||
|
||||
// Define edges for orphan nodes
|
||||
foreach (array_keys($networkmap_data['orphans']) as $node) {
|
||||
foreach (array_keys($orphans) as $node) {
|
||||
$graph .= networkmap_create_edge ('0', $node, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'topology', $id_networkmap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Create nodes
|
||||
foreach ($networkmap_data['nodes'] as $node_id => $node) {
|
||||
switch ($node['type']) {
|
||||
// Policy
|
||||
case 4:
|
||||
if (enterprise_installed()) {
|
||||
enterprise_include_once("include/functions_policies.php");
|
||||
$graph .= policies_create_node($node, $simple, $font_size)."\n\t\t";
|
||||
}
|
||||
break;
|
||||
// Group
|
||||
case 2:
|
||||
$graph .= networkmap_create_group_node ($node , $simple, $font_size, $metaconsole = false, null, $strict_user) .
|
||||
"\n\t\t";
|
||||
break;
|
||||
// Agent
|
||||
case 0:
|
||||
$graph .= networkmap_create_agent_node($node, $simple,
|
||||
$font_size, $cut_names, $relative) . "\n\t\t";
|
||||
break;
|
||||
// Module
|
||||
case 1:
|
||||
$graph .= networkmap_create_module_node($node, $simple,
|
||||
$font_size) . "\n\t\t";
|
||||
break;
|
||||
// Module group
|
||||
case 3:
|
||||
$graph .= networkmap_create_module_group_node ($node , $simple, $font_size, true, $node['id_server']) . "\n\t\t";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Define edges
|
||||
foreach ($networkmap_data['edges'] as $id_child => $id_parent) {
|
||||
if (!is_array($id_parent)) {
|
||||
$id_parent = (array)$id_parent;
|
||||
}
|
||||
|
||||
foreach ($id_parent as $id_p) {
|
||||
$graph .= networkmap_create_edge ($id_p,
|
||||
$id_child,
|
||||
foreach ($parents as $node => $parent_id) {
|
||||
// Verify that the parent is in the graph
|
||||
if (isset ($nodes[$parent_id])) {
|
||||
$graph .= networkmap_create_edge ($parent_id,
|
||||
$node,
|
||||
$layout,
|
||||
$nooverlap,
|
||||
$pure,
|
||||
|
@ -1213,6 +1374,107 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||
'topology',
|
||||
$id_networkmap);
|
||||
}
|
||||
else {
|
||||
$orphans[$node] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Define edges for the module interfaces relations
|
||||
// Get the remote_snmp_proc relations
|
||||
if ($l2_network) {
|
||||
$relations = modules_get_relations();
|
||||
if ($relations === false)
|
||||
$relations = array();
|
||||
foreach ($relations as $key => $relation) {
|
||||
$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_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])) {
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Close graph
|
||||
|
@ -1221,21 +1483,6 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||
return $graph;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 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,
|
||||
|
|
|
@ -74,7 +74,7 @@ function networkmap_process_networkmap($id = 0) {
|
|||
$show_snmp_modules = false;
|
||||
|
||||
// NO CONTEMPLADO
|
||||
$l2_network_interfaces = false;
|
||||
$l2_network_interfaces = true;
|
||||
/*
|
||||
if (isset($options['l2_network_interfaces']))
|
||||
$l2_network_interfaces = (bool)$options['l2_network_interfaces'];
|
||||
|
@ -183,7 +183,6 @@ function networkmap_process_networkmap($id = 0) {
|
|||
$nodes_and_relations['nodes'][$index]['id_map'] = $id;
|
||||
$nodes_and_relations['nodes'][$index]['x'] = (int)$node['coords'][0];
|
||||
$nodes_and_relations['nodes'][$index]['y'] = (int)$node['coords'][1];
|
||||
$nodes_and_relations['nodes'][$index]['type'] = $node['type'];
|
||||
$style['shape'] = 'circle';
|
||||
$style['image'] = $node['image'];
|
||||
$style['width'] = $node['width'];
|
||||
|
@ -192,9 +191,12 @@ function networkmap_process_networkmap($id = 0) {
|
|||
$nodes_and_relations['nodes'][$index]['style'] = json_encode($style);
|
||||
if ($node['type'] == 'agent') {
|
||||
$nodes_and_relations['nodes'][$index]['source_data'] = $node['id_agent'];
|
||||
$nodes_and_relations['nodes'][$index]['type'] = 0;
|
||||
}
|
||||
else {
|
||||
$nodes_and_relations['nodes'][$index]['source_data'] = $node['id_module'];
|
||||
$nodes_and_relations['nodes'][$index]['id_agent'] = $node['id_agent'];
|
||||
$nodes_and_relations['nodes'][$index]['type'] = 1;
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
|
@ -212,7 +214,6 @@ function networkmap_process_networkmap($id = 0) {
|
|||
|
||||
$center = array('x' => 500, 'y' => 500);
|
||||
}
|
||||
|
||||
$networkmap['center_x'] = $center['x'];
|
||||
$networkmap['center_y'] = $center['y'];
|
||||
db_process_sql_update('tmap',
|
||||
|
@ -267,9 +268,10 @@ function networkmap_db_node_to_js_node($node, &$count, &$count_item_holding_area
|
|||
}
|
||||
else if ((int)$node['type'] == 1) {
|
||||
$item['type'] = 1;
|
||||
$item['id_agent'] = "";
|
||||
$item['id_agent'] = (int)$node['style']['id_agent'];
|
||||
$item['id_module'] = (int)$node['source_data'];
|
||||
}else if ((int)$node['type'] == 3) {
|
||||
}
|
||||
else if ((int)$node['type'] == 3) {
|
||||
$item['type'] = 3;
|
||||
$item['id_agent'] = "";
|
||||
$item['id_module'] = "";
|
||||
|
@ -409,11 +411,39 @@ function networkmap_links_to_js_links($relations, $nodes_graph) {
|
|||
$return = array();
|
||||
|
||||
foreach ($relations as $relation) {
|
||||
if (($relation['parent_type'] == 1) && ($relation['child_type'] == 1)) {
|
||||
$id_module1 = $relation['id_agent_parent'];
|
||||
$id_module2 = $relation['id_agent_child'];
|
||||
$id_agent1 = agents_get_agent_id_by_module_id($id_module1);
|
||||
$id_agent2 = agents_get_agent_id_by_module_id($id_module2);
|
||||
foreach ($nodes_graph as $node) {
|
||||
if (($id_agent1 == $node['id_agent']) && ($node['id_module'] == "")) {
|
||||
$id_agent_parent = $node["id_db"];
|
||||
}
|
||||
if (($id_agent2 == $node['id_agent']) && ($node['id_module'] == "")) {
|
||||
$id_agent_child = $node["id_db"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (enterprise_installed()) {
|
||||
enterprise_include_once("include/functions_pandora_networkmap.php");
|
||||
|
||||
$id_target = get_id_target($relation['id_parent']);
|
||||
$id_source = get_id_source($relation['id_child']);
|
||||
$id_target_a = "";
|
||||
$id_source_a = "";
|
||||
if ($relation['parent_type'] == 1) {
|
||||
$id_target_a = get_agent_id($relation['id_parent'], $nodes_graph);
|
||||
$id_target = get_id_target($relation['id_parent']);
|
||||
}
|
||||
else {
|
||||
$id_target_a = get_id_target($relation['id_parent']);
|
||||
}
|
||||
if ($relation['child_type'] == 1) {
|
||||
$id_source_a = get_agent_id($relation['id_child'], $nodes_graph);
|
||||
$id_source = get_id_source($relation['id_child']);
|
||||
}
|
||||
else {
|
||||
$id_source_a = get_id_source($relation['id_child']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($nodes_graph as $node) {
|
||||
|
@ -425,6 +455,7 @@ function networkmap_links_to_js_links($relations, $nodes_graph) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
$item = array();
|
||||
$item['id_db'] = $relation['id'];
|
||||
$item['arrow_start'] = '';
|
||||
|
@ -432,13 +463,19 @@ function networkmap_links_to_js_links($relations, $nodes_graph) {
|
|||
$item['status_start'] = '';
|
||||
$item['status_end'] = '';
|
||||
$item['id_module_start'] = 0;
|
||||
$item['id_agent_start'] = $id_source;
|
||||
$item['id_agent_start'] = $id_source_a;
|
||||
$item['id_module_end'] = 0;
|
||||
$item['id_agent_end'] = $id_target;
|
||||
$item['id_agent_end'] = $id_target_a;
|
||||
$item['target'] = -1;
|
||||
$item['source'] = -1;
|
||||
$item['target_id_db'] = $relation['id_parent'];
|
||||
$item['source_id_db'] = $relation['id_child'];
|
||||
if (($relation['parent_type'] == 1) && ($relation['child_type'] == 1)) {
|
||||
$item['target_id_db'] = $id_agent_parent;
|
||||
$item['source_id_db'] = $id_agent_child;
|
||||
}
|
||||
else {
|
||||
$item['target_id_db'] = $relation['id_parent'];
|
||||
$item['source_id_db'] = $relation['id_child'];
|
||||
}
|
||||
$item['text_end'] = "";
|
||||
$item['text_start'] = "";
|
||||
|
||||
|
@ -454,13 +491,24 @@ function networkmap_links_to_js_links($relations, $nodes_graph) {
|
|||
$item['id_module_start'] = $id_source;
|
||||
$item['text_start'] = io_safe_output(modules_get_agentmodule_name($item['id_module_start']));
|
||||
}
|
||||
|
||||
foreach ($nodes_graph as $node) {
|
||||
if (enterprise_installed()) {
|
||||
if ($node['id_db'] == $relation['id_parent']) {
|
||||
$item['target'] = $node['id'];
|
||||
if (($relation['parent_type'] == 1) && ($relation['child_type'] == 1)) {
|
||||
if ($node['id_db'] == $id_agent_parent) {
|
||||
$item['target'] = $node['id'];
|
||||
}
|
||||
if ($node['id_db'] == $id_agent_child) {
|
||||
$item['source'] = $node['id'];
|
||||
}
|
||||
}
|
||||
if ($node['id_db'] == $relation['id_child']) {
|
||||
$item['source'] = $node['id'];
|
||||
else {
|
||||
if ($node['id_db'] == $relation['id_parent']) {
|
||||
$item['target'] = $node['id'];
|
||||
}
|
||||
if ($node['id_db'] == $relation['id_child']) {
|
||||
$item['source'] = $node['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -475,7 +523,6 @@ function networkmap_links_to_js_links($relations, $nodes_graph) {
|
|||
|
||||
$return[] = $item;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@ -539,6 +586,7 @@ function networkmap_write_js_array($id, $nodes_and_relations = array()) {
|
|||
$style = json_decode($node['style'], true);
|
||||
$node['style'] = json_decode($node['style'], true);
|
||||
|
||||
// Only agents can be show
|
||||
if (isset($node['type'])) {
|
||||
if ($node['type'] == 1)
|
||||
continue;
|
||||
|
@ -564,7 +612,6 @@ function networkmap_write_js_array($id, $nodes_and_relations = array()) {
|
|||
}
|
||||
|
||||
if ($relations === false) $relations = array();
|
||||
|
||||
//Clean the relations and transform the module relations into
|
||||
//interfaces
|
||||
networkmap_clean_relations_for_js($relations);
|
||||
|
@ -704,6 +751,7 @@ function networkmap_loadfile($id = 0, $file = '',
|
|||
}
|
||||
else {
|
||||
$data['type'] = $ids[$node_id]['type'];
|
||||
|
||||
switch ($ids[$node_id]['type']) {
|
||||
case 'module':
|
||||
$data['id_module'] = $ids[$node_id]['id_module'];
|
||||
|
|
|
@ -17,11 +17,10 @@ global $config;
|
|||
check_login();
|
||||
|
||||
if (is_ajax ()) {
|
||||
$resize_networkmap = (bool)get_parameter(
|
||||
'resize_networkmap', false);
|
||||
|
||||
$resize_networkmap_enterprise = (bool)get_parameter(
|
||||
'resize_networkmap_enterprise', false);
|
||||
|
||||
if ($resize_networkmap_enterprise) {
|
||||
if ($resize_networkmap) {
|
||||
$id = (int) get_parameter('id', 0);
|
||||
|
||||
$return = array();
|
||||
|
@ -202,7 +201,7 @@ if ($edit_networkmap) {
|
|||
break;
|
||||
}
|
||||
$refresh_value = $values['source_period'];
|
||||
$l2_network_interfaces = false;
|
||||
$l2_network_interfaces = true;
|
||||
/* NO CONTEMPLADO
|
||||
if (isset($options['l2_network_interfaces']))
|
||||
$l2_network_interfaces = $options['l2_network_interfaces'];
|
||||
|
@ -368,7 +367,7 @@ else {
|
|||
__('This operation can\'t be undone, because it is on DB.'), true);
|
||||
$table->data[6][1] = '<div id="spinner_process"></div><div id="process_button">' .
|
||||
html_print_button(__('Process'),
|
||||
'process', !((bool)$id), 'resize_networkmap_enterprise(' . $id . ');', 'class="sub"', true) .
|
||||
'process', !((bool)$id), 'resize_networkmap(' . $id . ');', 'class="sub"', true) .
|
||||
'</div>';
|
||||
|
||||
echo '<form method="post" action="index.php?sec=network&sec2=operation/agentes/pandora_networkmap">';
|
||||
|
@ -392,7 +391,7 @@ else {
|
|||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function resize_networkmap_enterprise(id) {
|
||||
function resize_networkmap(id) {
|
||||
var params1 = [];
|
||||
params1.push("get_image_path=1");
|
||||
params1.push("img_src=" + "images/spinner.gif");
|
||||
|
@ -412,7 +411,7 @@ function resize_networkmap_enterprise(id) {
|
|||
|
||||
|
||||
var params = [];
|
||||
params.push("resize_networkmap_enterprise=1");
|
||||
params.push("resize_networkmap=1");
|
||||
params.push("id=" + id);
|
||||
params.push("page=operation/agentes/pandora_networkmap.editor");
|
||||
jQuery.ajax ({
|
||||
|
|
Loading…
Reference in New Issue