minor changes in demo data functionality
This commit is contained in:
parent
cb60581bcf
commit
75ddb3b934
|
@ -233,7 +233,6 @@ if ($display_loading === true || $running_create === true || $running_delete) {
|
|||
$table_aux->size[1] = '50%';
|
||||
|
||||
$agent_sel_values = [
|
||||
10 => '10',
|
||||
30 => '30',
|
||||
50 => '50',
|
||||
500 => '500',
|
||||
|
@ -505,52 +504,6 @@ if ($display_loading === true || $running_create === true || $running_delete) {
|
|||
)
|
||||
);
|
||||
|
||||
/* $table_adv->data['row8'][] = html_print_label_input_block(
|
||||
__('Create dashboards'),
|
||||
html_print_checkbox_switch(
|
||||
'enable_dashboards',
|
||||
1,
|
||||
$enabled_items['dashboards'],
|
||||
true
|
||||
)
|
||||
);
|
||||
$table_adv->data['row8'][] = html_print_label_input_block(
|
||||
__('Create dashboards'),
|
||||
html_print_checkbox_switch(
|
||||
'enable_dashboards',
|
||||
1,
|
||||
$enabled_items['dashboards'],
|
||||
true
|
||||
)
|
||||
);
|
||||
$table_adv->data['row8'][] = html_print_label_input_block(
|
||||
__('Create dashboards'),
|
||||
html_print_checkbox_switch(
|
||||
'enable_dashboards',
|
||||
1,
|
||||
$enabled_items['dashboards'],
|
||||
true
|
||||
)
|
||||
);
|
||||
$table_adv->data['row8'][] = html_print_label_input_block(
|
||||
__('Create dashboards'),
|
||||
html_print_checkbox_switch(
|
||||
'enable_dashboards',
|
||||
1,
|
||||
$enabled_items['dashboards'],
|
||||
true
|
||||
)
|
||||
);
|
||||
$table_adv->data['row8'][] = html_print_label_input_block(
|
||||
__('Create dashboards'),
|
||||
html_print_checkbox_switch(
|
||||
'enable_dashboards',
|
||||
1,
|
||||
$enabled_items['dashboards'],
|
||||
true
|
||||
)
|
||||
);*/
|
||||
|
||||
echo '<form class="max_floating_element_size" id="form_setup" method="post">';
|
||||
echo '<fieldset>';
|
||||
echo '<legend>'.__('Configure demo data').'</legend>';
|
||||
|
|
|
@ -134,6 +134,7 @@ if ($action === 'create_demo_data') {
|
|||
|
||||
$agent_created_total = 0;
|
||||
$agent_data_values_buffer = [];
|
||||
$agent_traps_values_buffer = [];
|
||||
|
||||
if ($total_agents_to_create > 0 && $agents_to_create > 0) {
|
||||
while ($agent_created_total < ($total_agents_to_create - 1)) {
|
||||
|
@ -798,35 +799,8 @@ if ($action === 'create_demo_data') {
|
|||
'utimestamp' => $utimestamp,
|
||||
];
|
||||
|
||||
$created_trap_id = db_process_sql_insert('ttrap', $values);
|
||||
|
||||
if ($created_trap_id > 0) {
|
||||
// Register created demo item in tdemo_data.
|
||||
$values = [
|
||||
'item_id' => $created_trap_id,
|
||||
'table_name' => 'ttrap',
|
||||
];
|
||||
$result = (bool) db_process_sql_insert('tdemo_data', $values);
|
||||
|
||||
if ($result === false) {
|
||||
// Rollback inventory module if could not be registered in tdemo_data.
|
||||
db_process_sql_delete('ttrap', ['id_module_inventory' => $created_trap_id]);
|
||||
|
||||
register_error(
|
||||
DEMO_AGENT,
|
||||
__('Uncaught error (source %s): could not create trap with index %d', $filename, ($trap_access_idx - 1)),
|
||||
true
|
||||
);
|
||||
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
register_error(
|
||||
DEMO_AGENT,
|
||||
__('Uncaught error (source %s): could not create trap with index %d', $filename, ($trap_access_idx - 1)),
|
||||
true
|
||||
);
|
||||
}
|
||||
// Buffer history traps for later bulk insertion (performance reasons).
|
||||
$agent_traps_values_buffer[] = $values;
|
||||
}
|
||||
|
||||
if ($adv_options_is_enabled === false
|
||||
|
@ -850,10 +824,11 @@ if ($action === 'create_demo_data') {
|
|||
}
|
||||
}
|
||||
|
||||
$agent_data_values_buffer_chunks = array_chunk($agent_data_values_buffer, 1000);
|
||||
$agent_data_values_buffer_chunks = array_chunk($agent_data_values_buffer, 100000);
|
||||
$agent_traps_values_buffer_chunks = array_chunk($agent_traps_values_buffer, 100000);
|
||||
|
||||
foreach ($agent_data_values_buffer_chunks as $chunk) {
|
||||
// Bulk inserts.
|
||||
// Bulk inserts (insert batches of up to 100,000 as a performance limit).
|
||||
mysql_db_process_sql_insert_multiple(
|
||||
'tagente_datos',
|
||||
$chunk,
|
||||
|
@ -861,6 +836,52 @@ if ($action === 'create_demo_data') {
|
|||
);
|
||||
}
|
||||
|
||||
// Get last trap in database.
|
||||
$id_trap_begin = db_get_value(
|
||||
'MAX(id_trap)',
|
||||
'ttrap',
|
||||
1,
|
||||
1,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
if ($id_trap_begin === false) {
|
||||
$id_trap_begin = 0;
|
||||
}
|
||||
|
||||
foreach ($agent_traps_values_buffer_chunks as $chunk) {
|
||||
// Bulk inserts (insert batches of up to 100,000 as a performance limit).
|
||||
mysql_db_process_sql_insert_multiple(
|
||||
'ttrap',
|
||||
$chunk,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
// Get last trap in database after insertion.
|
||||
$id_trap_end = db_get_value(
|
||||
'MAX(id_trap)',
|
||||
'ttrap',
|
||||
1,
|
||||
1,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
if ($id_trap_end === false) {
|
||||
$id_trap_end = 0;
|
||||
}
|
||||
|
||||
for ($i = ($id_trap_begin + 1); $i <= $id_trap_end; $i++) {
|
||||
// Register created demo item in tdemo_data.
|
||||
$values = [
|
||||
'item_id' => $i,
|
||||
'table_name' => 'ttrap',
|
||||
];
|
||||
db_process_sql_insert('tdemo_data', $values);
|
||||
}
|
||||
|
||||
update_item_checked(DEMO_AGENT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -699,6 +699,45 @@ class WelcomeWindow extends Wizard
|
|||
echo html_print_submit_button(__('Create'), 'create_goliat', false, ['icon' => 'next', 'style' => 'margin-top:15px; float:right;']);
|
||||
?>
|
||||
</div>
|
||||
<div id="dialog_demo" class="invisible">
|
||||
<?php
|
||||
$agent_sel_values = [
|
||||
30 => '30',
|
||||
50 => '50',
|
||||
500 => '500',
|
||||
1000 => '1000',
|
||||
2000 => '2000',
|
||||
];
|
||||
|
||||
echo '<form action="index.php?sec=gsetup&sec2=godmode/setup/setup§ion=demo_data" method="post">';
|
||||
echo html_print_input_hidden('create_data', 1, true);
|
||||
echo html_print_input_hidden('display_loading', 1, true);
|
||||
echo html_print_label_input_block(
|
||||
__('Number of agents to be created'),
|
||||
html_print_div(
|
||||
[
|
||||
'class' => '',
|
||||
'content' => html_print_select(
|
||||
$agent_sel_values,
|
||||
'agents_num',
|
||||
$agents_num,
|
||||
'',
|
||||
'',
|
||||
30,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'w100px'
|
||||
),
|
||||
],
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
echo html_print_submit_button(__('Create'), 'create_demo_data', false, ['icon' => 'next', 'style' => 'margin-top:15px; float:right;']);
|
||||
echo '</form>';
|
||||
?>
|
||||
</div>
|
||||
<div id="dialog_connectivity" class="invisible">
|
||||
<?php
|
||||
echo html_print_input_hidden('check_connectivity', 1);
|
||||
|
@ -1114,7 +1153,7 @@ class WelcomeWindow extends Wizard
|
|||
} else {
|
||||
switch($('#task_to_perform :selected').val()) {
|
||||
case 'load_demo_data':
|
||||
loadDemoDataPage();
|
||||
openCreateDemoDataDialog();
|
||||
break;
|
||||
case 'wizard_agent':
|
||||
deployAgent();
|
||||
|
@ -1156,11 +1195,6 @@ class WelcomeWindow extends Wizard
|
|||
window.location = '<?php echo ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&show_deploy_agent=1'); ?>';
|
||||
}
|
||||
|
||||
// Task to do actions.
|
||||
function loadDemoDataPage() {
|
||||
window.location = '<?php echo ui_get_full_url('index.php?sec=gagente&sec2=godmode/setup/setup§ion=demo_data'); ?>';
|
||||
}
|
||||
|
||||
function openCreateModulesDialog() {
|
||||
$('#dialog_goliat').dialog({
|
||||
title: '<?php echo __('Create WEB monitoring'); ?>',
|
||||
|
@ -1178,6 +1212,23 @@ class WelcomeWindow extends Wizard
|
|||
.show();
|
||||
}
|
||||
|
||||
function openCreateDemoDataDialog() {
|
||||
$('#dialog_demo').dialog({
|
||||
title: '<?php echo __('Create demo data'); ?>',
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
close: false,
|
||||
height: 200,
|
||||
width: 480,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
function openCreateConnectivityDialog() {
|
||||
$('#dialog_connectivity').dialog({
|
||||
title: '<?php echo __('Create network monitoring'); ?>',
|
||||
|
|
Loading…
Reference in New Issue