Merge branch 'ent-10118-creacion-de-mapas-de-red' into 'develop'
Ent 10118 creacion de mapas de red See merge request artica/pandorafms!5531
This commit is contained in:
commit
472ffdf443
|
@ -2,6 +2,8 @@ START TRANSACTION;
|
|||
|
||||
ALTER TABLE `tserver` ADD COLUMN `server_keepalive_utimestamp` BIGINT NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE `tmap` MODIFY COLUMN `id_group` TEXT NOT NULL default '';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tmonitor_filter` (
|
||||
`id_filter` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_name` VARCHAR(600) NOT NULL,
|
||||
|
|
|
@ -782,7 +782,9 @@ class NetworkMap
|
|||
if ($this->network) {
|
||||
// Network map, based on direct network.
|
||||
$nodes = networkmap_get_nodes_from_ip_mask(
|
||||
$this->network
|
||||
$this->network,
|
||||
false,
|
||||
'
'
|
||||
);
|
||||
} else if ($this->mapOptions['map_filter']['empty_map']) {
|
||||
// Empty map returns no data.
|
||||
|
@ -792,17 +794,22 @@ class NetworkMap
|
|||
|| $this->mapOptions['map_filter']['dont_show_subgroups'] == 1
|
||||
) {
|
||||
// Show only current selected group.
|
||||
$filter['id_grupo'] = $this->idGroup;
|
||||
$filter['id_grupo'] = explode(',', $this->idGroup);
|
||||
} else {
|
||||
// Show current group and children.
|
||||
$childrens = groups_get_children($this->idGroup, null, true);
|
||||
if (!empty($childrens)) {
|
||||
$childrens = array_keys($childrens);
|
||||
foreach (explode(',', $this->idGroup) as $key => $group) {
|
||||
$childrens = groups_get_children($group, null, true);
|
||||
if (!empty($childrens)) {
|
||||
$childrens = array_keys($childrens);
|
||||
|
||||
$filter['id_grupo'] = $childrens;
|
||||
$filter['id_grupo'][] = $this->idGroup;
|
||||
} else {
|
||||
$filter['id_grupo'] = $this->idGroup;
|
||||
if (empty($filter['id_grupo']) === false) {
|
||||
$filter['id_grupo'] = array_merge($filter['id_grupo'], $childrens);
|
||||
} else {
|
||||
$filter['id_grupo'] = $childrens;
|
||||
}
|
||||
} else {
|
||||
$filter['id_grupo'][] = $group;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1356,9 +1356,10 @@ function networkmap_get_types($strict_user=false)
|
|||
*/
|
||||
function networkmap_get_nodes_from_ip_mask(
|
||||
$ip_mask,
|
||||
$return_ids_only=false
|
||||
$return_ids_only=false,
|
||||
$separator=',',
|
||||
) {
|
||||
$list_ip_masks = explode(',', $ip_mask);
|
||||
$list_ip_masks = explode($separator, $ip_mask);
|
||||
|
||||
if (empty($list_ip_masks) === true) {
|
||||
return [];
|
||||
|
@ -1375,14 +1376,14 @@ function networkmap_get_nodes_from_ip_mask(
|
|||
$sql = sprintf(
|
||||
'SELECT *
|
||||
FROM `tagente`
|
||||
INNER JOIN
|
||||
(SELECT DISTINCT `id_agent` FROM
|
||||
INNER JOIN
|
||||
(SELECT DISTINCT `id_agent` FROM
|
||||
(SELECT `id_agente` AS "id_agent", `direccion` AS "ip"
|
||||
FROM `tagente`
|
||||
FROM `tagente`
|
||||
UNION
|
||||
SELECT ag.`id_agent`, a.`ip`
|
||||
FROM `taddress_agent` ag
|
||||
INNER JOIN `taddress` a
|
||||
FROM `taddress_agent` ag
|
||||
INNER JOIN `taddress` a
|
||||
ON ag.id_a=a.id_a
|
||||
) t_tmp
|
||||
WHERE (-1 << %d) & INET_ATON(t_tmp.ip) = INET_ATON("%s")
|
||||
|
|
|
@ -273,6 +273,25 @@ if (!empty($result)) {
|
|||
if ($not_found) {
|
||||
ui_print_error_message(__('Not found networkmap.'));
|
||||
} else {
|
||||
if ($disabled_source === false) {
|
||||
echo '<div id="map_loading" style="width: 98%;height: 1000px; background-color: rgba(245, 245, 245, .3);position: absolute;display: flex;justify-content: center;align-items: center;flex-direction: column-reverse;">';
|
||||
echo html_print_image('images/spinner.gif', true, 'width: 50px;height: 50px;');
|
||||
echo '<div>'.__('Creating map...').'</div>';
|
||||
echo '</div>';
|
||||
$info1 = __('To create a network map that visually recreates link-level (L2) relationships, you must first discover these relationships with Discovery Server. Network maps only reflect relationships that have already been discovered.');
|
||||
$separator = '<br>';
|
||||
$info2 = __('Discovery Server discovers relationships between interfaces (L2) through SNMP and relationships between hosts (L3) through route discovery.');
|
||||
$info3 = __('You can also create these relationships manually by editing nodes or re-passing a discovery task after adding new information (for example by adding new SNMP communities).');
|
||||
$info4 = __('See our documentation for more information.');
|
||||
ui_print_info_message(
|
||||
[
|
||||
'no_close' => false,
|
||||
'message' => $info1.$separator.$info2.$separator.$info3.$separator.$info4,
|
||||
],
|
||||
'style="width: 98%;"'
|
||||
);
|
||||
}
|
||||
|
||||
$table = new stdClass();
|
||||
$table->id = 'form_editor';
|
||||
|
||||
|
@ -337,7 +356,14 @@ if ($not_found) {
|
|||
);
|
||||
|
||||
$table->data[3][0] = __('Description');
|
||||
$table->data[3][1] = html_print_textarea('description', 7, 25, $description, '', true);
|
||||
$table->data[3][1] = html_print_input_text(
|
||||
'description',
|
||||
$description,
|
||||
'',
|
||||
100,
|
||||
100,
|
||||
true
|
||||
);
|
||||
|
||||
$table->data[4][0] = __('Position X');
|
||||
$table->data[4][1] = html_print_input_text('pos_x', $offset_x, '', 2, 10, true);
|
||||
|
@ -352,7 +378,23 @@ if ($not_found) {
|
|||
$table->data[6][1] = html_print_input_text('scale_z', $scale_z, '', 2, 10, true).ui_print_help_tip(__('Introduce zoom level. 1 = Highest resolution. Figures may include decimals'), true);
|
||||
|
||||
$table->data['source'][0] = __('Source');
|
||||
$table->data['source'][1] = html_print_radio_button('source', 'group', __('Group'), $source, true, $disabled_source).html_print_radio_button('source', 'recon_task', __('Discovery task'), $source, true, $disabled_source).html_print_radio_button('source', 'ip_mask', __('CIDR IP mask'), $source, true, $disabled_source);
|
||||
$table->data['source'][1] = html_print_select(
|
||||
[
|
||||
'group' => __('Group'),
|
||||
'recon_task' => __('Discovery task'),
|
||||
'ip_mask' => __('CIDR IP mask'),
|
||||
],
|
||||
'source',
|
||||
$source,
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
$disabled_source
|
||||
);
|
||||
|
||||
$table->data['source_data_recon_task'][0] = __('Source from recon task');
|
||||
$table->data['source_data_recon_task'][0] .= ui_print_help_tip(
|
||||
|
@ -378,18 +420,28 @@ if ($not_found) {
|
|||
);
|
||||
|
||||
$table->data['source_data_ip_mask'][0] = __('Source from CIDR IP mask');
|
||||
$table->data['source_data_ip_mask'][1] = html_print_input_text('ip_mask', $ip_mask, '', 20, 255, true, $disabled_source);
|
||||
$table->data['source_data_ip_mask'][1] = html_print_textarea(
|
||||
'ip_mask',
|
||||
3,
|
||||
5,
|
||||
$ip_mask,
|
||||
'style="width: 238px"',
|
||||
true,
|
||||
'',
|
||||
$disabled_source
|
||||
);
|
||||
|
||||
$table->data['source_data_group'][0] = __('Source group');
|
||||
$table->data['source_data_group'][1] = '<div class="w250px">'.html_print_select_groups(
|
||||
$config['id_user'],
|
||||
'AR',
|
||||
true,
|
||||
'id_group',
|
||||
$id_group,
|
||||
'id_group[]',
|
||||
explode(',', $id_group),
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true
|
||||
).'</div>';
|
||||
$table->data['source_data_group'][1] .= html_print_image(
|
||||
|
@ -498,9 +550,10 @@ if ($not_found) {
|
|||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function() {
|
||||
$("input[name='source']").on('change', function() {
|
||||
var source = $("input[name='source']:checked").val();
|
||||
|
||||
$("#map_loading").hide();
|
||||
$("#source").change(function() {
|
||||
const source = $(this).val();
|
||||
|
||||
if (source == 'recon_task') {
|
||||
$("#form_editor-source_data_ip_mask")
|
||||
.css('display', 'none');
|
||||
|
@ -510,7 +563,6 @@ $(document).ready(function() {
|
|||
.css('display', 'none');
|
||||
$("#form_editor-source_data_recon_task")
|
||||
.css('display', '');
|
||||
|
||||
}
|
||||
else if (source == 'ip_mask') {
|
||||
$("#form_editor-source_data_ip_mask")
|
||||
|
@ -598,17 +650,15 @@ $(document).ready(function() {
|
|||
.css('display', '');
|
||||
}
|
||||
});
|
||||
|
||||
$("input[name='source']").trigger("change");
|
||||
|
||||
$("#source").trigger("change");
|
||||
$("#method").trigger("change");
|
||||
|
||||
|
||||
// Control if id_group has changed.
|
||||
var id_group_old = $("#id_group").val();
|
||||
var id_group_changed = false;
|
||||
|
||||
$("#id_group").on('change',{id_group_old: id_group_old}, function () {
|
||||
|
||||
var id_group_new = $("#id_group").val();
|
||||
if((id_group_old != id_group_new) && (update_networkmap == 1 )) {
|
||||
id_group_changed = true;
|
||||
|
@ -625,7 +675,7 @@ $(document).ready(function() {
|
|||
update_networkmap = $("input[name='update_networkmap']").val();
|
||||
|
||||
$( "#submit-crt" ).click(function( event ) {
|
||||
|
||||
$("#map_loading").show();
|
||||
if(update_networkmap == 1 && id_group_changed === true) {
|
||||
confirmDialog({
|
||||
title: '<?php echo __('Are you sure?'); ?>',
|
||||
|
@ -643,7 +693,6 @@ $(document).ready(function() {
|
|||
})
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$("#refresh_time_units").trigger("change");
|
||||
|
|
|
@ -182,7 +182,7 @@ if ($save_empty_networkmap === true) {
|
|||
|
||||
$values = [];
|
||||
$values['name'] = $name;
|
||||
$values['id_group'] = $id_group;
|
||||
$values['id_group'] = implode(',', $id_group);
|
||||
|
||||
$values['generation_method'] = 4;
|
||||
|
||||
|
@ -237,7 +237,7 @@ if ($new_networkmap || $save_networkmap) {
|
|||
}
|
||||
|
||||
if ($save_networkmap) {
|
||||
$id_group = (int) get_parameter('id_group', 0);
|
||||
$id_group = get_parameter('id_group', 0);
|
||||
$id_group_map = (int) get_parameter('id_group_map', 0);
|
||||
|
||||
|
||||
|
@ -292,7 +292,7 @@ if ($new_networkmap || $save_networkmap) {
|
|||
|
||||
$values = [];
|
||||
$values['name'] = $name;
|
||||
$values['id_group'] = $id_group;
|
||||
$values['id_group'] = implode(',', $id_group);
|
||||
$values['source_period'] = 60;
|
||||
$values['width'] = $width;
|
||||
$values['height'] = $height;
|
||||
|
@ -333,7 +333,7 @@ if ($new_networkmap || $save_networkmap) {
|
|||
|
||||
if ($source == 'group') {
|
||||
$values['source'] = 0;
|
||||
$values['source_data'] = $id_group;
|
||||
$values['source_data'] = implode(',', $id_group);
|
||||
} else if ($source == 'recon_task') {
|
||||
$values['source'] = 1;
|
||||
$values['source_data'] = $recon_task_id;
|
||||
|
@ -444,7 +444,7 @@ else if ($update_networkmap || $copy_networkmap || $delete) {
|
|||
}
|
||||
|
||||
if ($update_networkmap) {
|
||||
$id_group = (int) get_parameter('id_group', 0);
|
||||
$id_group = get_parameter('id_group', 0);
|
||||
// Get id of old group source to check changes.
|
||||
$id_group_old = db_get_value('id_group', 'tmap', 'id', $id);
|
||||
|
||||
|
@ -480,7 +480,7 @@ else if ($update_networkmap || $copy_networkmap || $delete) {
|
|||
|
||||
$values = [];
|
||||
$values['name'] = $name;
|
||||
$values['id_group'] = $id_group;
|
||||
$values['id_group'] = implode(',', $id_group);
|
||||
$values['id_group_map'] = $id_group_map;
|
||||
|
||||
$description = get_parameter('description', '');
|
||||
|
|
|
@ -171,7 +171,23 @@ if (is_ajax() === true) {
|
|||
$table->data[6][1] = html_print_input_text('scale_z', $map_filter['z_dash'], '', 2, 10, true).ui_print_help_tip(__('Introduce zoom level. 1 = Highest resolution. Figures may include decimals'), true);
|
||||
|
||||
$table->data['source'][0] = __('Source');
|
||||
$table->data['source'][1] = html_print_radio_button('source', 'group', __('Group'), $source, true).html_print_radio_button('source', 'recon_task', __('Discovery task'), $source, true).html_print_radio_button('source', 'ip_mask', __('CIDR IP mask'), $source, true);
|
||||
$table->data['source'][1] = html_print_select(
|
||||
[
|
||||
'group' => __('Group'),
|
||||
'recon_task' => __('Discovery task'),
|
||||
'ip_mask' => __('CIDR IP mask'),
|
||||
],
|
||||
'source',
|
||||
$source,
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
$disabled_source
|
||||
);
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
$sql = sprintf(
|
||||
|
@ -221,7 +237,16 @@ if (is_ajax() === true) {
|
|||
);
|
||||
|
||||
$table->data['source_data_ip_mask'][0] = __('Source from CIDR IP mask');
|
||||
$table->data['source_data_ip_mask'][1] = html_print_input_text('ip_mask', $map_info['source_data'], '', 20, 255, true);
|
||||
$table->data['source_data_ip_mask'][1] = html_print_textarea(
|
||||
'ip_mask',
|
||||
3,
|
||||
5,
|
||||
$map_info['source_data'],
|
||||
'',
|
||||
true,
|
||||
'',
|
||||
$disabled_source
|
||||
);
|
||||
|
||||
$dont_show_subgroups = 0;
|
||||
if (isset($map_filter['dont_show_subgroups'])) {
|
||||
|
@ -296,9 +321,9 @@ if (is_ajax() === true) {
|
|||
$map_form .= html_print_table($table, true);
|
||||
|
||||
$map_form .= '<script>
|
||||
$("input[name=\'source\']").on(\'change\', function() {
|
||||
var source = $("input[name=\'source\']:checked").val();
|
||||
|
||||
$("#source").change(function() {
|
||||
const source = $(this).val();
|
||||
|
||||
if (source == \'recon_task\') {
|
||||
$("#form_editor-source_data_ip_mask")
|
||||
.css(\'display\', \'none\');
|
||||
|
@ -388,8 +413,8 @@ if (is_ajax() === true) {
|
|||
.css(\'display\', \'\');
|
||||
}
|
||||
});
|
||||
|
||||
$("input[name=\'source\']").trigger("change");
|
||||
|
||||
$("#source").trigger("change");
|
||||
$("#method").trigger("change");
|
||||
</script>';
|
||||
|
||||
|
|
|
@ -2323,7 +2323,7 @@ CREATE TABLE IF NOT EXISTS `tsessions_php` (
|
|||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tmap` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_group` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`id_group` TEXT NOT NULL DEFAULT '',
|
||||
`id_user` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`type` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`subtype` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
|
|
Loading…
Reference in New Issue