Merge branch 'wip/3595' into 'ent-3595-discovery-fase-2'
Wip/3595 See merge request artica/pandorafms!2279 Former-commit-id: e079a3c54a1f054498cb67af759ee5d3f1be4eac
This commit is contained in:
commit
756e785634
|
@ -15,6 +15,8 @@ if (! check_acl($config['id_user'], 0, 'AW')) {
|
|||
|
||||
ui_require_css_file('discovery');
|
||||
|
||||
ui_print_page_header(__('Discovery'), '', false, '', true);
|
||||
|
||||
|
||||
/**
|
||||
* Mask class names.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -195,6 +195,14 @@ define('AGENT_STATUS_UNKNOWN', 3);
|
|||
define('AGENT_STATUS_ALERT_FIRED', 4);
|
||||
define('AGENT_STATUS_WARNING', 2);
|
||||
|
||||
// Pseudo criticity analysis.
|
||||
define('NO_CRIT', -1);
|
||||
define('CRIT_0', 0);
|
||||
define('CRIT_1', 1);
|
||||
define('CRIT_2', 2);
|
||||
define('CRIT_3', 3);
|
||||
define('CRIT_4', 4);
|
||||
define('CRIT_5', 5);
|
||||
|
||||
// Visual maps contants.
|
||||
// The items kind.
|
||||
|
@ -506,6 +514,12 @@ define('OPTION_COLOR_PICKER', 11);
|
|||
define('NODE_TYPE', 0);
|
||||
define('ARROW_TYPE', 1);
|
||||
|
||||
// Networkmap node types.
|
||||
define('NODE_AGENT', 0);
|
||||
define('NODE_MODULE', 1);
|
||||
define('NODE_PANDORA', 2);
|
||||
define('NODE_GENERIC', 3);
|
||||
|
||||
// SAML attributes constants.
|
||||
define('SAML_ROLE_AND_TAG', 'eduPersonEntitlement');
|
||||
define('SAML_USER_DESC', 'commonName');
|
||||
|
|
|
@ -489,11 +489,11 @@ function networkmap_generate_dot(
|
|||
|
||||
// Create void statistics array
|
||||
$stats = [];
|
||||
|
||||
$count = 0;
|
||||
$group_nodes = 10;
|
||||
$graph .= networkmap_create_transparent_node($count);
|
||||
foreach (array_keys($orphans) as $node) {
|
||||
/*
|
||||
$count = 0;
|
||||
$group_nodes = 10;
|
||||
$graph .= networkmap_create_transparent_node($count);
|
||||
foreach (array_keys($orphans) as $node) {
|
||||
if ($group_nodes == 0) {
|
||||
$count++;
|
||||
$graph .= networkmap_create_transparent_node($count);
|
||||
|
@ -507,7 +507,8 @@ function networkmap_generate_dot(
|
|||
);
|
||||
|
||||
$group_nodes--;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Create nodes
|
||||
foreach ($nodes as $node_id => $node) {
|
||||
|
@ -714,7 +715,7 @@ function networkmap_create_edge(
|
|||
|
||||
// Option edgeURL allows node navigation.
|
||||
$edge = "\n".$head.' -- '.$tail;
|
||||
$edge .= '[color="#BDBDBD", headclip=false, tailclip=false, edgeURL=""];';
|
||||
$edge .= '[len='.$ranksep.', color="#BDBDBD", headclip=false, tailclip=false, edgeURL=""];';
|
||||
$edge .= "\n";
|
||||
|
||||
return $edge;
|
||||
|
@ -1328,10 +1329,18 @@ function networkmap_get_new_nodes_from_ip_mask(
|
|||
) {
|
||||
$list_ip_masks = explode(',', $ip_mask);
|
||||
|
||||
if (empty($list_ip_masks)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$agents = [];
|
||||
foreach ($list_ip_masks as $subnet) {
|
||||
$net = explode('/', $subnet);
|
||||
|
||||
// Calculate real network address. Avoid user bad input.
|
||||
$mask = ~((1 << (32 - $net[1])) - 1);
|
||||
$network = long2ip(ip2long($net[0]) & $mask);
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT *
|
||||
FROM `tagente`
|
||||
|
@ -1349,7 +1358,7 @@ function networkmap_get_new_nodes_from_ip_mask(
|
|||
) t_res
|
||||
ON t_res.`id_agent` = `tagente`.`id_agente`',
|
||||
(32 - $net[1]),
|
||||
$net[0]
|
||||
$network
|
||||
);
|
||||
|
||||
$subnet_agents = db_get_all_rows_sql($sql);
|
||||
|
@ -1553,6 +1562,7 @@ function networkmap_db_node_to_js_node(
|
|||
$item['raw_text'] = $node['style']['label'];
|
||||
$item['text'] = io_safe_output($node['style']['label']);
|
||||
$item['shape'] = $node['style']['shape'];
|
||||
|
||||
switch ($node['type']) {
|
||||
case 0:
|
||||
$color = get_status_color_networkmap($node['source_data']);
|
||||
|
@ -1689,7 +1699,9 @@ function networkmap_links_to_js_links(
|
|||
|
||||
$count = 0;
|
||||
foreach ($relations as $key => $relation) {
|
||||
if (($relation['parent_type'] == 1) && ($relation['child_type'] == 1)) {
|
||||
if (($relation['parent_type'] == NODE_MODULE)
|
||||
&& ($relation['child_type'] == NODE_MODULE)
|
||||
) {
|
||||
$id_target_agent = agents_get_agent_id_by_module_id(
|
||||
$relation['id_parent_source_data']
|
||||
);
|
||||
|
@ -1698,16 +1710,16 @@ function networkmap_links_to_js_links(
|
|||
);
|
||||
$id_target_module = $relation['id_parent_source_data'];
|
||||
$id_source_module = $relation['id_child_source_data'];
|
||||
} else if (($relation['parent_type'] == 1)
|
||||
&& ($relation['child_type'] == 0)
|
||||
} else if (($relation['parent_type'] == NODE_MODULE)
|
||||
&& ($relation['child_type'] == NODE_AGENT)
|
||||
) {
|
||||
$id_target_agent = agents_get_agent_id_by_module_id(
|
||||
$relation['id_parent_source_data']
|
||||
);
|
||||
$id_target_module = $relation['id_parent_source_data'];
|
||||
$id_source_agent = $relation['id_child_source_data'];
|
||||
} else if (($relation['parent_type'] == 0)
|
||||
&& ($relation['child_type'] == 1)
|
||||
} else if (($relation['parent_type'] == NODE_AGENT)
|
||||
&& ($relation['child_type'] == NODE_MODULE)
|
||||
) {
|
||||
$id_target_agent = $relation['id_parent_source_data'];
|
||||
$id_source_module = $relation['id_child_source_data'];
|
||||
|
@ -1747,10 +1759,10 @@ function networkmap_links_to_js_links(
|
|||
$item['target_id_db'] = (int) $target_and_source['target'];
|
||||
$item['source_id_db'] = (int) $target_and_source['source'];
|
||||
} else {
|
||||
if (($relation['parent_type'] == 1) && ($relation['child_type'] == 1)) {
|
||||
if (($relation['parent_type'] == NODE_MODULE) && ($relation['child_type'] == NODE_MODULE)) {
|
||||
$item['target_id_db'] = $id_target_agent;
|
||||
$item['source_id_db'] = $id_source_agent;
|
||||
} else if (($relation['parent_type'] == 0) && ($relation['child_type'] == 0)) {
|
||||
} else if (($relation['parent_type'] == NODE_AGENT) && ($relation['child_type'] == NODE_AGENT)) {
|
||||
$item['target_id_db'] = (int) $relation['id_parent_source_data'];
|
||||
$item['source_id_db'] = $id_source_agent;
|
||||
} else {
|
||||
|
@ -1775,7 +1787,7 @@ function networkmap_links_to_js_links(
|
|||
}
|
||||
}
|
||||
|
||||
if ($relation['child_type'] == 1) {
|
||||
if ($relation['child_type'] == NODE_MODULE) {
|
||||
$item['arrow_start'] = 'module';
|
||||
$item['status_start'] = modules_get_agentmodule_status((int) $id_source_module, false, false, null);
|
||||
$item['id_module_start'] = (int) $id_source_module;
|
||||
|
@ -1793,7 +1805,7 @@ function networkmap_links_to_js_links(
|
|||
$control1 = false;
|
||||
$control2 = false;
|
||||
|
||||
if (($relation['parent_type'] == 1) && ($relation['child_type'] == 1)) {
|
||||
if (($relation['parent_type'] == NODE_MODULE) && ($relation['child_type'] == NODE_MODULE)) {
|
||||
if (($item['status_start'] == AGENT_MODULE_STATUS_CRITICAL_BAD) || ($item['status_end'] == AGENT_MODULE_STATUS_CRITICAL_BAD)) {
|
||||
$item['link_color'] = '#FC4444';
|
||||
} else if (($item['status_start'] == AGENT_MODULE_STATUS_WARNING) || ($item['status_end'] == AGENT_MODULE_STATUS_WARNING)) {
|
||||
|
@ -1823,7 +1835,7 @@ function networkmap_links_to_js_links(
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if ($relation['child_type'] == 1) {
|
||||
} else if ($relation['child_type'] == NODE_MODULE) {
|
||||
if ($item['status_start'] == AGENT_MODULE_STATUS_CRITICAL_BAD) {
|
||||
$item['link_color'] = '#FC4444';
|
||||
} else if ($item['status_start'] == AGENT_MODULE_STATUS_WARNING) {
|
||||
|
@ -1850,7 +1862,7 @@ function networkmap_links_to_js_links(
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if ($relation['parent_type'] == 1) {
|
||||
} else if ($relation['parent_type'] == NODE_MODULE) {
|
||||
if ($item['status_end'] == AGENT_MODULE_STATUS_CRITICAL_BAD) {
|
||||
$item['link_color'] = '#FC4444';
|
||||
} else if ($item['status_end'] == AGENT_MODULE_STATUS_WARNING) {
|
||||
|
@ -1877,8 +1889,8 @@ function networkmap_links_to_js_links(
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (($relation['parent_type'] == 3)
|
||||
&& ($relation['child_type'] == 3)
|
||||
} else if (($relation['parent_type'] == NODE_PANDORA)
|
||||
&& ($relation['child_type'] == NODE_PANDORA)
|
||||
) {
|
||||
foreach ($nodes_graph as $key2 => $node) {
|
||||
if ($relation['id_parent'] == $node['id_db']) {
|
||||
|
@ -1891,10 +1903,10 @@ function networkmap_links_to_js_links(
|
|||
$agent2 = $node['id_db'];
|
||||
}
|
||||
}
|
||||
} else if (($relation['parent_type'] == 3)
|
||||
|| ($relation['child_type'] == 3)
|
||||
} else if (($relation['parent_type'] == NODE_PANDORA)
|
||||
|| ($relation['child_type'] == NODE_PANDORA)
|
||||
) {
|
||||
if ($relation['parent_type'] == 3) {
|
||||
if ($relation['parent_type'] == NODE_PANDORA) {
|
||||
foreach ($nodes_graph as $key2 => $node) {
|
||||
if ($relation['id_parent'] == $node['id_db']) {
|
||||
$agent = $node['id_db'];
|
||||
|
@ -1902,7 +1914,7 @@ function networkmap_links_to_js_links(
|
|||
$agent2 = $node['id_db'];
|
||||
}
|
||||
}
|
||||
} else if ($relation['child_type'] == 3) {
|
||||
} else if ($relation['child_type'] == NODE_PANDORA) {
|
||||
foreach ($nodes_graph as $key2 => $node) {
|
||||
if ($relation['id_child'] == $node['id_db']) {
|
||||
$agent2 = $node['id_db'];
|
||||
|
@ -1932,8 +1944,8 @@ function networkmap_links_to_js_links(
|
|||
}
|
||||
|
||||
if ((($item['target'] == -1) || ($item['source'] == -1))
|
||||
&& $relation['parent_type'] == 1
|
||||
&& $relation['child_type'] == 1
|
||||
&& $relation['parent_type'] == NODE_MODULE
|
||||
&& $relation['child_type'] == NODE_MODULE
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
@ -2190,10 +2202,11 @@ function networkmap_loadfile(
|
|||
if (preg_match('/^node.*$/', $line) != 0) {
|
||||
$items = explode(' ', $line);
|
||||
$node_id = $items[1];
|
||||
|
||||
// 200 for larger maps
|
||||
$node_x = ($items[2] * 100);
|
||||
// 200 is for show more big
|
||||
$node_y = ($height_map - $items[3] * 100);
|
||||
// 200 is for show more big
|
||||
// 200 for larger maps
|
||||
$data['id'] = $node_id;
|
||||
$data['text'] = '';
|
||||
$data['image'] = '';
|
||||
|
@ -2306,7 +2319,10 @@ function networkmap_loadfile(
|
|||
$relations_param[] = $row;
|
||||
}
|
||||
|
||||
return $networkmap_nodes;
|
||||
return [
|
||||
'nodes' => $networkmap_nodes,
|
||||
'relations' => $relations_param,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -2749,4 +2765,4 @@ function networkmap_load_cluetip()
|
|||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
|
|
@ -473,8 +473,7 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
|
|||
$self->{'pa_config'}, $self->{'pa_config'}->{'servername'},
|
||||
$host_name, $device, $self->{'group_id'}, 0, $id_os,
|
||||
'', 300, $self->{'dbh'}, undef, $location->{'longitude'},
|
||||
$location->{'latitude'}, undef, undef, undef, undef,
|
||||
undef, undef, $self->{'main_event_id'}
|
||||
$location->{'latitude'}
|
||||
);
|
||||
return undef unless defined ($agent_id) and ($agent_id > 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue