mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Fixed the groups in the networkmap new.
This commit is contained in:
parent
2831607723
commit
db8bff681b
@ -108,6 +108,15 @@ class Networkmap extends Map {
|
|||||||
|
|
||||||
$chunks = explode("ajax.php?", $chunks[1]);
|
$chunks = explode("ajax.php?", $chunks[1]);
|
||||||
|
|
||||||
|
$is_node_group = false;
|
||||||
|
if ($this->subtype == MAP_SUBTYPE_GROUPS) {
|
||||||
|
if (strstr($chunks[1], "&id_group=") !== false) {
|
||||||
|
$is_node_group = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$id_agent = null;
|
$id_agent = null;
|
||||||
$status = null;
|
$status = null;
|
||||||
$title = "";
|
$title = "";
|
||||||
@ -117,7 +126,17 @@ class Networkmap extends Map {
|
|||||||
$color = DEFAULT_NODE_COLOR;
|
$color = DEFAULT_NODE_COLOR;
|
||||||
$image = DEFAULT_NODE_IMAGE;
|
$image = DEFAULT_NODE_IMAGE;
|
||||||
|
|
||||||
if ($is_node_module_group) {
|
if ($is_node_group) {
|
||||||
|
preg_match("/<TR><TD>(.*)<\/TD><\/TR><\/TABLE>>/", $chunks[0], $matches);
|
||||||
|
$title = $matches[1];
|
||||||
|
preg_match("/id_group=([0-9]*)/", $chunks[1], $matches);
|
||||||
|
$id = $matches[1];
|
||||||
|
$type = ITEM_TYPE_GROUP_NETWORKMAP;
|
||||||
|
preg_match("/data-status=\"([0-9]*)\"/", $chunks[1], $matches);
|
||||||
|
$status = $matches[1];
|
||||||
|
$shape = "rhombus";
|
||||||
|
}
|
||||||
|
elseif ($is_node_module_group) {
|
||||||
preg_match("/<TR><TD>(.*)<\/TD><\/TR><\/TABLE>>/", $chunks[0], $matches);
|
preg_match("/<TR><TD>(.*)<\/TD><\/TR><\/TABLE>>/", $chunks[0], $matches);
|
||||||
$title = $matches[1];
|
$title = $matches[1];
|
||||||
$id = db_get_value('id_mg', 'tmodule_group',
|
$id = db_get_value('id_mg', 'tmodule_group',
|
||||||
@ -281,6 +300,17 @@ class Networkmap extends Map {
|
|||||||
$return['module_group'] = $this->filter['module_group'];
|
$return['module_group'] = $this->filter['module_group'];
|
||||||
$return['show_modulegroup'] = $this->filter['show_module_group'];
|
$return['show_modulegroup'] = $this->filter['show_module_group'];
|
||||||
|
|
||||||
|
switch ($this->subtype) {
|
||||||
|
case MAP_SUBTYPE_GROUPS:
|
||||||
|
$return['show_groups'] = true;
|
||||||
|
$return['show_agents'] = $this->filter['show_agents'];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$return['show_groups'] = false;
|
||||||
|
$return['show_agents'] = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,6 +323,7 @@ class Networkmap extends Map {
|
|||||||
|
|
||||||
$parameters = $this->temp_parseParameters_generateDot();
|
$parameters = $this->temp_parseParameters_generateDot();
|
||||||
|
|
||||||
|
|
||||||
// Generate dot file
|
// Generate dot file
|
||||||
$graph = networkmap_generate_dot (__('Pandora FMS'),
|
$graph = networkmap_generate_dot (__('Pandora FMS'),
|
||||||
$parameters['id_group'],
|
$parameters['id_group'],
|
||||||
@ -320,7 +351,9 @@ class Networkmap extends Map {
|
|||||||
$parameters['show_modules'],
|
$parameters['show_modules'],
|
||||||
$parameters['only_modules_alerts'],
|
$parameters['only_modules_alerts'],
|
||||||
$parameters['module_group'],
|
$parameters['module_group'],
|
||||||
$parameters['show_modulegroup']);
|
$parameters['show_modulegroup'],
|
||||||
|
$parameters['show_groups'],
|
||||||
|
$parameters['show_agents']);
|
||||||
|
|
||||||
|
|
||||||
$filename_dot = sys_get_temp_dir() . "/networkmap" . uniqid() . ".dot";
|
$filename_dot = sys_get_temp_dir() . "/networkmap" . uniqid() . ".dot";
|
||||||
|
@ -506,6 +506,7 @@ define("ITEM_TYPE_MODULE_NETWORKMAP", 1);
|
|||||||
define("ITEM_TYPE_EDGE_NETWORKMAP", 2);
|
define("ITEM_TYPE_EDGE_NETWORKMAP", 2);
|
||||||
define("ITEM_TYPE_FICTIONAL_NODE", 3);
|
define("ITEM_TYPE_FICTIONAL_NODE", 3);
|
||||||
define("ITEM_TYPE_MODULEGROUP_NETWORKMAP", 4);
|
define("ITEM_TYPE_MODULEGROUP_NETWORKMAP", 4);
|
||||||
|
define("ITEM_TYPE_GROUP_NETWORKMAP", 5);
|
||||||
|
|
||||||
/* Another constants new networkmap */
|
/* Another constants new networkmap */
|
||||||
define("DEFAULT_NODE_WIDTH", 30);
|
define("DEFAULT_NODE_WIDTH", 30);
|
||||||
|
@ -233,7 +233,8 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||||||
$ip_mask = null, $dont_show_subgroups = false, $strict_user = false,
|
$ip_mask = null, $dont_show_subgroups = false, $strict_user = false,
|
||||||
$size_canvas = null, $old_mode = false, $id_tag = 0,
|
$size_canvas = null, $old_mode = false, $id_tag = 0,
|
||||||
$show_all_modules = false, $only_modules_alerts = false,
|
$show_all_modules = false, $only_modules_alerts = false,
|
||||||
$filter_module_group = 0, $show_modulegroup = false) {
|
$filter_module_group = 0, $show_modulegroup = false,
|
||||||
|
$show_groups = false, $show_agents = true) {
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@ -370,12 +371,89 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Get groups data
|
||||||
|
if ($show_groups) {
|
||||||
|
if ($group > 0) {
|
||||||
|
$groups = array();
|
||||||
|
$id_groups = groups_get_id_recursive($group, true);
|
||||||
|
|
||||||
|
foreach($id_groups as $id_group) {
|
||||||
|
$add = false;
|
||||||
|
if (check_acl($config["id_user"], $id_group, 'AR')) {
|
||||||
|
$add = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($add) {
|
||||||
|
$groups[] = db_get_row ('tgrupo', 'id_grupo', $id_group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$filter['id_grupo'] = $id_groups;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($strict_user) {
|
||||||
|
$groups = users_get_groups ($config['id_user'],"AR", false, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$groups = db_get_all_rows_in_table ('tgrupo');
|
||||||
|
}
|
||||||
|
if ($groups === false) {
|
||||||
|
$groups = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Open Graph
|
// Open Graph
|
||||||
$graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom,
|
$graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom,
|
||||||
$ranksep, $font_size, $size_canvas);
|
$ranksep, $font_size, $size_canvas);
|
||||||
|
|
||||||
// Parse agents
|
|
||||||
$nodes = array ();
|
$nodes = array ();
|
||||||
|
$node_count = 0;
|
||||||
|
|
||||||
|
if ($show_groups) {
|
||||||
|
// Parse groups
|
||||||
|
$nodes_groups = array();
|
||||||
|
foreach ($groups as $group2) {
|
||||||
|
$node_count ++;
|
||||||
|
$group2['type'] = 'group';
|
||||||
|
$group2['id_node'] = $node_count;
|
||||||
|
|
||||||
|
// Add node
|
||||||
|
$nodes_groups[$group2['id_grupo']] = $group2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$groups_hiden = array();
|
||||||
|
foreach ($nodes_groups as $node_group) {
|
||||||
|
|
||||||
|
//~ $node_count++;
|
||||||
|
|
||||||
|
// Save node parent information to define edges later
|
||||||
|
if ($node_group['parent'] != "0" && $node_group['id_grupo'] != $group) {
|
||||||
|
if ((!$dont_show_subgroups) || ($group == 0)) {
|
||||||
|
$parents[$node_count] =
|
||||||
|
$nodes_groups[$node_group['parent']]['id_node'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$groups_hiden[$node_group['id_grupo']] = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$orphans[$node_group['id_node']] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nodes[$node_group['id_node']] = $node_group;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($show_agents) {
|
||||||
|
// Parse agents
|
||||||
|
|
||||||
|
|
||||||
// Add node refs
|
// Add node refs
|
||||||
$node_ref = array();
|
$node_ref = array();
|
||||||
@ -383,11 +461,15 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||||||
|
|
||||||
$module_groups = array();
|
$module_groups = array();
|
||||||
|
|
||||||
$node_count = 0;
|
|
||||||
|
|
||||||
foreach ($agents as $agent) {
|
foreach ($agents as $agent) {
|
||||||
$node_count++;
|
$node_count++;
|
||||||
|
|
||||||
|
if ($show_groups) {
|
||||||
|
$parents[$node_count] = $agent['parent'] = $nodes_groups[$agent['id_grupo']]['id_node'];
|
||||||
|
}
|
||||||
|
|
||||||
$node_ref[$agent['id_agente']] = $node_count;
|
$node_ref[$agent['id_agente']] = $node_count;
|
||||||
|
|
||||||
$agent['id_node'] = $node_count;
|
$agent['id_node'] = $node_count;
|
||||||
@ -565,6 +647,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} // End if ($show_agents)
|
||||||
|
|
||||||
// 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
|
||||||
@ -666,6 +749,11 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch ($node['type']) {
|
switch ($node['type']) {
|
||||||
|
case 'group':
|
||||||
|
$graph .= networkmap_create_group_node ($node , $simple, $font_size, $metaconsole = false, null, $strict_user) .
|
||||||
|
"\n\t\t";
|
||||||
|
$stats['groups'][] = $node['id_grupo'];
|
||||||
|
break;
|
||||||
case 'agent':
|
case 'agent':
|
||||||
$graph .= networkmap_create_agent_node($node, $simple,
|
$graph .= networkmap_create_agent_node($node, $simple,
|
||||||
$font_size, $cut_names, $relative) . "\n\t\t";
|
$font_size, $cut_names, $relative) . "\n\t\t";
|
||||||
@ -898,7 +986,8 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0,
|
|||||||
else {
|
else {
|
||||||
if ($strict_user) {
|
if ($strict_user) {
|
||||||
$groups = users_get_groups ($config['id_user'],"AR", false, true);
|
$groups = users_get_groups ($config['id_user'],"AR", false, true);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$groups = db_get_all_rows_in_table ('tgrupo');
|
$groups = db_get_all_rows_in_table ('tgrupo');
|
||||||
}
|
}
|
||||||
if ($groups === false) {
|
if ($groups === false) {
|
||||||
@ -957,7 +1046,8 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0,
|
|||||||
tagente.unknown_count, tagente.total_count, tagente.notinit_count');
|
tagente.unknown_count, tagente.total_count, tagente.notinit_count');
|
||||||
$agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
|
$agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
|
||||||
unset($filter['id_group']);
|
unset($filter['id_group']);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Get agents data
|
// Get agents data
|
||||||
$agents = agents_get_agents ($filter,
|
$agents = agents_get_agents ($filter,
|
||||||
array ('id_grupo, nombre, id_os, id_agente,
|
array ('id_grupo, nombre, id_os, id_agente,
|
||||||
@ -1202,7 +1292,8 @@ function networkmap_create_group_node ($group, $simple = 0, $font_size = 10, $me
|
|||||||
$url_tooltip = 'ajax.php?page=operation/agentes/ver_agente&get_group_status_tooltip=1&id_group='.$group['id_grupo'];
|
$url_tooltip = 'ajax.php?page=operation/agentes/ver_agente&get_group_status_tooltip=1&id_group='.$group['id_grupo'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$node = "\n" . $group['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.30, height=0.30, label=<<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD>'.$img_node.'</TD></TR>
|
$node = "\n" . $group['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.30, height=0.30, ' .
|
||||||
|
'label=<<TABLE CELLPADDING="0" data-status="' . $status . '" CELLSPACING="0" BORDER="0"><TR><TD>'.$img_node.'</TD></TR>
|
||||||
<TR><TD>'.io_safe_output($name).'</TD></TR></TABLE>>,
|
<TR><TD>'.io_safe_output($name).'</TD></TR></TABLE>>,
|
||||||
shape="invtrapezium", URL="' . $url . '",
|
shape="invtrapezium", URL="' . $url . '",
|
||||||
tooltip="' . $url_tooltip . '"];' . "\n";
|
tooltip="' . $url_tooltip . '"];' . "\n";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user