mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 15:54:29 +02:00
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_require_css_file('discovery');
|
||||||
|
|
||||||
|
ui_print_page_header(__('Discovery'), '', false, '', true);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mask class names.
|
* 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_ALERT_FIRED', 4);
|
||||||
define('AGENT_STATUS_WARNING', 2);
|
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.
|
// Visual maps contants.
|
||||||
// The items kind.
|
// The items kind.
|
||||||
@ -506,6 +514,12 @@ define('OPTION_COLOR_PICKER', 11);
|
|||||||
define('NODE_TYPE', 0);
|
define('NODE_TYPE', 0);
|
||||||
define('ARROW_TYPE', 1);
|
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.
|
// SAML attributes constants.
|
||||||
define('SAML_ROLE_AND_TAG', 'eduPersonEntitlement');
|
define('SAML_ROLE_AND_TAG', 'eduPersonEntitlement');
|
||||||
define('SAML_USER_DESC', 'commonName');
|
define('SAML_USER_DESC', 'commonName');
|
||||||
|
@ -489,7 +489,7 @@ function networkmap_generate_dot(
|
|||||||
|
|
||||||
// Create void statistics array
|
// Create void statistics array
|
||||||
$stats = [];
|
$stats = [];
|
||||||
|
/*
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$group_nodes = 10;
|
$group_nodes = 10;
|
||||||
$graph .= networkmap_create_transparent_node($count);
|
$graph .= networkmap_create_transparent_node($count);
|
||||||
@ -508,6 +508,7 @@ function networkmap_generate_dot(
|
|||||||
|
|
||||||
$group_nodes--;
|
$group_nodes--;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Create nodes
|
// Create nodes
|
||||||
foreach ($nodes as $node_id => $node) {
|
foreach ($nodes as $node_id => $node) {
|
||||||
@ -714,7 +715,7 @@ function networkmap_create_edge(
|
|||||||
|
|
||||||
// Option edgeURL allows node navigation.
|
// Option edgeURL allows node navigation.
|
||||||
$edge = "\n".$head.' -- '.$tail;
|
$edge = "\n".$head.' -- '.$tail;
|
||||||
$edge .= '[color="#BDBDBD", headclip=false, tailclip=false, edgeURL=""];';
|
$edge .= '[len='.$ranksep.', color="#BDBDBD", headclip=false, tailclip=false, edgeURL=""];';
|
||||||
$edge .= "\n";
|
$edge .= "\n";
|
||||||
|
|
||||||
return $edge;
|
return $edge;
|
||||||
@ -1328,10 +1329,18 @@ function networkmap_get_new_nodes_from_ip_mask(
|
|||||||
) {
|
) {
|
||||||
$list_ip_masks = explode(',', $ip_mask);
|
$list_ip_masks = explode(',', $ip_mask);
|
||||||
|
|
||||||
|
if (empty($list_ip_masks)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
$agents = [];
|
$agents = [];
|
||||||
foreach ($list_ip_masks as $subnet) {
|
foreach ($list_ip_masks as $subnet) {
|
||||||
$net = explode('/', $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(
|
$sql = sprintf(
|
||||||
'SELECT *
|
'SELECT *
|
||||||
FROM `tagente`
|
FROM `tagente`
|
||||||
@ -1349,7 +1358,7 @@ function networkmap_get_new_nodes_from_ip_mask(
|
|||||||
) t_res
|
) t_res
|
||||||
ON t_res.`id_agent` = `tagente`.`id_agente`',
|
ON t_res.`id_agent` = `tagente`.`id_agente`',
|
||||||
(32 - $net[1]),
|
(32 - $net[1]),
|
||||||
$net[0]
|
$network
|
||||||
);
|
);
|
||||||
|
|
||||||
$subnet_agents = db_get_all_rows_sql($sql);
|
$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['raw_text'] = $node['style']['label'];
|
||||||
$item['text'] = io_safe_output($node['style']['label']);
|
$item['text'] = io_safe_output($node['style']['label']);
|
||||||
$item['shape'] = $node['style']['shape'];
|
$item['shape'] = $node['style']['shape'];
|
||||||
|
|
||||||
switch ($node['type']) {
|
switch ($node['type']) {
|
||||||
case 0:
|
case 0:
|
||||||
$color = get_status_color_networkmap($node['source_data']);
|
$color = get_status_color_networkmap($node['source_data']);
|
||||||
@ -1689,7 +1699,9 @@ function networkmap_links_to_js_links(
|
|||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($relations as $key => $relation) {
|
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(
|
$id_target_agent = agents_get_agent_id_by_module_id(
|
||||||
$relation['id_parent_source_data']
|
$relation['id_parent_source_data']
|
||||||
);
|
);
|
||||||
@ -1698,16 +1710,16 @@ function networkmap_links_to_js_links(
|
|||||||
);
|
);
|
||||||
$id_target_module = $relation['id_parent_source_data'];
|
$id_target_module = $relation['id_parent_source_data'];
|
||||||
$id_source_module = $relation['id_child_source_data'];
|
$id_source_module = $relation['id_child_source_data'];
|
||||||
} else if (($relation['parent_type'] == 1)
|
} else if (($relation['parent_type'] == NODE_MODULE)
|
||||||
&& ($relation['child_type'] == 0)
|
&& ($relation['child_type'] == NODE_AGENT)
|
||||||
) {
|
) {
|
||||||
$id_target_agent = agents_get_agent_id_by_module_id(
|
$id_target_agent = agents_get_agent_id_by_module_id(
|
||||||
$relation['id_parent_source_data']
|
$relation['id_parent_source_data']
|
||||||
);
|
);
|
||||||
$id_target_module = $relation['id_parent_source_data'];
|
$id_target_module = $relation['id_parent_source_data'];
|
||||||
$id_source_agent = $relation['id_child_source_data'];
|
$id_source_agent = $relation['id_child_source_data'];
|
||||||
} else if (($relation['parent_type'] == 0)
|
} else if (($relation['parent_type'] == NODE_AGENT)
|
||||||
&& ($relation['child_type'] == 1)
|
&& ($relation['child_type'] == NODE_MODULE)
|
||||||
) {
|
) {
|
||||||
$id_target_agent = $relation['id_parent_source_data'];
|
$id_target_agent = $relation['id_parent_source_data'];
|
||||||
$id_source_module = $relation['id_child_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['target_id_db'] = (int) $target_and_source['target'];
|
||||||
$item['source_id_db'] = (int) $target_and_source['source'];
|
$item['source_id_db'] = (int) $target_and_source['source'];
|
||||||
} else {
|
} 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['target_id_db'] = $id_target_agent;
|
||||||
$item['source_id_db'] = $id_source_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['target_id_db'] = (int) $relation['id_parent_source_data'];
|
||||||
$item['source_id_db'] = $id_source_agent;
|
$item['source_id_db'] = $id_source_agent;
|
||||||
} else {
|
} 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['arrow_start'] = 'module';
|
||||||
$item['status_start'] = modules_get_agentmodule_status((int) $id_source_module, false, false, null);
|
$item['status_start'] = modules_get_agentmodule_status((int) $id_source_module, false, false, null);
|
||||||
$item['id_module_start'] = (int) $id_source_module;
|
$item['id_module_start'] = (int) $id_source_module;
|
||||||
@ -1793,7 +1805,7 @@ function networkmap_links_to_js_links(
|
|||||||
$control1 = false;
|
$control1 = false;
|
||||||
$control2 = 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)) {
|
if (($item['status_start'] == AGENT_MODULE_STATUS_CRITICAL_BAD) || ($item['status_end'] == AGENT_MODULE_STATUS_CRITICAL_BAD)) {
|
||||||
$item['link_color'] = '#FC4444';
|
$item['link_color'] = '#FC4444';
|
||||||
} else if (($item['status_start'] == AGENT_MODULE_STATUS_WARNING) || ($item['status_end'] == AGENT_MODULE_STATUS_WARNING)) {
|
} 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) {
|
if ($item['status_start'] == AGENT_MODULE_STATUS_CRITICAL_BAD) {
|
||||||
$item['link_color'] = '#FC4444';
|
$item['link_color'] = '#FC4444';
|
||||||
} else if ($item['status_start'] == AGENT_MODULE_STATUS_WARNING) {
|
} 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) {
|
if ($item['status_end'] == AGENT_MODULE_STATUS_CRITICAL_BAD) {
|
||||||
$item['link_color'] = '#FC4444';
|
$item['link_color'] = '#FC4444';
|
||||||
} else if ($item['status_end'] == AGENT_MODULE_STATUS_WARNING) {
|
} 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)
|
} else if (($relation['parent_type'] == NODE_PANDORA)
|
||||||
&& ($relation['child_type'] == 3)
|
&& ($relation['child_type'] == NODE_PANDORA)
|
||||||
) {
|
) {
|
||||||
foreach ($nodes_graph as $key2 => $node) {
|
foreach ($nodes_graph as $key2 => $node) {
|
||||||
if ($relation['id_parent'] == $node['id_db']) {
|
if ($relation['id_parent'] == $node['id_db']) {
|
||||||
@ -1891,10 +1903,10 @@ function networkmap_links_to_js_links(
|
|||||||
$agent2 = $node['id_db'];
|
$agent2 = $node['id_db'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (($relation['parent_type'] == 3)
|
} else if (($relation['parent_type'] == NODE_PANDORA)
|
||||||
|| ($relation['child_type'] == 3)
|
|| ($relation['child_type'] == NODE_PANDORA)
|
||||||
) {
|
) {
|
||||||
if ($relation['parent_type'] == 3) {
|
if ($relation['parent_type'] == NODE_PANDORA) {
|
||||||
foreach ($nodes_graph as $key2 => $node) {
|
foreach ($nodes_graph as $key2 => $node) {
|
||||||
if ($relation['id_parent'] == $node['id_db']) {
|
if ($relation['id_parent'] == $node['id_db']) {
|
||||||
$agent = $node['id_db'];
|
$agent = $node['id_db'];
|
||||||
@ -1902,7 +1914,7 @@ function networkmap_links_to_js_links(
|
|||||||
$agent2 = $node['id_db'];
|
$agent2 = $node['id_db'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ($relation['child_type'] == 3) {
|
} else if ($relation['child_type'] == NODE_PANDORA) {
|
||||||
foreach ($nodes_graph as $key2 => $node) {
|
foreach ($nodes_graph as $key2 => $node) {
|
||||||
if ($relation['id_child'] == $node['id_db']) {
|
if ($relation['id_child'] == $node['id_db']) {
|
||||||
$agent2 = $node['id_db'];
|
$agent2 = $node['id_db'];
|
||||||
@ -1932,8 +1944,8 @@ function networkmap_links_to_js_links(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((($item['target'] == -1) || ($item['source'] == -1))
|
if ((($item['target'] == -1) || ($item['source'] == -1))
|
||||||
&& $relation['parent_type'] == 1
|
&& $relation['parent_type'] == NODE_MODULE
|
||||||
&& $relation['child_type'] == 1
|
&& $relation['child_type'] == NODE_MODULE
|
||||||
) {
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -2190,10 +2202,11 @@ function networkmap_loadfile(
|
|||||||
if (preg_match('/^node.*$/', $line) != 0) {
|
if (preg_match('/^node.*$/', $line) != 0) {
|
||||||
$items = explode(' ', $line);
|
$items = explode(' ', $line);
|
||||||
$node_id = $items[1];
|
$node_id = $items[1];
|
||||||
|
|
||||||
|
// 200 for larger maps
|
||||||
$node_x = ($items[2] * 100);
|
$node_x = ($items[2] * 100);
|
||||||
// 200 is for show more big
|
|
||||||
$node_y = ($height_map - $items[3] * 100);
|
$node_y = ($height_map - $items[3] * 100);
|
||||||
// 200 is for show more big
|
// 200 for larger maps
|
||||||
$data['id'] = $node_id;
|
$data['id'] = $node_id;
|
||||||
$data['text'] = '';
|
$data['text'] = '';
|
||||||
$data['image'] = '';
|
$data['image'] = '';
|
||||||
@ -2306,7 +2319,10 @@ function networkmap_loadfile(
|
|||||||
$relations_param[] = $row;
|
$relations_param[] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $networkmap_nodes;
|
return [
|
||||||
|
'nodes' => $networkmap_nodes,
|
||||||
|
'relations' => $relations_param,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -473,8 +473,7 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
|
|||||||
$self->{'pa_config'}, $self->{'pa_config'}->{'servername'},
|
$self->{'pa_config'}, $self->{'pa_config'}->{'servername'},
|
||||||
$host_name, $device, $self->{'group_id'}, 0, $id_os,
|
$host_name, $device, $self->{'group_id'}, 0, $id_os,
|
||||||
'', 300, $self->{'dbh'}, undef, $location->{'longitude'},
|
'', 300, $self->{'dbh'}, undef, $location->{'longitude'},
|
||||||
$location->{'latitude'}, undef, undef, undef, undef,
|
$location->{'latitude'}
|
||||||
undef, undef, $self->{'main_event_id'}
|
|
||||||
);
|
);
|
||||||
return undef unless defined ($agent_id) and ($agent_id > 0);
|
return undef unless defined ($agent_id) and ($agent_id > 0);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user