Merge branch 'ent-10906-Carga-de-datos-de-demo' of brutus.artica.es:artica/pandorafms into ent-10906-Carga-de-datos-de-demo

This commit is contained in:
alejandro.campos@artica.es 2023-12-04 11:37:41 +01:00
commit 4a64f023fe
6 changed files with 587 additions and 36 deletions

View File

@ -146,4 +146,66 @@ total_size[3]="819M"
mount_point[1]="/home"
mount_point[2]="/"
mount_point[3]="/tmp"
mount_point[3]="/tmp"
[log_modules]
source[1]="httpd"
data[1]='127.0.0.1 - "GET /index.html HTTP/1.1" 200 3456 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"'
source[2]="httpd"
data[2]='192.168.1.1 - "POST /submit.php HTTP/1.1" 302 0 "https://example.com/form" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"'
source[3]="httpd"
data[3]='10.0.0.2 - "GET /images/logo.png HTTP/1.1" 304 0 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.1 Mobile/15E148 Safari/604.1"'
source[4]="httpd"
data[4]='172.16.0.1 - "GET /page/about-us HTTP/1.1" 404 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"'
source[5]="httpd"
data[5]='192.168.0.10 - "GET /css/style.css HTTP/1.1" 200 768 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"'
source[6]="httpd"
data[6]='203.0.113.45 - "GET /blog/post-123 HTTP/1.1" 200 5432 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"'
source[7]="httpd"
data[7]='54.78.90.12 - "GET /category/api-reference HTTP/1.1" 200 6543 "-" "Mozilla/5.0 (Linux; Android 10; SM-G960U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.181 Mobile Safari/537.36"'
source[8]="httpd"
data[8]='88.77.66.55 - "GET /contact-us HTTP/1.1" 301 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"'
source[9]="httpd"
data[9]='198.51.100.23 - "GET /images/photo.jpg HTTP/1.1" 200 4567 "https://example.com/gallery" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"'
source[10]="httpd"
data[10]='128.0.0.1 - "GET /downloads/file.zip HTTP/1.1" 200 12345 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"'
source[11]="mysqld"
data[11]="[Warning] Aborted connection 123 to db: 'your_database' user: 'your_user' host: '192.168.1.100' (Got an error reading communication packets)"
source[12]="mysqld"
data[12]="[ERROR] Table 'your_database.your_table' doesn't exist"
source[13]="mysqld"
data[13]="[Note] Starting crash recovery..."
source[14]="mysqld"
data[14]="[Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a LIMIT clause. Use a different log bin event type."
source[15]="mysqld"
data[15]="[ERROR] Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space"
source[16]="mysqld"
data[16]="[Note] Aborted connection 456 to db: 'another_database' user: 'another_user' host: 'localhost' (Got timeout reading communication packets)"
source[17]="mysqld"
data[17]="[ERROR] Can't create a new thread (errno 11); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug"
source[18]="mysqld"
data[18]="[Warning] 'user' entry 'your_user@localhost' ignored in --skip-name-resolve mode."
source[19]="mysqld"
data[19]="[Note] InnoDB: Starting rollback of uncommitted transactions"
source[20]="mysqld"
data[20]="[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed."

View File

@ -0,0 +1,16 @@
[gis_data]
name="Demo GIS map"
group="Demo servers"
zoom_level="6"
initial_latitude="40"
initial_longitude="-3"
initial_altitude="0"
default_latitude="40"
default_longitude="-3"
default_altitude="0"
[gis_layers]
name[1]="Demo servers"
group[1]="Demo servers"

View File

@ -56,6 +56,7 @@ $service_agent_name = get_parameter('service_agent_name', 'demo-global-agent-1')
$dir_item_id_map = [
DEMO_CUSTOM_GRAPH => 'graphs',
DEMO_NETWORK_MAP => 'network_maps',
DEMO_GIS_MAP => 'gis_maps',
DEMO_SERVICE => 'services',
DEMO_REPORT => 'reports',
DEMO_DASHBOARD => 'dashboards',
@ -65,6 +66,7 @@ $dir_item_id_map = [
$enabled_items = [
'graphs' => (int) get_parameter('enable_cg', $def_value),
'network_maps' => (int) get_parameter('enable_nm', $def_value),
'gis_maps' => (int) get_parameter('enable_gis', $def_value),
'services' => (int) get_parameter('enable_services', $def_value),
'reports' => (int) get_parameter('enable_rep', $def_value),
'dashboards' => (int) get_parameter('enable_dashboards', $def_value),
@ -135,6 +137,7 @@ if ($display_loading === true || $running_create === true || $running_delete) {
DEMO_AGENT => 'agents',
DEMO_SERVICE => 'services',
DEMO_NETWORK_MAP => 'network maps',
DEMO_GIS_MAP => 'GIS maps',
DEMO_CUSTOM_GRAPH => 'custom graphs',
DEMO_REPORT => 'custom reports',
DEMO_VISUAL_CONSOLE => 'visual consoles',
@ -369,6 +372,16 @@ if ($display_loading === true || $running_create === true || $running_delete) {
);
$table_adv->data['row6'][] = html_print_label_input_block(
__('Create GIS maps'),
html_print_checkbox_switch(
'enable_gis',
1,
$enabled_items['gis_maps'],
true
)
);
$table_adv->data['row7'][] = html_print_label_input_block(
__('Create custom graphs'),
html_print_checkbox_switch(
'enable_cg',
@ -378,7 +391,7 @@ if ($display_loading === true || $running_create === true || $running_delete) {
)
);
$table_adv->data['row7'][] = html_print_label_input_block(
$table_adv->data['row8'][] = html_print_label_input_block(
__('Create reports'),
html_print_checkbox_switch(
'enable_rep',
@ -388,7 +401,7 @@ if ($display_loading === true || $running_create === true || $running_delete) {
)
);
$table_adv->data['row8'][] = html_print_label_input_block(
$table_adv->data['row9'][] = html_print_label_input_block(
__('Create visual consoles'),
html_print_checkbox_switch(
'enable_vc',
@ -398,7 +411,7 @@ if ($display_loading === true || $running_create === true || $running_delete) {
)
);
$table_adv->data['row9'][] = html_print_label_input_block(
$table_adv->data['row10'][] = html_print_label_input_block(
__('Create dashboards'),
html_print_checkbox_switch(
'enable_dashboards',
@ -408,7 +421,7 @@ if ($display_loading === true || $running_create === true || $running_delete) {
)
);
$table_adv->data['row10'][] = html_print_label_input_block(
$table_adv->data['row11'][] = html_print_label_input_block(
__('Demo data plugin agent'),
html_print_input_text(
'plugin_agent',
@ -424,7 +437,7 @@ if ($display_loading === true || $running_create === true || $running_delete) {
)
);
$table_adv->data['row11'][] = html_print_label_input_block(
$table_adv->data['row12'][] = html_print_label_input_block(
__('Traps target IP').ui_print_help_tip(__('All demo traps are generated using version 1'), true),
html_print_input_text(
'traps_target_ip',
@ -440,7 +453,7 @@ if ($display_loading === true || $running_create === true || $running_delete) {
)
);
$table_adv->data['row12'][] = html_print_label_input_block(
$table_adv->data['row13'][] = html_print_label_input_block(
__('Traps community'),
html_print_input_text(
'traps_community',
@ -456,7 +469,7 @@ if ($display_loading === true || $running_create === true || $running_delete) {
)
);
$table_adv->data['row13'][] = html_print_label_input_block(
$table_adv->data['row14'][] = html_print_label_input_block(
__('Tentacle target IP'),
html_print_input_text(
'tentacle_target_ip',
@ -472,7 +485,7 @@ if ($display_loading === true || $running_create === true || $running_delete) {
)
);
$table_adv->data['row14'][] = html_print_label_input_block(
$table_adv->data['row15'][] = html_print_label_input_block(
__('Tentacle port'),
html_print_input_text(
'tentacle_port',
@ -488,7 +501,7 @@ if ($display_loading === true || $running_create === true || $running_delete) {
)
);
$table_adv->data['row15'][] = html_print_label_input_block(
$table_adv->data['row16'][] = html_print_label_input_block(
__('Tentacle extra options'),
html_print_input_text(
'tentacle_extra_options',
@ -546,6 +559,7 @@ if ($display_loading === true || $running_create === true || $running_delete) {
$demo_agents_count = (int) db_get_value('count(*)', 'tdemo_data', 'table_name', 'tagente');
$demo_services_count = (int) db_get_value('count(*)', 'tdemo_data', 'table_name', 'tservice');
$demo_nm_count = (int) db_get_value('count(*)', 'tdemo_data', 'table_name', 'tmap');
$demo_gis_count = (int) db_get_value('count(*)', 'tdemo_data', 'table_name', 'tgis_map');
$demo_cg_count = (int) db_get_value('count(*)', 'tdemo_data', 'table_name', 'tgraph');
$demo_rep_count = (int) db_get_value('count(*)', 'tdemo_data', 'table_name', 'treport');
$demo_vc_count = (int) db_get_value('count(*)', 'tdemo_data', 'table_name', 'tlayout');
@ -575,6 +589,9 @@ if ($display_loading === true || $running_create === true || $running_delete) {
$table_summary->data[$i][0] = __('Network maps');
$table_summary->data[$i][1] = ($demo_nm_count > 0) ? $demo_nm_count : '-';
$i++;
$table_summary->data[$i][0] = __('GIS maps');
$table_summary->data[$i][1] = ($demo_gis_count > 0) ? $demo_gis_count : '-';
$i++;
$table_summary->data[$i][0] = __('Custom graphs');
$table_summary->data[$i][1] = ($demo_cg_count > 0) ? $demo_cg_count : '-';
$i++;

View File

@ -58,6 +58,7 @@ if ($action === 'create_demo_data') {
'reports',
'dashboards',
'visual_consoles',
'gis_maps',
];
$demodata_directory = $config['homedir'].'/extras/demodata/';
@ -296,10 +297,15 @@ if ($action === 'create_demo_data') {
}
}
$date_time = new DateTime();
$current_date_time = $date_time->format('Y-m-d H:i:s');
$values = [
'server_name' => $server_name,
'id_os' => $id_os,
'os_version' => $os_version,
'server_name' => $server_name,
'id_os' => $id_os,
'os_version' => $os_version,
'ultimo_contacto' => $current_date_time,
'ultimo_contacto_remoto' => $current_date_time,
];
$create_alias = $agent_data['agent_alias'].'-'.($agents_created_count[$agent_data['agent_alias']] + 1);
@ -529,6 +535,7 @@ if ($action === 'create_demo_data') {
'utimestamp' => $utimestamp,
'last_status' => 0,
'last_known_status' => 0,
'current_interval' => $agent_interval,
];
$status_id = db_get_value(
@ -1539,6 +1546,174 @@ if ($action === 'create_demo_data') {
register_error(DEMO_NETWORK_MAP, __('No configuration files found or failed to parse files'));
}
$gis_count = count($parsed_ini['gis_maps'] ?? []);
if ($gis_count > 0) {
// Enable GIS features
$token = 'activate_gis';
$activate_gis = db_get_value_filter('value', 'tconfig', ['token' => $token]);
if ($activate_gis === false) {
config_create_value($token, 1);
} else {
config_update_value($token, 1);
}
// Create GIS maps.
foreach ($parsed_ini['gis_maps'] as $ini_gis_data) {
$filename = $ini_gis_data['filename'];
$gis_data = $ini_gis_data['gis_data'];
$gis_layers = $ini_gis_data['gis_layers'];
if (isset($gis_data['name']) === false
|| is_string($gis_data['name']) === false
|| isset($gis_data['group']) === false
|| is_string($gis_data['group']) === false
) {
register_error(
DEMO_GIS_MAP,
__('Error in %s: name and/or group is not specified or does not have a valid format. Skipping GIS map creation', $filename)
);
continue;
}
$gis_name = $gis_data['name'];
$gis_group = $gis_data['group'];
$gis_zoom_level = (isset($gis_data['zoom_level']) === true) ? $gis_data['zoom_level'] : '6';
$gis_initial_latitude = (isset($gis_data['initial_latitude']) === true) ? $gis_data['initial_latitude'] : '0';
$gis_initial_longitude = (isset($gis_data['initial_longitude']) === true) ? $gis_data['initial_longitude'] : '0';
$gis_initial_altitude = (isset($gis_data['initial_altitude']) === true) ? $gis_data['initial_altitude'] : '0';
$gis_default_latitude = (isset($gis_data['default_latitude']) === true) ? $gis_data['default_latitude'] : '0';
$gis_default_longitude = (isset($gis_data['default_longitude']) === true) ? $gis_data['default_longitude'] : '0';
$gis_default_altitude = (isset($gis_data['default_altitude']) === true) ? $gis_data['default_altitude'] : '0';
$gis_id_group = get_group_or_create_demo_group($gis_group);
if ($gis_id_group === false) {
// Group could not be created. Skip GIS map creation.
register_error(
DEMO_GIS_MAP,
__('Error in %s: the specified group does not exist in the system and could not be created. Skipping GIS map creation', $filename)
);
continue;
}
$values = [];
$values['map_name'] = io_safe_input($gis_name);
$values['group_id'] = $gis_id_group;
$values['zoom_level'] = $gis_zoom_level;
$values['initial_latitude'] = $gis_initial_latitude;
$values['initial_longitude'] = $gis_initial_longitude;
$values['initial_altitude'] = $gis_initial_altitude;
$values['default_latitude'] = $gis_default_latitude;
$values['default_longitude'] = $gis_default_longitude;
$values['default_altitude'] = $gis_default_altitude;
$id_map = db_process_sql_insert('tgis_map', $values);
if ($id_map > 0) {
// Register created map in tdemo_data.
$values = [
'item_id' => $id_map,
'table_name' => 'tgis_map',
];
$result = (bool) db_process_sql_insert('tdemo_data', $values);
if ($result === false) {
// Rollback demo item creation if could not be registered in tdemo_data.
db_process_sql_delete('tgis_map', ['id_tgis_map' => $id_map]);
register_error(
DEMO_GIS_MAP,
__('Uncaught error (source %s): could not create GIS map %s', $filename, $gis_name)
);
continue;
}
} else {
// Network map group could not be created. Skip creation of map.
register_error(
DEMO_GIS_MAP,
__('Uncaught error (source %s): could not create GIS map %s', $filename, $gis_name)
);
continue;
}
$values = [];
$values['tgis_map_id_tgis_map'] = $id_map;
$values['tgis_map_con_id_tmap_con'] = 1;
db_process_sql_insert('tgis_map_has_tgis_map_con', $values);
if (count($gis_layers) > 0) {
$item_access_idx = 1;
while (1) {
$items_array = [];
foreach ($gis_layers as $key => $value) {
$items_array[$key] = ($value[$item_access_idx] ?? null);
}
$item_access_idx++;
$test_empty_array = array_filter($items_array);
if (empty($test_empty_array) === true) {
break;
}
$item_values = [];
$layer_order = $item_access_idx - 2;
$item_values['tgis_map_id_tgis_map'] = $id_map;
$item_values['layer_stack_order'] = $layer_order;
$item_values['tgrupo_id_grupo'] = -1;
$item_values['view_layer'] = 1;
$item_values['layer_name'] = io_safe_input((isset($items_array['name']) === true) ? $items_array['name'] : 'layer-'-$layer_order);
if (isset($items_array['group']) === true) {
$layer_id_group = get_group_or_create_demo_group($items_array['group']);
if ($layer_id_group !== false) {
$item_values['tgrupo_id_grupo'] = $layer_id_group;
}
}
$created_gis_layer_id = db_process_sql_insert('tgis_map_layer', $item_values);
if ($created_gis_layer_id > 0) {
// Register created demo item in tdemo_data.
$values = [
'item_id' => $created_gis_layer_id,
'table_name' => 'tgis_map_layer',
];
$result = (bool) db_process_sql_insert('tdemo_data', $values);
if ($result === false) {
// Rollback demo item if could not be registered in tdemo_data.
db_process_sql_delete('tgis_map_layer', ['id_tmap_layer' => $created_gis_layer_id]);
register_error(
DEMO_GIS_MAP,
__('Uncaught error (source %s): could not create GIS map item with index %d', $filename, ($item_access_idx - 1))
);
continue;
}
} else {
register_error(
DEMO_GIS_MAP,
__('Uncaught error (source %s): could not create GIS map item with index %d', $filename, ($item_access_idx - 1))
);
}
}
}
}
update_progress($total_items_count, $gis_count, $gis_count);
update_item_checked(DEMO_GIS_MAP);
} else {
register_error(DEMO_GIS_MAP, __('No configuration files found or failed to parse files'));
}
$cg_count = count($parsed_ini['graphs'] ?? []);
if ($cg_count > 0) {
// Create graphs.
@ -2073,12 +2248,27 @@ if ($action === 'create_demo_data') {
// Map used types.
$types = [
'static_image' => 0,
'module_graph' => 1,
'custom_graph' => 1,
'value' => 2,
'label' => 4,
'icon' => 5,
'static_image' => 0,
'module_graph' => 1,
'custom_graph' => 1,
'value' => 2,
'percentile' => 3,
'label' => 4,
'icon' => 5,
'bubble' => 9,
'box' => 12,
'event_history' => 14,
'circular_progress_bar' => 15,
'circular_progress_bar_int' => 16,
'color_cloud' => 20,
'odometer' => 22,
'basic_chart' => 23,
];
$value_process_types = [
'max' => 6,
'min' => 7,
'avg' => 8,
];
// Get ID of item type. Skip if it does not exist.
@ -2093,6 +2283,16 @@ if ($action === 'create_demo_data') {
$element_values = [];
$element_values['type'] = $types[$items_array['type']];
if ($items_array['type'] == 'value') {
if (isset($items_array['process']) === true && isset($value_process_types[$items_array['process']])) {
$element_values['type'] = $value_process_types[$items_array['process']];
if (isset($items_array['interval']) === true) {
$element_values['period'] = $items_array['interval'];
}
}
}
$element_values['id_layout'] = $created_id;
if ($items_array['type'] === 'static_image') {
@ -2157,17 +2357,6 @@ if ($action === 'create_demo_data') {
}
if ($items_array['type'] === 'module_graph') {
if (isset($items_array['image']) === false
|| is_string($items_array['image']) === false
) {
// The above fields are required for this item.
register_error(
DEMO_VISUAL_CONSOLE,
__('Error in %s: image field must be specified for module_graph item type. Skipping creation of item with index %d', $filename, ($item_access_idx - 1))
);
continue;
}
if (isset($items_array['agent_name']) === true) {
$matched_agents = agents_get_agents(
['nombre' => $items_array['agent_name']],
@ -2240,6 +2429,176 @@ if ($action === 'create_demo_data') {
}
}
if ($items_array['type'] === 'basic_chart') {
if (isset($items_array['agent_name']) === true) {
$matched_agents = agents_get_agents(
['nombre' => $items_array['agent_name']],
['id_agente'],
'AR',
[
'field' => 'nombre',
'order' => 'ASC',
],
false,
0,
false,
false,
false
);
$agent_id = $matched_agents[0]['id_agente'];
if (!($agent_id > 0)) {
continue;
}
$element_values['id_agent'] = $agent_id;
if (isset($items_array['module']) === true) {
$module_row = modules_get_agentmodule_id(io_safe_input($items_array['module']), $agent_id);
$module_id = $module_row['id_agente_modulo'];
if (!($module_id > 0)) {
continue;
}
$element_values['id_agente_modulo'] = $module_id;
}
}
if (isset($items_array['interval']) === true) {
$element_values['period'] = $items_array['interval'];
}
}
if ($items_array['type'] === 'event_history') {
if (isset($items_array['agent_name']) === true) {
$matched_agents = agents_get_agents(
['nombre' => $items_array['agent_name']],
['id_agente'],
'AR',
[
'field' => 'nombre',
'order' => 'ASC',
],
false,
0,
false,
false,
false
);
$agent_id = $matched_agents[0]['id_agente'];
if (!($agent_id > 0)) {
continue;
}
$element_values['id_agent'] = $agent_id;
if (isset($items_array['module']) === true) {
$module_row = modules_get_agentmodule_id(io_safe_input($items_array['module']), $agent_id);
$module_id = $module_row['id_agente_modulo'];
if (!($module_id > 0)) {
continue;
}
$element_values['id_agente_modulo'] = $module_id;
}
}
if (isset($items_array['interval']) === true) {
$element_values['period'] = $items_array['interval'];
}
}
if ($items_array['type'] === 'odometer') {
if (isset($items_array['agent_name']) === true) {
$matched_agents = agents_get_agents(
['nombre' => $items_array['agent_name']],
['id_agente'],
'AR',
[
'field' => 'nombre',
'order' => 'ASC',
],
false,
0,
false,
false,
false
);
$agent_id = $matched_agents[0]['id_agente'];
if (!($agent_id > 0)) {
continue;
}
$element_values['id_agent'] = $agent_id;
if (isset($items_array['module']) === true) {
$module_row = modules_get_agentmodule_id(io_safe_input($items_array['module']), $agent_id);
$module_id = $module_row['id_agente_modulo'];
if (!($module_id > 0)) {
continue;
}
$element_values['id_agente_modulo'] = $module_id;
}
}
}
if ($items_array['type'] === 'color_cloud') {
if (isset($items_array['agent_name']) === true) {
$matched_agents = agents_get_agents(
['nombre' => $items_array['agent_name']],
['id_agente'],
'AR',
[
'field' => 'nombre',
'order' => 'ASC',
],
false,
0,
false,
false,
false
);
$agent_id = $matched_agents[0]['id_agente'];
if (!($agent_id > 0)) {
continue;
}
$element_values['id_agent'] = $agent_id;
if (isset($items_array['module']) === true) {
$module_row = modules_get_agentmodule_id(io_safe_input($items_array['module']), $agent_id);
$module_id = $module_row['id_agente_modulo'];
if (!($module_id > 0)) {
continue;
}
$element_values['id_agente_modulo'] = $module_id;
}
}
}
if ($items_array['type'] === 'box') {
if (isset($items_array['border_color']) === true) {
$element_values['border_color'] = $items_array['border_color'];
}
if (isset($items_array['fill_color']) === true) {
$element_values['fill_color'] = $items_array['fill_color'];
}
}
if ($items_array['type'] === 'icon') {
if (isset($items_array['image']) === false
|| is_string($items_array['image']) === false
@ -2327,6 +2686,59 @@ if ($action === 'create_demo_data') {
$element_values['height'] = $items_array['height'];
}
$element_values['show_on_top'] = (isset($items_array['show_on_top']) === true && $items_array['show_on_top'] === true) ? 1 : 0;
// Check here percentile items as height is used for max value
if ($items_array['type'] === 'percentile' || $items_array['type'] === 'bubble' || $items_array['type'] === 'circular_progress_bar' || $items_array['type'] === 'circular_progress_bar_int') {
if (isset($items_array['agent_name']) === true) {
$matched_agents = agents_get_agents(
['nombre' => $items_array['agent_name']],
['id_agente'],
'AR',
[
'field' => 'nombre',
'order' => 'ASC',
],
false,
0,
false,
false,
false
);
$agent_id = $matched_agents[0]['id_agente'];
if (!($agent_id > 0)) {
continue;
}
$element_values['id_agent'] = $agent_id;
if (isset($items_array['module']) === true) {
$module_row = modules_get_agentmodule_id(io_safe_input($items_array['module']), $agent_id);
$module_id = $module_row['id_agente_modulo'];
if (!($module_id > 0)) {
continue;
}
$element_values['id_agente_modulo'] = $module_id;
}
}
$element_values['border_width'] = 0;
if (isset($items_array['min']) === true) {
$element_values['border_width'] = $items_array['min'];
}
$element_values['height'] = 100;
if (isset($items_array['max']) === true) {
$element_values['height'] = $items_array['max'];
}
$element_values['image'] = 'percent';
}
$id = db_process_sql_insert('tlayout_data', $element_values);
if ($id > 0) {
@ -2834,6 +3246,9 @@ if ($action === 'cleanup_demo_data') {
'tagente_estado' => 'id_agente_estado',
'trel_item' => 'id',
'tplugin' => 'id',
'tgis_data_status' => 'tagente_id_agente',
'tgis_map' => 'id_tgis_map',
'tgis_map_layer' => 'id_tmap_layer',
];
$table_id_field = $table_id_field_dict[$item['table_name']];

View File

@ -897,9 +897,10 @@ define('LOG_ALERTS', 2);
// Demo items IDs.
define('DEMO_AGENT', 1);
define('DEMO_NETWORK_MAP', 2);
define('DEMO_CUSTOM_GRAPH', 3);
define('DEMO_REPORT', 4);
define('DEMO_SERVICE', 5);
define('DEMO_DASHBOARD', 6);
define('DEMO_VISUAL_CONSOLE', 7);
define('DEMO_PLUGIN', 8);
define('DEMO_GIS_MAP', 3);
define('DEMO_CUSTOM_GRAPH', 4);
define('DEMO_REPORT', 5);
define('DEMO_SERVICE', 6);
define('DEMO_DASHBOARD', 7);
define('DEMO_VISUAL_CONSOLE', 8);
define('DEMO_PLUGIN', 9);

View File

@ -197,6 +197,19 @@ sub parse_ini_file {
$ini_data{'inventory_values'} = {};
}
# Initialize log modules keys
if(!defined($ini_data{'log_modules'})) {
$ini_data{'log_modules'} = {};
}
if(!defined($ini_data{'log_modules'}{'source'})) {
$ini_data{'log_modules'}{'source'} = {};
}
if(!defined($ini_data{'log_modules'}{'data'})) {
$ini_data{'log_modules'}{'data'} = {};
}
# Initialize traps keys
if(!defined($ini_data{'traps'})) {
$ini_data{'traps'} = {};
@ -518,6 +531,33 @@ sub generate_agent($) {
$xml .= "</agent_data>\n";
}
# Append log module data to XML (only once a day at 00:00)
if (!empty($sorted_ini[$current_ini]->{'log_modules'}->{'source'}) && !empty($sorted_ini[$current_ini]->{'log_modules'}->{'data'})) {
# Remove agent_data closing tag
$xml =~ s/<\/agent_data>//i;
# Add log modules for each source
foreach my $log_key (sort keys %{$sorted_ini[$current_ini]->{'log_modules'}->{'source'}}) {
# Only if data is defined
if(defined($sorted_ini[$current_ini]->{'log_modules'}->{'data'}->{$log_key})) {
# Add log module 50% of times
if(get_bool(50)) {
my $log_source = $sorted_ini[$current_ini]->{'log_modules'}->{'source'}->{$log_key};
my $log_data = $sorted_ini[$current_ini]->{'log_modules'}->{'data'}->{$log_key};
$xml .= "<log_module>\n";
$xml .= "\t<source><![CDATA[$log_source]]></source>\n";
$xml .= "\t<data><![CDATA[$log_data]]></data>\n";
$xml .= "</log_module>\n";
}
}
}
# Close agent_data tag again
$xml .= "</agent_data>\n";
}
# Get file name MD5
my $file_md5 = md5_hex($agent->{'agent_name'});