From 57eec94c42745492389490482520d0c093b725f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Su=C3=A1rez?= Date: Fri, 28 Jul 2023 09:32:30 -0600 Subject: [PATCH 001/264] Add OS, server and interval. --- pandora_server/util/pandora_manage.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 71fd0db43e..2b0f20f244 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -4508,7 +4508,9 @@ sub cli_create_event() { # exist_check($id_agent,'agent',$agent_name); if($id_agent == -1){ if($force_create_agent == 1){ - pandora_create_agent ($conf, '', $agent_name, '', $id_group, '', '', 'Created by cli_create_event', '', $dbh); + my $target_os = pandora_get_os($dbh, 'other'); + my $target_server = $conf{'servername'}; + pandora_create_agent ($conf, $target_server, $agent_name, '', $id_group, '', $target_os, 'Created by cli_create_event', '300', $dbh); print_log "[INFO] Adding agent '$agent_name' \n\n"; $id_agent = get_agent_id($dbh,$agent_name); } From a0b02670fb4028a5a6752463a5aceb4fa37b23ee Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 31 Aug 2023 10:45:27 +0200 Subject: [PATCH 002/264] #11954 Fix pagination --- pandora_console/godmode/agentes/fields_manager.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/fields_manager.php b/pandora_console/godmode/agentes/fields_manager.php index 25b06e2f5a..53b4995d20 100644 --- a/pandora_console/godmode/agentes/fields_manager.php +++ b/pandora_console/godmode/agentes/fields_manager.php @@ -217,6 +217,7 @@ foreach ($fields as $field) { array_push($table->data, $data); } +$tablePagination = ''; if ($fields) { html_print_table($table); $tablePagination = ui_pagination($count_fields, false, $offset, 0, true, 'offset', false); @@ -231,6 +232,9 @@ html_print_action_buttons( [ 'icon' => 'next' ], true ), - ['type' => 'form_action'] + [ + 'type' => 'form_action', + 'right_content' => $tablePagination, + ], ); echo ''; From eab6a00300d97a1ef5ab8da2097f14af712c90c4 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 31 Aug 2023 10:49:59 +0200 Subject: [PATCH 003/264] #11945 Amend changes --- pandora_console/godmode/agentes/fields_manager.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pandora_console/godmode/agentes/fields_manager.php b/pandora_console/godmode/agentes/fields_manager.php index 53b4995d20..25b06e2f5a 100644 --- a/pandora_console/godmode/agentes/fields_manager.php +++ b/pandora_console/godmode/agentes/fields_manager.php @@ -217,7 +217,6 @@ foreach ($fields as $field) { array_push($table->data, $data); } -$tablePagination = ''; if ($fields) { html_print_table($table); $tablePagination = ui_pagination($count_fields, false, $offset, 0, true, 'offset', false); @@ -232,9 +231,6 @@ html_print_action_buttons( [ 'icon' => 'next' ], true ), - [ - 'type' => 'form_action', - 'right_content' => $tablePagination, - ], + ['type' => 'form_action'] ); echo ''; From 9ae34fae404fa1bc7c324448cd67fc275cd92020 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 31 Aug 2023 12:35:32 +0200 Subject: [PATCH 004/264] #11954 Fix delete alerts action in bulk --- .../godmode/massive/massive_delete_action_alerts.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/massive/massive_delete_action_alerts.php b/pandora_console/godmode/massive/massive_delete_action_alerts.php index cad37a3a29..0cd712e124 100644 --- a/pandora_console/godmode/massive/massive_delete_action_alerts.php +++ b/pandora_console/godmode/massive/massive_delete_action_alerts.php @@ -111,7 +111,8 @@ if ($delete) { $alerts_agent_modules = []; foreach ($agent_alerts['simple'] as $agent_alert) { if ((in_array($agent_alert['id_alert_template'], $id_alert_templates)) && (in_array($agent_alert['id_agent_module'], $modules_id))) { - $alerts_agent_modules = array_merge($alerts_agent_modules, alerts_get_alerts_agent_module($agent_alert['id_agent_module'], true, false, 'id')); + // $alerts_agent_modules = array_merge($alerts_agent_modules, alerts_get_alerts_agent_module($agent_alert['id_agent_module'], true, false, 'id')); + $alerts_agent_modules[] = $agent_alert['id']; } } @@ -126,7 +127,7 @@ if ($delete) { $agent_module_actions = []; foreach ($alerts_agent_modules as $alert_agent_module) { - $agent_module_actions = alerts_get_alert_agent_module_actions($alert_agent_module['id'], ['id', 'id_alert_action']); + $agent_module_actions = alerts_get_alert_agent_module_actions($alert_agent_module, ['id', 'id_alert_action']); foreach ($agent_module_actions as $agent_module_action) { foreach ($actions as $action) { From dac99b7a30be4960df2832e3cb420792a886fd62 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 1 Sep 2023 08:55:18 +0200 Subject: [PATCH 005/264] #11886 Fix minimun misprint --- pandora_console/include/functions_reporting_html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index eb7c555fb9..60e6e41a0c 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -4091,7 +4091,7 @@ function reporting_html_value( $table2->head = [ __('Agent'), __('Module'), - __('Minimun'), + __('Minimum'), ]; break; @@ -4162,7 +4162,7 @@ function reporting_html_value( case 'min_value': $table1->head = [ __('Lapse'), - __('Minimun'), + __('Minimum'), ]; break; From 94315147cfeb8d88daeeb53c1c062f9babd7b052 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 1 Sep 2023 10:12:03 +0200 Subject: [PATCH 006/264] #11750 module_data name file add module id --- pandora_console/include/functions_api.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 7e22befbee..95e3e47919 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -10299,8 +10299,7 @@ function api_set_module_data($id, $thrash2, $other, $trash1) modules_get_type_name($agentModule['id_tipo_modulo']), $data ); - - if (false === @file_put_contents($config['remote_config'].'/'.io_safe_output($agent['nombre']).'.'.$time.'.data', $xml)) { + if (false === @file_put_contents($config['remote_config'].'/'.io_safe_output($agent['nombre']).'.'.$idAgentModule.'.'.$time.'.data', $xml)) { returnError(sprintf('XML file could not be generated in path: %s', $config['remote_config'])); } else { echo __('XML file was generated successfully in path: ').$config['remote_config']; From 5a31621abfc33c93ee1c772f5b7e20d6c734c163 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 1 Sep 2023 13:15:42 +0200 Subject: [PATCH 007/264] #11903 Fix gis maps --- .../godmode/gis_maps/configure_gis_map.php | 14 +++++++++----- pandora_console/include/functions_gis.php | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/gis_maps/configure_gis_map.php b/pandora_console/godmode/gis_maps/configure_gis_map.php index a6f282d2cf..fee2b9d723 100644 --- a/pandora_console/godmode/gis_maps/configure_gis_map.php +++ b/pandora_console/godmode/gis_maps/configure_gis_map.php @@ -243,10 +243,15 @@ switch ($action) { $map_default_altitude = get_parameter('map_default_altitude'); $map_group_id = get_parameter('map_group_id'); $map_levels_zoom = get_parameter('map_levels_zoom', 16); - $map_connection_list_temp = explode(',', get_parameter('map_connection_list')); + $map_connection_list_temp_string = implode(',', $map_connection_list_temp); + if (strlen($map_connection_list_temp_string) > 0) { + $where_map_connection = ' WHERE id_tmap_connection IN('.$map_connection_list_temp_string.')'; + } else { + $where_map_connection = ''; + } - $listConnectionTemp = db_get_all_rows_sql('SELECT id_tmap_connection, conection_name, group_id FROM tgis_map_connection'); + $listConnectionTemp = db_get_all_rows_sql('SELECT id_tmap_connection, conection_name, group_id FROM tgis_map_connection'.$where_map_connection); foreach ($map_connection_list_temp as $index => $value) { $cleanValue = trim($value); @@ -256,7 +261,6 @@ switch ($action) { } $map_connection_default = get_parameter('map_connection_default'); - $map_connection_list = []; foreach ($listConnectionTemp as $idMapConnection) { $default = 0; @@ -345,7 +349,7 @@ function deleteConnectionMap(idConnectionMap) { checked = $("#radiobtn0001", $("#map_connection_" + idConnectionMap)).attr('checked'); $("#map_connection_" + idConnectionMap).remove(); - + if (checked) { //Checked first, but not is index = 0 maybe. @@ -485,7 +489,7 @@ foreach ($listConnectionTemp as $connectionTemp) { $table->data[1][0] = __('Add Map connection').$iconError; $table->data[1][1] = " - - + diff --git a/pandora_console/godmode/reporting/visual_console_builder.php b/pandora_console/godmode/reporting/visual_console_builder.php index 986dcb423b..fc043228ed 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.php +++ b/pandora_console/godmode/reporting/visual_console_builder.php @@ -78,6 +78,7 @@ $action = get_parameterBetweenListValues( 'update', 'delete', 'multiple_delete', + 'update_json', ], 'new' ); @@ -523,6 +524,110 @@ switch ($activeTab) { } break; + case 'update_json': + // Update background. + $background = get_parameter('background'); + $width = get_parameter('background_width'); + $height = get_parameter('background_height'); + + if ($width == 0 && $height == 0) { + $sizeBackground = getimagesize( + $config['homedir'].'/images/console/background/'.$background + ); + $width = $sizeBackground[0]; + $height = $sizeBackground[1]; + } + + db_process_sql_update( + 'tlayout', + [ + 'background' => $background, + 'width' => $width, + 'height' => $height, + ], + ['id' => $idVisualConsole] + ); + + // Return the updated visual console. + $visualConsole = db_get_row_filter( + 'tlayout', + ['id' => $idVisualConsole] + ); + + // Update elements in visual map. + $idsElements = db_get_all_rows_filter( + 'tlayout_data', + ['id_layout' => $idVisualConsole], + [ + 'id', + 'type', + ] + ); + + $array_update = json_decode(io_safe_output(get_parameter('array_update')), true); + + if (count($array_update)) { + foreach ($array_update as $row) { + $id = $row['id']; + $values = []; + $values['label'] = $row['label']; + $values['image'] = $row['image']; + $values['width'] = $row['width']; + $values['height'] = $row['height']; + $values['pos_x'] = $row['pos_x']; + $values['pos_y'] = $row['pos_y']; + + switch ($row['rowtype']) { + case NETWORK_LINK: + case LINE_ITEM: + continue 2; + + break; + + case SIMPLE_VALUE_MAX: + case SIMPLE_VALUE_MIN: + case SIMPLE_VALUE_AVG: + $values['period'] = $row['period']; + break; + + case MODULE_GRAPH: + $values['period'] = $row['period']; + unset($values['image']); + break; + + case GROUP_ITEM: + $values['id_group'] = $row['group']; + break; + + case CIRCULAR_PROGRESS_BAR: + case CIRCULAR_INTERIOR_PROGRESS_BAR: + case PERCENTILE_BUBBLE: + case PERCENTILE_BAR: + unset($values['height']); + break; + } + + if (defined('METACONSOLE')) { + $values['id_metaconsole'] = $row['id_server']; + } + + $values['id_agent'] = $row['agent']; + $values['id_agente_modulo'] = $row['module']; + $values['id_custom_graph'] = $row['custom_graph']; + $values['parent_item'] = $row['parent']; + $values['id_layout_linked'] = $row['map_linked']; + + if (enterprise_installed()) { + enterprise_visual_map_update_action_from_list_elements($row['rowtype'], $values, $id); + } + + db_process_sql_update('tlayout_data', $values, ['id' => $id]); + } + + return true; + } + break; + case 'delete': $id_element = get_parameter('id_element'); $result = db_process_sql_delete('tlayout_data', ['id' => $id_element]); From 08bccce67367b92acc1250d72d7d28e9279da755 Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Tue, 17 Oct 2023 08:28:38 -0600 Subject: [PATCH 040/264] Remove root validation --- pandora_agents/pc/pandora_agent | 11 +---------- pandora_agents/unix/pandora_agent | 9 +-------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/pandora_agents/pc/pandora_agent b/pandora_agents/pc/pandora_agent index aa8208f5d0..04b7de51a5 100644 --- a/pandora_agents/pc/pandora_agent +++ b/pandora_agents/pc/pandora_agent @@ -2185,16 +2185,7 @@ sub configure ($) { #Launch tentacle server in proxy mode if configured if ($Conf{'proxy_mode'}) { - - #Check if user is root - if ($> != 0) { - if (launch_tentacle_proxy() != 0) { - return 1; - } - } else { - error ('Proxy mode can not be launched as root'); - return 1; - } + return 1 if (launch_tentacle_proxy() != 0); } # Add the plugins directory to the PATH diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index de7a2e6946..d0b7c22ede 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -4183,14 +4183,7 @@ my $PID = $$; #Launch tentacle server in proxy mode if configured if ($Conf{'proxy_mode'}) { - - #Check if user is root - if ($> != 0) { - launch_tentacle_proxy(); - } else { - log_message ('error', 'Proxy mode can not be launched as root'); - exit 1; - } + launch_tentacle_proxy(); } # Advice if YAML::Tiny is allowed in this system From 4fb7e1719b1d8cc53d5c8e61c90bd76a37eb747f Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 18 Oct 2023 12:49:47 +0200 Subject: [PATCH 041/264] add periodicity graph pandora_enterprise#9640 --- pandora_console/extensions/agents_modules.php | 2 +- pandora_console/include/ajax/module.php | 17 +- pandora_console/include/functions_graph.php | 537 ++++++++++++++++ pandora_console/include/graphs/fgraph.php | 67 +- pandora_console/include/styles/pandora.css | 33 +- .../operation/agentes/stat_win.php | 572 +++++++----------- pandora_console/operation/search_modules.php | 2 +- 7 files changed, 845 insertions(+), 385 deletions(-) diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index d6c4f3bb32..f372f45812 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -1007,7 +1007,7 @@ function mainAgentsModules() echo " + + + + + + + +
".html_print_select($listConnection, 'map_connection_list', '', '', '', '0', true)." + ".html_print_select($listConnection, 'select-map_connection_list', '', '', '', '0', true)." ".html_print_image( diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index ba9116759b..b57ec9e9ff 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -1585,7 +1585,7 @@ function gis_add_conection_maps_in_form($map_connection_list)
'.html_print_input_text('map_connection_name_'.$mapConnection['id_conection'], $mapConnectionRowDB['conection_name'], '', 20, 40, true, true).' '.$radioButton.''.html_print_image('images/delete.svg', true, ['alt' => '', 'class' => 'invert_filter']).''.html_print_image('images/delete.svg', true, ['alt' => '', 'class' => 'invert_filter main_menu_icon']).'
"; $win_handle = dechex(crc32($module_id.$module['name'])); $graph_type = return_graphtype(modules_get_agentmodule_type($module_id)); - $link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&".'period='.SECONDS_1DAY.'&'.'id='.$module_id.'&'.'refresh='.SECONDS_10MINUTES."', 'day_".$win_handle."', 800, 480)"; + $link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&".'period='.SECONDS_1DAY.'&id='.$module_id.'&period_graph=0&refresh='.SECONDS_10MINUTES."', 'day_".$win_handle."', 800, 480)"; echo ''; diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 78daacb0a0..2951ad495a 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -1283,7 +1283,7 @@ if (check_login()) { } if (is_snapshot_data($module['datos']) === false) { - $link = 'winopeng_var(\'operation/agentes/stat_win.php?type='.$graph_type.'&period='.SECONDS_1DAY.'&id='.$module['id_agente_modulo'].'&refresh='.SECONDS_10MINUTES.'&draw_events='.$draw_events.'\', \'day_'.$win_handle.'\', 800, 480)'; + $link = 'winopeng_var(\'operation/agentes/stat_win.php?type='.$graph_type.'&period='.SECONDS_1DAY.'&id='.$module['id_agente_modulo'].'&refresh='.SECONDS_10MINUTES.'&period_graph=0&draw_events='.$draw_events.'\', \'day_'.$win_handle.'\', 800, 480)'; $graphButtons[] = html_print_anchor( [ 'href' => 'javascript:'.$link, @@ -1499,9 +1499,14 @@ if (check_login()) { $output = ''; $graph_data = get_parameter('graph_data', ''); $params = json_decode(base64_decode($graph_data), true); + $form_data = json_decode(base64_decode(get_parameter('form_data', [])), true); $server_id = (int) get_parameter('server_id', 0); include_once $config['homedir'].'/include/functions_graph.php'; + $tab_active = get_parameter('active', 'tabs-chart-module-graph'); + + $output .= draw_form_stat_win($form_data, $tab_active); + // Metaconsole connection to the node. if (is_metaconsole() === true && empty($server_id) === false) { $server = metaconsole_get_connection_by_id($server_id); @@ -1553,7 +1558,15 @@ if (check_login()) { $output .= $graph['chart']; $output .= ''; } else { - $output .= grafico_modulo_sparse($params); + if ($tab_active === 'tabs-chart-module-graph') { + $output .= grafico_modulo_sparse($params); + } else { + $output .= graphic_periodicity_module($params); + if ($params['compare'] === 'separated') { + $params['date'] = ($params['date'] - $params['period']); + $output .= graphic_periodicity_module($params); + } + } } } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index e6605a488b..006870757e 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2422,6 +2422,147 @@ function graphic_combined_module( } +/** + * Draw periodicity graph + * + * @param array $params Params for draw chart. + * + * @return string Html output. + */ +function graphic_periodicity_module(array $params): string +{ + $date_array = []; + $date_array['period'] = $params['period']; + $date_array['final_date'] = $params['date']; + $date_array['start_date'] = ($params['date'] - $params['period']); + + $array_data = fullscale_data( + $params['agent_module_id'], + $date_array, + false, + false, + 1, + false, + $params['period_slice_chart'], + 0 + ); + + if (empty($array_data) === false) { + $graph_labels = []; + $multiple_labels = []; + foreach ($array_data['sum1']['slice_data'] as $time => $array_data) { + $graph_labels[] = date('H:i', ($time / 1000)); + + $avg = [ + 'y' => $array_data['avg'], + 'x' => $time, + ]; + + $max = [ + 'y' => $array_data['max'], + 'x' => $time, + ]; + + $min = [ + 'y' => $array_data['min'], + 'x' => $time, + ]; + + $sum = [ + 'y' => $array_data['sum'], + 'x' => $time, + ]; + if ((int) $params['period_mode'] === CUSTOM_GRAPH_HBARS) { + $avg = [ + 'x' => $array_data['avg'], + 'y' => $time, + ]; + + $max = [ + 'x' => $array_data['max'], + 'y' => $time, + ]; + + $min = [ + 'x' => $array_data['min'], + 'y' => $time, + ]; + + $sum = [ + 'x' => $array_data['sum'], + 'y' => $time, + ]; + } + + $graph_values_avg[] = $avg; + $graph_values_max[] = $max; + $graph_values_min[] = $min; + $graph_values_sum[] = $sum; + } + + if ((bool) $params['period_average'] === true) { + $graph_values['avg'] = $graph_values_avg; + $multiple_labels['avg'] = [ + 'label' => __('Average'), + 'fill' => ((int) $params['period_mode'] === CUSTOM_GRAPH_AREA) ? true : false, + ]; + } + + if ((bool) $params['period_maximum'] === true) { + $graph_values['max'] = $graph_values_max; + $multiple_labels['max'] = [ + 'label' => __('Maximun'), + 'fill' => ((int) $params['period_mode'] === CUSTOM_GRAPH_AREA) ? true : false, + ]; + } + + if ((bool) $params['period_minimum'] === true) { + $graph_values['min'] = $graph_values_min; + $multiple_labels['min'] = [ + 'label' => __('Minimum'), + 'fill' => ((int) $params['period_mode'] === CUSTOM_GRAPH_AREA) ? true : false, + ]; + } + + if ((bool) $params['period_summatory'] === true) { + $graph_values['sum'] = $graph_values_sum; + $multiple_labels['sum'] = [ + 'label' => __('Summatory'), + 'fill' => ((int) $params['period_mode'] === CUSTOM_GRAPH_AREA) ? true : false, + ]; + } + } + + $options = [ + 'height' => 200, + 'waterMark' => true, + 'legend' => ['display' => true], + 'labels' => $graph_labels, + 'multiple' => $multiple_labels, + ]; + + $output = '
'; + $output .= '
'; + if ((int) $params['period_mode'] === CUSTOM_GRAPH_HBARS + || (int) $params['period_mode'] === CUSTOM_GRAPH_VBARS + ) { + if ((int) $params['period_mode'] === CUSTOM_GRAPH_HBARS) { + $options['axis'] = 'y'; + } + + $output .= vbar_graph($graph_values, $options); + } else { + $output .= line_graph($graph_values, $options); + } + + $output .= '
'; + $output .= '
'; + + return $output; + +} + + /** * Function for convert data summatory. * @@ -3909,6 +4050,7 @@ function fullscale_data( } $data['sum'.$series_suffix]['slice_data'][$real_date]['avg'] = ($sum_data / $count_data); + $data['sum'.$series_suffix]['slice_data'][$real_date]['sum'] = $sum_data; if ($max_value != (-PHP_INT_MAX)) { $data['sum'.$series_suffix]['slice_data'][$real_date]['max'] = $max_value; @@ -4174,6 +4316,7 @@ function fullscale_data( $data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['avg'] = 0; if (isset($count_data) === true) { $data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['avg'] = ($sum_data / $count_data); + $data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['sum'] = $sum_data; } $data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['max'] = $max_value; @@ -5351,3 +5494,397 @@ function graph_analytics_filter_select() return $result; } + + +function draw_form_stat_win(array $form_data, string $tab_active) +{ + $table = html_get_predefined_table('transparent', 2); + $table->width = '100%'; + $table->id = 'stat_win_form_div'; + $table->style[0] = 'text-align:left;font-weight: bold;font-size:8.5pt;line-height:30pt;'; + $table->style[1] = 'text-align:left;font-weight: bold;line-height:30pt;'; + $table->style[2] = 'text-align:left;font-weight: bold;line-height:30pt;'; + $table->style[3] = 'text-align:left;font-weight: bold;line-height:30pt;'; + $table->class = 'table_modal_alternate'; + $table->data = []; + + if ((bool) $form_data['histogram'] === true || $tab_active === 'tabs-chart-period-graph') { + $table->data[0][0] = __('Refresh time'); + $table->data[0][1] = '
'.html_print_extended_select_for_time( + 'refresh', + $form_data['refresh'], + '', + '', + 0, + 7, + true + ).'
'; + + $table->data[0][2] = ''; + $table->data[0][3] = ''; + + $table->data[1][0] = __('Begin date'); + $table->data[1][1] = html_print_input_text( + 'start_date', + $form_data['start_date'], + '', + 10, + 20, + true, + false, + false, + '', + 'small-input' + ); + + $table->data[1][2] = __('Begin time'); + $table->data[1][3] = html_print_input_text( + 'start_time', + $form_data['start_time'], + '', + 10, + 10, + true, + false, + false, + '', + 'small-input' + ); + + $table->data[2][0] = __('Time range'); + $table->data[2][1] = '
'.html_print_extended_select_for_time( + 'period', + $form_data['period'], + '', + '', + 0, + 7, + true + ).'
'; + + $table->data[3][0] = __('Time compare (Separated)'); + $table->data[3][1] = html_print_checkbox_switch( + 'time_compare_separated', + 1, + (bool) $form_data['time_compare_separated'], + true + ); + + $table->data[3][2] = ''; + $table->data[3][3] = ''; + + if ($tab_active === 'tabs-chart-period-graph') { + $table->data[4][0] = __('Maximum'); + $table->data[4][1] = html_print_checkbox_switch( + 'period_maximum', + 1, + (bool) $form_data['period_maximum'], + true + ); + + $table->data[4][2] = __('Minimum'); + $table->data[4][3] = html_print_checkbox_switch( + 'period_minimum', + 1, + (bool) $form_data['period_minimum'], + true + ); + + $table->data[5][0] = __('Average'); + $table->data[5][1] = html_print_checkbox_switch( + 'period_average', + 1, + (bool) $form_data['period_average'], + true + ); + + $table->data[5][2] = __('Summatory'); + $table->data[5][3] = html_print_checkbox_switch( + 'period_summatory', + 1, + (bool) $form_data['period_summatory'], + true + ); + + $table->data[6][0] = __('Slice'); + $table->data[6][1] = '
'.html_print_extended_select_for_time( + 'period_slice_chart', + (string) $form_data['period_slice_chart'], + '', + '', + 0, + 7, + true, + false, + true, + '', + false, + [ + SECONDS_1HOUR => __('1 hour'), + SECONDS_1DAY => __('1 day'), + SECONDS_1WEEK => __('1 week'), + SECONDS_1MONTH => __('1 month'), + ] + ).'
'; + + $table->data[6][2] = __('Mode'); + $options_period_mode = [ + CUSTOM_GRAPH_AREA => __('Area'), + CUSTOM_GRAPH_LINE => __('Line'), + // CUSTOM_GRAPH_HBARS => __('Horizontal bars'), + CUSTOM_GRAPH_VBARS => __('Vertical bars'), + ]; + + $table->data[6][3] = '
'.html_print_select( + $options_period_mode, + 'period_mode', + $form_data['period_mode'], + '', + '', + 0, + true, + false, + false + ).'
'; + } + } else { + $table->data[0][0] = __('Refresh time'); + $table->data[0][1] = '
'.html_print_extended_select_for_time( + 'refresh', + $form_data['refresh'], + '', + '', + 0, + 7, + true + ).'
'; + + $table->data[0][2] = __('Show events'); + $disabled = false; + + $table->data[0][3] = html_print_checkbox_switch( + 'draw_events', + 1, + (bool) $form_data['draw_events'], + true, + $disabled + ); + + $table->data[1][0] = __('Begin date'); + $table->data[1][1] = html_print_input_text( + 'start_date', + $form_data['start_date'], + '', + 10, + 20, + true, + false, + false, + '', + 'small-input' + ); + + $table->data[1][2] = __('Show alerts'); + $table->data[1][3] = html_print_checkbox_switch( + 'draw_alerts', + 1, + (bool) $form_data['draw_alerts'], + true + ); + + $table->data[2][0] = __('Begin time'); + $table->data[2][1] = html_print_input_text( + 'start_time', + $form_data['start_time'], + '', + 10, + 10, + true, + false, + false, + '', + 'small-input' + ); + + $table->data[2][2] = __('Show unknown graph'); + $table->data[2][3] = html_print_checkbox_switch( + 'unknown_graph', + 1, + (bool) $form_data['unknown_graph'], + true + ); + + $table->data[3][0] = __('Time range'); + $table->data[3][1] = '
'.html_print_extended_select_for_time( + 'period', + $form_data['period'], + '', + '', + 0, + 7, + true + ).'
'; + + $table->data[3][2] = ''; + $table->data[3][3] = ''; + + if (!modules_is_boolean($form_data['id'])) { + $table->data[4][0] = __('Zoom'); + $options = []; + $options[$form_data['zoom']] = 'x'.$form_data['zoom']; + $options[1] = 'x1'; + $options[2] = 'x2'; + $options[3] = 'x3'; + $options[4] = 'x4'; + $options[5] = 'x5'; + $table->data[4][1] = '
'.html_print_select( + $options, + 'zoom', + $form_data['zoom'], + '', + '', + 0, + true, + false, + false + ).'
'; + + $table->data[4][2] = __('Show percentil'); + $table->data[4][3] = html_print_checkbox_switch( + 'show_percentil', + 1, + (bool) $form_data['show_percentil'], + true + ); + } + + $table->data[5][0] = __('Time compare (Overlapped)'); + $table->data[5][1] = html_print_checkbox_switch( + 'time_compare_overlapped', + 1, + (bool) $form_data['time_compare_overlapped'], + true + ); + + $table->data[5][2] = __('Time compare (Separated)'); + $table->data[5][3] = html_print_checkbox_switch( + 'time_compare_separated', + 1, + (bool) $form_data['time_compare_separated'], + true + ); + + $table->data[6][0] = __('Show AVG/MAX/MIN data series in graph'); + $table->data[6][1] = html_print_checkbox_switch( + 'type_mode_graph', + 1, + (bool) $form_data['type_mode_graph'], + true, + false + ); + + $table->data[6][2] = __('Show full scale graph (TIP)'); + $table->data[6][2] .= ui_print_help_tip( + __('TIP mode charts do not support average - maximum - minimum series, you can only enable TIP or average, maximum or minimum series'), + true + ); + $table->data[6][3] = html_print_checkbox_switch( + 'fullscale', + 1, + (bool) $form_data['fullscale'], + true, + false + ); + + $table->data[7][0] = __('Projection graph'); + $table->data[7][0] .= ui_print_help_tip( + __('Projection graph take as begin date the current time'), + true + ); + $table->data[7][1] = html_print_checkbox_switch( + 'enable_projected_period', + 1, + (bool) $form_data['enable_projected_period'], + true + ); + + $table->data[7][2] = __('Projection period'); + $table->data[7][3] = '
'.html_print_extended_select_for_time( + 'period_projected', + $form_data['period_projected'], + '', + '', + 0, + 7, + true + ).'
'; + } + + $form_table = html_print_table($table, true); + $form_table .= html_print_div( + [ + 'class' => 'action-buttons-right-forced margin-top-10', + 'content' => html_print_submit_button( + __('Reload'), + 'submit', + false, + [ + 'icon' => 'search', + 'mode' => 'secondary mini', + 'class' => 'float-right', + ], + true + ), + ], + true + ); + + $output = '
'; + $output .= html_print_input_hidden('id', $form_data['id'], true); + $output .= html_print_input_hidden('label', $form_data['label'], true); + + if (empty($server_id) === false) { + $output .= html_print_input_hidden('server', $form_data['server_id'], true); + } + + $output .= html_print_input_hidden('histogram', $form_data['histogram'], true); + $output .= html_print_input_hidden('period_graph', $form_data['period_graph'], true); + $output .= html_print_input_hidden('type', $form_data['type'], true); + + $output .= ui_toggle( + $form_table, + ''.__('Graph configuration menu').''.ui_print_help_tip( + __('In Pandora FMS, data is stored compressed. The data visualization in database, charts or CSV exported data won\'t match, because is interpreted at runtime. Please check \'Pandora FMS Engineering\' chapter from documentation.'), + true + ), + '', + '', + true, + true, + '', + 'white-box-content', + 'box-flat pdd_10px', + 'images/arrow@svg.svg', + 'images/arrow@svg.svg', + true + ); + $output .= '
'; + + return $output; +} + + +function draw_container_chart_stat_win(?string $name='stat-win-module-graph') +{ + $output = '
'; + $output .= '
'; + $output .= html_print_image('images/spinner_charts.gif', true); + $output .= '
'; + + $output .= '
'; + $output .= '
'; + + $output .= '
'; + + return $output; +} diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 494ec9c010..9cf7b5621d 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -1220,11 +1220,24 @@ function get_build_setup_charts($type, $options, $data) break; case 'BAR': - $setData->setLabel('data')->setBackgroundColor($colors); - $setData->setLabel('data')->setBorderColor($borders); - $setData->setLabel('data')->setBorderWidth(2); - - $setData->setLabel('data')->data()->exchangeArray(array_values($data)); + if (isset($options['multiple']) === true && empty($options['multiple']) === false) { + $i = 0; + foreach ($options['multiple'] as $key_label => $info) { + $dataSet = $chart->createDataSet(); + $dataSet->setLabel(($info['label'] ?? '--')); + $dataSet->setBackgroundColor(($info['backgroundColor'] ?? $colors[$i])); + $dataSet->setBorderColor(($info['borderColor'] ?? $borders[$i])); + $dataSet->setBorderWidth(($info['borderWidth'] ?? 2)); + $dataSet->data()->exchangeArray(array_values($data[$key_label])); + $chart->addDataSet($dataSet); + $i++; + } + } else { + $setData->setLabel('data')->setBackgroundColor($colors); + $setData->setLabel('data')->setBorderColor($borders); + $setData->setLabel('data')->setBorderWidth(2); + $setData->setLabel('data')->data()->exchangeArray(array_values($data)); + } // Para las horizontales. if (isset($options['axis']) === true @@ -1250,19 +1263,32 @@ function get_build_setup_charts($type, $options, $data) break; case 'LINE': - $chart->labels()->exchangeArray($options['labels']); - - foreach ($data as $key => $dataset) { - $dataSet1 = $chart->createDataSet(); - $dataSet1->setLabel($dataset['label']); - $dataSet1->setBackgroundColor($dataset['backgroundColor']); - $dataSet1->setBorderColor($dataset['borderColor']); - $dataSet1->setPointBackgroundColor($dataset['pointBackgroundColor']); - $dataSet1->setPointBorderColor($dataset['pointBorderColor']); - $dataSet1->setPointHoverBackgroundColor($dataset['pointHoverBackgroundColor']); - $dataSet1->setPointHoverBorderColor($dataset['pointHoverBorderColor']); - $dataSet1->data()->exchangeArray($dataset['data']); - $chart->addDataSet($dataSet1); + if (isset($options['multiple']) === true && empty($options['multiple']) === false) { + $i = 0; + foreach ($options['multiple'] as $key_label => $info) { + $dataSet = $chart->createDataSet(); + $dataSet->setLabel(($info['label'] ?? '--')); + $dataSet->setBackgroundColor(($info['backgroundColor'] ?? $colors[$i])); + $dataSet->setBorderColor(($info['borderColorColor'] ?? $borders[$i])); + $dataSet->setFill(($info['fill'] ?? false)); + $dataSet->data()->exchangeArray(array_values($data[$key_label])); + $chart->addDataSet($dataSet); + $i++; + } + } else { + $chart->labels()->exchangeArray($options['labels']); + foreach ($data as $key => $dataset) { + $dataSet = $chart->createDataSet(); + $dataSet->setLabel($dataset['label']); + $dataSet->setBackgroundColor($dataset['backgroundColor']); + $dataSet->setBorderColor($dataset['borderColor']); + $dataSet->setPointBackgroundColor($dataset['pointBackgroundColor']); + $dataSet->setPointBorderColor($dataset['pointBorderColor']); + $dataSet->setPointHoverBackgroundColor($dataset['pointHoverBackgroundColor']); + $dataSet->setPointHoverBorderColor($dataset['pointHoverBorderColor']); + $dataSet->data()->exchangeArray($dataset['data']); + $chart->addDataSet($dataSet); + } } break; @@ -1271,7 +1297,10 @@ function get_build_setup_charts($type, $options, $data) break; } - if ($type !== 'RADAR' && $type !== 'LINE') { + if ($type !== 'RADAR' + && $type !== 'LINE' + && ((isset($options['multiple']) === false || empty($options['multiple']) === true)) + ) { $chart->addDataSet($setData); } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 1e89e83243..87b2c9d89e 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -9572,9 +9572,19 @@ div.stat-win-spinner img { } .stat_win_histogram { - width: 95%; margin: 0 auto; - margin-top: 18%; +} + +.bg_general { + background-color: #ffffff; +} + +#tabs-chart-modal { + border: 0px; +} + +#tabs-chart-ul-graphs li a img { + margin-left: 20px; } #stat-win-module-graph .stat_win_histogram div.nodata_container { @@ -12787,3 +12797,22 @@ tr.shown td.details-control { position: relative; top: -92px; } + +.container-periodicity-graph { + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + align-content: center; + border: 1px solid #e5e9ed; + border-radius: 10px; + margin-top: 25px; + padding: 10px; +} + +.container-periodicity-graph > div { + flex: 0 0 auto; + width: 100%; + height: 300px; + background-color: transparent; +} diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index a16d4c6e65..0f8b7e707b 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -127,6 +127,7 @@ ui_print_message_dialog( + '; +echo '
'; +echo ''.__('Configure demo data').''; +html_print_input_hidden('update_config', 1); +html_print_table($table_aux); +echo '
'; + +$actionButtons = []; + +$actionButtons[] = html_print_submit_button( + __('Create demo data'), + 'update_button', + false, + [ 'icon' => 'update' ], + true +); + +$actionButtons[] = html_print_button( + __('Delete demo data'), + 'delete_session_users', + false, + '', + [ + 'icon' => 'delete', + 'mode' => 'secondary', + ], + true +); + +html_print_action_buttons( + implode('', $actionButtons) +); + +echo ''; + +?> + + \ No newline at end of file diff --git a/pandora_console/include/ajax/demo_data.ajax.php b/pandora_console/include/ajax/demo_data.ajax.php new file mode 100644 index 0000000000..1016903e57 --- /dev/null +++ b/pandora_console/include/ajax/demo_data.ajax.php @@ -0,0 +1,386 @@ + 0) { + // Read all ini files. + $parsed_ini[] = parse_ini_file($config['homedir'].'/extras/demodata/agents/linux.ini', true, INI_SCANNER_TYPED); +hd($parsed_ini, true); + $ag_groups_num = ($agents_num / 10); + + // Create new group per group of ten agents that are to be created. + for ($i=0; $i<$ag_groups_num; $i++) { + $group_name = db_get_value_sql( + 'SELECT tg.nombre + FROM tdemo_data tdd INNER JOIN tgrupo tg ON tdd.item_id = tg.id_grupo + WHERE tdd.table_name = "tgrupo" + ORDER BY tdd.id DESC' + ); + + if ($group_name === false) { + $group_last_id = 0; + } else { + $group_last_id = (int) explode(' ', $group_name)[2]; + } + + if (!($group_last_id > -1)) { + echo json_encode(['msg' => 'Demo group ID not valid']); + return; + } + + $demo_group_name = 'Demo group '.($i + $group_last_id + 1); + + $created_group_id = groups_create_group($demo_group_name, []); + + if ($created_group_id > 0) { + $demo_group_ids[] = $created_group_id; + + // Register created demo item in tdemo_data. + $values = [ + 'item_id' => $created_group_id, + 'table_name' => 'tgrupo', + ]; + $result = (bool) db_process_sql_insert('tdemo_data', $values); + + if ($result === false) { + // Rollback group creation. + db_process_sql_delete('tgrupo', ['id_grupo' => $created_group_id]); + } + } else { + echo json_encode(['msg' => 'Could not create demo agent group']); + return; + } + } + + $agents_created_count = 0; + $group_idx = 0; + + $agent_alias = db_get_value_sql('SELECT ta.alias FROM tdemo_data tdd INNER JOIN tagente ta ON tdd.item_id = ta.id_agente WHERE tdd.table_name="tagente" ORDER BY tdd.id DESC'); + + if ($agent_alias === false) { + $agent_last_id = 0; + } else { + $agent_last_id = (int) explode(' ', $agent_alias)[1]; + } + + foreach ($parsed_ini as $ini_so_data) { + $agent_data = $ini_so_data['agent_data']; + $modules_data = $ini_so_data['modules']; + $inventory = $ini_so_data['inventory']; + $inventory_values = $ini_so_data['inventory_values']; + + $address_network = $agent_data['address_network']; + $os_versions = $agent_data['os_versions']; + $os_name = $agent_data['os_name']; + + // Get OS id given OS name. + $id_os = db_get_value_filter('id_os', 'tconfig_os', ['name' => $os_name]); + + if ($id_os === false) { + // Create OS if does not exist. + $values = ['name' => $os_name]; + $id_os = (bool) db_process_sql_insert('tconfig_os', $values); + + if ($id_os === false) { + continue; + } + } + + // Define agents to be created per group of 10. + $agents_per_os = [ + 'Linux' => 5, + 'Windows' => 2, + 'MAC OS' => 1, + 'BSD' => 1, + 'Cisco' => 1, + ]; + + $agents_to_create = ($ag_groups_num * $agents_per_os[$os_name]); + + for ($i=0; $i < $agents_to_create; $i++) { + $next_ip_address = calculateNextHostAddress($address_network); + + $os_version = current($os_versions); + next($os_versions); + + if (current($os_versions) === false) { + reset($os_versions); + } + + $agent_last_id++; + + $created_agent_id = agents_create_agent( + $agent_data['agent_alias'].' '.$agent_last_id, + $demo_group_ids[$group_idx], + // Default interval. + 300, + $next_ip_address, + false, + false, + $id_os, + $os_version + ); + + if ($created_agent_id > 0) { + // Register created demo item in tdemo_data. + $values = [ + 'item_id' => $created_agent_id, + 'table_name' => 'tagente', + ]; + $result = (bool) db_process_sql_insert('tdemo_data', $values); + + if ($result === false) { + // Rollback agent creation if could not be registered in tdemo_data. + db_process_sql_delete('tagente', ['id_agente' => $created_agent_id]); + continue; + } + } + + $agents_created_count++; + + if (($agents_created_count % 10) === 0) { + $group_idx++; + } + + // Create agent modules. + $module_access_idx = 1; + + while (1) { + $modules_array = []; + foreach ($modules_data as $key => $value) { + $modules_array[$key] = ($value[$module_access_idx] ?? null); + } + + $test_empty_array = array_filter($modules_array); + + if (empty($test_empty_array) === true) { + break; + } + + $id_tipo = db_get_value_filter('id_tipo', 'ttipo_modulo', ['nombre' => $modules_array['type']]); + + $values = [ + 'unit' => $modules_array['unit'], + 'descripcion' => $modules_array['description'], + 'id_tipo_modulo' => $id_tipo, + 'id_module_group' => ($modules_array['group'] ?? 0), + ]; + + $created_mod_id = modules_create_agent_module( + $created_agent_id, + io_safe_input($modules_array['name']), + $values + ); + + if ($created_mod_id > 0) { + // Register created demo item in tdemo_data. + $values = [ + 'item_id' => $created_mod_id, + 'table_name' => 'tagente_modulo', + ]; + + $result = (bool) db_process_sql_insert('tdemo_data', $values); + + if ($result === false) { + // Rollback agent module creation if could not be registered in tdemo_data. + db_process_sql_delete('tagente_modulo', ['id_agente_modulo' => $created_mod_id]); + continue; + } + + // Insert module data. + $parsed = explode(';', $modules_array['values']); + + if ((string) $parsed[0] === 'RANDOM') { + $data = rand($parsed[1], $parsed[2]); + } else if ((string) $parsed[0] === 'PROC') { + $probability = (int) $parsed[1]; + + $data = 0; + + if ($probability > 0) { + $randomNumber = rand(1, 100); + + if ($randomNumber <= $probability) { + $data = 1; + } + } + } + + $agent_data_values = [ + 'id_agente_modulo' => $created_mod_id, + 'datos' => $data, + 'utimestamp' => time(), + ]; + + db_process_sql_insert('tagente_datos', $agent_data_values); + } + + $module_access_idx++; + }; + + // Create inventory modules. + $module_access_idx = 1; + $date_time = new DateTime(); + $current_date_time = $date_time->format('Y-m-d H:i:s'); + + while (1) { + $modules_array = []; + foreach ($inventory as $key => $value) { + $modules_array[$key] = ($value[$module_access_idx] ?? null); + } + + $test_empty_array = array_filter($modules_array); + + if (empty($test_empty_array) === true) { + break; + } + + $values = [ + 'name' => $modules_array['name'], + 'data_format' => $modules_array['format'], + 'id_os' => 1, + ]; + + // STEP 1: tmodule_inventory. + $created_inventory_mod_id = inventory_create_inventory_module($values); + + if ($created_inventory_mod_id > 0) { + // Register created demo item in tdemo_data. + $values = [ + 'item_id' => $created_inventory_mod_id, + 'table_name' => 'tmodule_inventory', + ]; + $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('tmodule_inventory', ['id_module_inventory' => $created_inventory_mod_id]); + continue; + } + } + + $module_access_idx++; + + // STEP 2: tagent_module_inventory. + $values = [ + 'id_agente' => $created_agent_id, + 'id_module_inventory' => $created_inventory_mod_id, + 'interval' => 300, + 'utimestamp' => time(), + 'timestamp' => $current_date_time, + ]; + + + + // STEP 3: Create inventory values (tagente_datos_inventory). + $field_idx = 1; + $values_array = explode(';', $modules_array['values']); + + $selected_inventory_values = array_filter( + $inventory_values, + function ($key) use ($values_array) { + return in_array($key, $values_array); + }, + ARRAY_FILTER_USE_KEY + ); + + hd("INV VALUES", true); + hd($selected_inventory_values, true); + + $data_lines = []; + while (1) { + $line_values = array_column($selected_inventory_values, $field_idx); + + if (empty(array_filter($line_values)) === true) { + break; + } + + $data_lines[] = implode(';', $line_values); + $field_idx++; + } + + $data_str = implode('\n', $data_lines); + + hd("DATA STR",true); + hd($data_str, true); + + $inventory_data_values = [ + 'data' => $data_str, + 'utimestamp' => time(), + 'timestamp' => $current_date_time, + ]; + + $created_inventory_data = db_process_sql_insert('tagente_datos_inventory', $inventory_data_values); + hd("CID",true); + hd($inventory_data_values, true); + hd($created_inventory_data, true); + + if ($created_inventory_data > 0) { + // Register created inventory data element in tdemo_data. + $values = [ + 'item_id' => $created_inventory_data, + 'table_name' => 'tagente_datos_inventory', + ]; + $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( + 'tagente_datos_inventory', + ['id_agent_module_inventory' => $created_inventory_data] + ); + + continue; + } + } + }; + } + } + } + + return; +} + + +function calculateNextHostAddress($ip) { + list($network, $subnet) = explode('/', $ip); + + // Convert the network address to an array of octets. + $octets = explode('.', $network); + + // Convert the last octet to an integer. + $lastOctet = (int)$octets[3]; + + // Increment the last octet, and wrap around if it exceeds 255. + $lastOctet = ($lastOctet + 1) % 256; + + // Assemble the next host address. + $nextHost = implode('.', array($octets[0], $octets[1], $octets[2], $lastOctet)); + + return $nextHost . '/' . $subnet; +} \ No newline at end of file diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index 5e66268403..cd057414d0 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -581,6 +581,7 @@ class WelcomeWindow extends Wizard ], ]; + $fields['load_demo_data'] = __('Load demo data'); $fields['wizard_agent'] = __('Agent installation wizard'); $fields['check_web'] = __('Create WEB monitoring'); $fields['check_connectivity'] = __('Create network monitoring'); @@ -1112,6 +1113,9 @@ class WelcomeWindow extends Wizard alert(""); } else { switch($('#task_to_perform :selected').val()) { + case 'load_demo_data': + loadDemoDataPage(); + break; case 'wizard_agent': deployAgent(); break; @@ -1152,6 +1156,11 @@ class WelcomeWindow extends Wizard window.location = ''; } + // Task to do actions. + function loadDemoDataPage() { + window.location = ''; + } + function openCreateModulesDialog() { $('#dialog_goliat').dialog({ title: '', diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 720b0e6e55..04174569a1 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -207,6 +207,8 @@ function agents_get_next_contact_time_left(int $id_agente) * @param string $ip_address Agent IP. * @param mixed $values Other tagente fields. * @param boolean $alias_as_name True to not assign an alias as name. + * @param mixed $os OS ID. + * @param mixed $os_version OS version. * * @return integer New agent id if created. False if it could not be created. */ @@ -216,7 +218,9 @@ function agents_create_agent( $interval, $ip_address, $values=false, - $alias_as_name=false + $alias_as_name=false, + $os=false, + $os_version=false ) { global $config; @@ -250,6 +254,14 @@ function agents_create_agent( $values['direccion'] = $ip_address; } + if (empty($os) === false) { + $values['id_os'] = $os; + } + + if (empty($os_version) === false) { + $values['os_version'] = $os_version; + } + // Check if group has limit or overrides the agent limit. if (group_allow_more_agents($id_group, true, 'create') === false) { return false; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 141ab4344d..86533ed028 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4516,4 +4516,15 @@ CREATE TABLE IF NOT EXISTS `tgraph_analytics_filter` ( `graph_modules` TEXT NULL, `interval` INT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +-- --------------------------------------------------------------------- +-- Table `tdemo_data` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tdemo_data` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `item_id` INT UNSIGNED NULL DEFAULT NULL, + `table_name` VARCHAR(64) NULL DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + From fc82a04a58ffbddf38fdf8521b2e0e60d979f553 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Fri, 27 Oct 2023 08:42:07 +0200 Subject: [PATCH 057/264] change location of file --- .../{update_manager_client => }/required_um_versions.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pandora_console/{update_manager_client => }/required_um_versions.php (100%) diff --git a/pandora_console/update_manager_client/required_um_versions.php b/pandora_console/required_um_versions.php similarity index 100% rename from pandora_console/update_manager_client/required_um_versions.php rename to pandora_console/required_um_versions.php From fa39a975182eef8e60726240edf06c748b491c1b Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 27 Oct 2023 10:18:10 +0200 Subject: [PATCH 058/264] Module histogram only events pandora_enterprise#12209 --- pandora_console/include/functions_events.php | 52 +++ .../include/functions_reporting.php | 300 ++++++++---------- 2 files changed, 185 insertions(+), 167 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index f709fe2b4c..78a5a65bd2 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -127,6 +127,58 @@ function events_translate_event_type($event_type) } +/** + * Module status event_type into descriptive text. + * + * @param integer $event_type Event type. + * + * @return string Module status. + */ +function events_status_module_event_type($event_type) +{ + $module_status = ''; + switch ($event_type) { + case 'alert_fired': + case 'alert_recovered': + case 'alert_ceased': + case 'alert_manual_validation': + $module_status = AGENT_MODULE_STATUS_CRITICAL_ALERT; + break; + + case 'going_down_normal': + case 'going_up_normal': + $module_status = AGENT_MODULE_STATUS_NORMAL; + break; + + case 'going_unknown': + case 'unknown': + $module_status = AGENT_MODULE_STATUS_UNKNOWN; + break; + + case 'going_up_warning': + case 'going_down_warning': + $module_status = AGENT_MODULE_STATUS_WARNING; + break; + + case 'going_up_critical': + case 'going_down_critical': + $module_status = AGENT_MODULE_STATUS_CRITICAL_BAD; + break; + + case 'recon_host_detected': + case 'system': + case 'error': + case 'new_agent': + case 'configuration_change': + default: + $module_status = AGENT_MODULE_STATUS_NOT_INIT; + break; + } + + return $module_status; +} + + /** * Translates a numeric value event_status into descriptive text. * diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 39f1642fa0..d7dfef4b58 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -15920,171 +15920,153 @@ function reporting_module_histogram_graph($report, $content, $pdf=0) return false; } - $module_interval = modules_get_interval( - $content['id_agent_module'] - ); - $slice = ($content['period'] / $module_interval); + $filter = [ + 'id_agentmodule' => $content['id_agent_module'], + 'group_rep' => EVENT_GROUP_REP_ALL, + 'date_to' => date('Y-m-d', ($report['datetime'] - $content['period'])), + 'time_to' => date('H:i:s', ($report['datetime'] - $content['period'])), + ]; - $result_sla = reporting_advanced_sla( - $content['id_agent_module'], - ($report['datetime'] - $content['period']), - $report['datetime'], - null, - null, + $previous_event = events_get_all( + ['te.event_type, te.timestamp, te.utimestamp'], + $filter, 0, - null, - null, - null, - $slice, 1, + 'desc', + 'timestamp', true ); - // Select Warning and critical values. - $agentmodule_info = modules_get_agentmodule($content['id_agent_module']); - $min_value_critical = ($agentmodule_info['min_critical'] == 0) ? null : $agentmodule_info['min_critical']; + $status = ''; + if ($previous_event !== false) { + $previous_event = end($previous_event); + $status = $previous_event['event_type']; + } - // Check if module type is string. - $modules_is_string = modules_is_string($agentmodule_info['id_agente_modulo']); + $date_start = ($report['datetime'] - $content['period']); + $filter = [ + 'id_agentmodule' => $content['id_agent_module'], + 'group_rep' => EVENT_GROUP_REP_ALL, + 'date_from' => date('Y-m-d', $date_start), + 'date_to' => date('Y-m-d', $report['datetime']), + 'time_from' => date('H:i:s', $date_start), + 'time_to' => date('H:i:s', $report['datetime']), + ]; - if ($modules_is_string === false) { - if ($agentmodule_info['max_critical'] == 0) { - $max_value_critical = null; - if ($agentmodule_info['min_critical'] == 0) { - if ((bool) $content['dinamic_proc'] === true) { - $max_value_critical = 0.01; - } + $events = events_get_all( + ['te.event_type, te.timestamp, te.utimestamp'], + $filter, + null, + null, + null, + null, + true + ); + + $not_init_data = []; + $previous_data = [ + 'event_type' => $status, + 'utimestamp' => $date_start, + ]; + if (empty($status) === true) { + // Si viene de no iniciado busco el rpimer dato del modulo y si es de histórico. + $first_utimestamp = false; + $search_historydb = false; + $extract_first_data = modules_get_first_date($content['id_agent_module'], 0); + if (empty($extract_first_data) === false) { + $first_utimestamp = $extract_first_data['first_utimestamp']; + $search_historydb = (isset($extract_first_data['search_historydb']) === true) ? $extract_first_data['search_historydb'] : false; + } + + // Si se encuentra algun dato. + // Si no hay eventos, la fecha del primer dato no sea mayor al fin del report (seria un bloque completo de no iniciado). + // Se comprueba que si existen eventos el dato no sea previo al evento. + if ($first_utimestamp !== false + && (($events === false && $first_utimestamp < $report['datetime']) || ($events !== false && $first_utimestamp < $events[0]['utimestamp'])) + ) { + // Tenemos en cuenta si el modulo es de tipo string. + $module = modules_get_agentmodule($content['id_agent_module']); + $module_type = $module['id_tipo_modulo']; + $module_type_str = modules_get_type_name($module_type); + $table = 'tagente_datos'; + if (strstr($module_type_str, 'string') !== false) { + $table = 'tagente_datos_string'; + } + + $query = sprintf( + 'SELECT datos,utimestamp + FROM %s + WHERE id_agente_modulo = %d + AND utimestamp = %d + ', + $table, + $content['id_agent_module'], + $first_utimestamp + ); + + $data = db_get_all_rows_sql($query, $search_historydb); + if ($data !== false) { + $not_init_data = [ + 'event_type' => $status, + 'utimestamp' => $date_start, + ]; + $previous_data = [ + 'event_type' => 'going_up_normal', + 'utimestamp' => $data[0]['utimestamp'], + ]; } - } else { - $max_value_critical = $agentmodule_info['max_critical']; - } - } else { - if ($agentmodule_info['str_critical'] == '') { - $max_value_critical = null; - } else { - $max_value_critical = $agentmodule_info['str_critical']; } } - $inverse_critical = $agentmodule_info['critical_inverse']; - - $min_value_warning = ($agentmodule_info['min_warning'] == 0) ? null : $agentmodule_info['min_warning']; - - if ($modules_is_string === false) { - if ($agentmodule_info['max_warning'] == 0) { - $max_value_warning = null; - } else { - $max_value_warning = $agentmodule_info['max_warning']; - } - } else { - if ($agentmodule_info['str_warning'] == '') { - $max_value_warning = null; - } else { - $max_value_warning = $agentmodule_info['str_warning']; - } + $array_result = []; + $time_total = $content['period']; + $check_total = 0; + $check_ok = 0; + $time_ok = 0; + if (empty($events) === true) { + $events = []; } - $inverse_warning = $agentmodule_info['warning_inverse']; + // Añadimos el dato previo. + array_unshift($events, $previous_data); + if (empty($not_init_data) === false) { + // Añadimos si viene de no iniciado el no iniciado. + array_unshift($events, $not_init_data); + } - $data = []; - $data['time_total'] = 0; - $data['time_ok'] = 0; - $data['time_error'] = 0; - $data['time_warning'] = 0; - $data['time_unknown'] = 0; - $data['time_not_init'] = 0; - $data['time_downtime'] = 0; - $data['checks_total'] = 0; - $data['checks_ok'] = 0; - $data['checks_error'] = 0; - $data['checks_warning'] = 0; - $data['checks_unknown'] = 0; - $data['checks_not_init'] = 0; - - $array_graph = []; + $current_time = time(); $i = 0; - foreach ($result_sla as $value_sla) { - $data['time_total'] += $value_sla['time_total']; - $data['time_ok'] += $value_sla['time_ok']; - $data['time_error'] += $value_sla['time_error']; - $data['time_warning'] += $value_sla['time_warning']; - $data['time_unknown'] += $value_sla['time_unknown']; - $data['time_downtime'] += $value_sla['time_downtime']; - $data['time_not_init'] += $value_sla['time_not_init']; - $data['checks_total'] += $value_sla['checks_total']; - $data['checks_ok'] += $value_sla['checks_ok']; - $data['checks_error'] += $value_sla['checks_error']; - $data['checks_warning'] += $value_sla['checks_warning']; - $data['checks_unknown'] += $value_sla['checks_unknown']; - $data['checks_not_init'] += $value_sla['checks_not_init']; - - // Generate raw data for graph. - if ($value_sla['time_total'] != 0) { - if ($value_sla['time_error'] > 0) { - // ERR. - $array_graph[$i]['data'] = 3; - } else if ($value_sla['time_unknown'] > 0) { - // UNKNOWN. - $array_graph[$i]['data'] = 4; - } else if ($value_sla['time_warning'] > 0) { - // Warning. - $array_graph[$i]['data'] = 2; - } else if ($value_sla['time_not_init'] == $value_sla['time_total']) { - // NOT INIT. - $array_graph[$i]['data'] = 6; - } else { - $array_graph[$i]['data'] = 1; - } + foreach ($events as $event) { + $array_result[$i]['data'] = events_status_module_event_type($event['event_type']); + if (isset($events[($i + 1)]) === true) { + $period = ($events[($i + 1)]['utimestamp'] - $event['utimestamp']); + $array_result[$i]['utimestamp'] = $period; } else { - $array_graph[$i]['data'] = 7; + $period = ($report['datetime'] - $event['utimestamp']); + // El ultimo evento solo lo arrastramos hasta la fecha actual. + // Si pedimos mas fecha sera desconocido. + if ($report['datetime'] > $current_time) { + $period = ($current_time - $event['utimestamp']); + } + + $array_result[$i]['utimestamp'] = $period; } - $array_graph[$i]['utimestamp'] = ($value_sla['date_to'] - $value_sla['date_from']); + if ($array_result[$i]['data'] === AGENT_MODULE_STATUS_NORMAL) { + $check_ok++; + $time_ok += $period; + } + + $check_total++; $i++; } - $data['sla_value'] = reporting_sla_get_compliance_from_array( - $data - ); - - $data['sla_fixed'] = sla_truncate( - $data['sla_value'], - $config['graph_precision'] - ); - - $data_init = -1; - $acum = 0; - $sum = 0; - $array_result = []; - $i = 0; - foreach ($array_graph as $value) { - if ($data_init == -1) { - $data_init = $value['data']; - $acum = $value['utimestamp']; - } else { - if ($data_init == $value['data']) { - $acum = ($acum + $value['utimestamp']); - } else { - $array_result[$i]['data'] = $data_init; - $array_result[$i]['utimestamp'] = $acum; - $array_result[$i]['real_data'] = $sum; - $i++; - $data_init = $value['data']; - $acum = $value['utimestamp']; - } - } + // Bloque por si se pide mas fecha. + if ($report['datetime'] > $current_time) { + $array_result[$i]['data'] = AGENT_MODULE_STATUS_UNKNOWN; + $array_result[$i]['utimestamp'] = ($report['datetime'] - $current_time); } - if (count($array_result) == 0) { - $array_result = $array_graph; - } else { - $array_result[$i]['data'] = $data_init; - $array_result[$i]['utimestamp'] = $acum; - $array_result[$i]['real_data'] = $sum; - } - - $time_total = $data['time_total']; - // Slice graphs calculation. $return['agent'] = modules_get_agentmodule_agent_alias( $content['id_agent_module'] ); @@ -16092,37 +16074,21 @@ function reporting_module_histogram_graph($report, $content, $pdf=0) $content['id_agent_module'] ); - $return['max_critical'] = $max_value_critical; - $return['min_critical'] = $min_value_critical; - $return['critical_inverse'] = $inverse_critical; - $return['max_warning'] = $max_value_warning; - $return['min_warning'] = $min_value_warning; - $return['warning_inverse'] = $inverse_warning; - $return['data_not_init'] = $data['checks_not_init']; - $return['data_unknown'] = $data['checks_unknown']; - $return['data_critical'] = $data['checks_error']; - $return['data_warning'] = $data['checks_warning']; - $return['data_ok'] = $data['checks_ok']; - $return['data_total'] = $data['checks_total']; - $return['time_not_init'] = $data['time_not_init']; - $return['time_unknown'] = $data['time_unknown']; - $return['time_critical'] = $data['time_error']; - $return['time_warning'] = $data['time_warning']; - $return['time_ok'] = $data['time_ok']; - if ($data['checks_total'] > 0) { - $return['percent_ok'] = (($data['checks_ok'] * 100) / $data['checks_total']); + $return['data_ok'] = $check_ok; + $return['data_total'] = $check_total; + if ($check_total > 0) { + $return['percent_ok'] = (($time_ok * 100) / $content['period']); } else { $return['percent_ok'] = 0; } $colors = [ - 1 => COL_NORMAL, - 2 => COL_WARNING, - 3 => COL_CRITICAL, - 4 => COL_UNKNOWN, - 5 => COL_DOWNTIME, - 6 => COL_NOTINIT, - 7 => COL_IGNORED, + AGENT_MODULE_STATUS_CRITICAL_ALERT => COL_ALERTFIRED, + AGENT_MODULE_STATUS_NORMAL => COL_NORMAL, + AGENT_MODULE_STATUS_UNKNOWN => COL_UNKNOWN, + AGENT_MODULE_STATUS_WARNING => COL_WARNING, + AGENT_MODULE_STATUS_CRITICAL_BAD => COL_CRITICAL, + AGENT_MODULE_STATUS_NOT_INIT => COL_NOTINIT, ]; $width_graph = 100; From 407a505a3e2f20bf185364cc89c90fae6a4e60d3 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Fri, 27 Oct 2023 14:32:48 +0200 Subject: [PATCH 059/264] #8365 Added reports for ncm backups. --- .../reporting_builder.item_editor.php | 111 ++++++++++++++++++ .../godmode/reporting/reporting_builder.php | 31 ++++- pandora_console/include/functions_reports.php | 5 + .../operation/agentes/ver_agente.php | 26 ++++ 4 files changed, 169 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index e6032de2f6..d13071c60a 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -1039,6 +1039,11 @@ switch ($action) { $idAgent = $item['id_agent']; break; + case 'ncm_backups': + $id_agent_ncm = $item['id_agent']; + $ncm_group = $item['id_group']; + break; + case 'top_n_agents_sh': $group = $item['id_group']; $recursion = $item['recursion']; @@ -1928,6 +1933,71 @@ if (is_metaconsole() === true) { ?>
+ '; + $url = ui_get_full_url('ajax.php'); + html_print_input_hidden('url_ajax', $url, false, false, false, 'url_ajax'); + if (check_acl($config['id_user'], 0, 'RW')) { + html_print_select_groups( + $config['id_user'], + 'RW', + true, + 'ncm_group', + $ncm_group, + 'filterNcmAgentChange()', + ); + } else if (check_acl($config['id_user'], 0, 'RM')) { + html_print_select_groups( + $config['id_user'], + 'RM', + true, + 'ncm_group', + $ncm_group, + 'filterNcmAgentChange()', + ); + } + + echo ''; + ?> +
+ '; + $all_agents = agents_get_agents_selected($ncm_group); + html_print_select( + $all_agents, + 'agent_ncm', + $id_agent_ncm, + '', + __('Any'), + 0, + false, + true, + true, + '', + false, + 'width: 100%;', + false, + false, + false, + '', + false, + false, + false, + false, + true, + true, + ); + echo ''; + ?> +
@@ -6915,6 +6985,10 @@ function chooseType() { $('#agent_autocomplete_events').show(); + // NCM fields. + $("#row_ncm_group").hide(); + $("#row_ncm_agent").hide(); + switch (type) { case 'event_report_group': $("#row_description").show(); @@ -7764,6 +7838,11 @@ function chooseType() { $("#row_agent").show(); break; + case 'ncm_backups': + $("#row_ncm_group").show(); + $("#row_ncm_agent").show(); + break; + case 'top_n_agents_sh': $("#row_group").show(); $("#row_max_items").show(); @@ -8046,4 +8125,36 @@ $(document).ready(function () { }); }); +// Ncm agent filter by group. +function filterNcmAgentChange() { + var idGroup = $("#ncm_group").val(); + const url_ajax = $("#url_ajax").val(); + + $.ajax({ + url: url_ajax, + type: "POST", + dataType: "json", + async: false, + data: { + page: "operation/agentes/ver_agente", + get_ncm_agents: 1, + id_group: idGroup, + privilege: "AW", + keys_prefix: "_" + }, + success: function(data) { + $("#agent_ncm").empty(); + data.map(item => { + var option = $("") + .attr("value", item.id_agent) + .html(item.alias); + $("#agent_ncm").append(option); + }); + }, + error: function(err) { + console.error(err); + } + }); +} + diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 095f79b14a..349bad535e 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -2045,6 +2045,12 @@ switch ($action) { $good_format = true; break; + case 'ncm_backups': + $values['id_agent'] = get_parameter('agent_ncm'); + $values['id_group'] = get_parameter('ncm_group'); + $good_format = true; + break; + default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( @@ -2065,7 +2071,10 @@ switch ($action) { break; } - $values['id_agent'] = get_parameter('id_agent'); + if (isset($values['id_agent']) === false) { + $values['id_agent'] = get_parameter('id_agent'); + } + $values['id_gs'] = get_parameter('id_custom_graph'); $values['id_agent_module'] = ''; @@ -2181,7 +2190,10 @@ switch ($action) { $values['id_module_group'] = get_parameter( 'combo_modulegroup' ); - $values['id_group'] = get_parameter('combo_group'); + + if (isset($values['id_group']) === false) { + $values['id_group'] = get_parameter('combo_group'); + } if ($values['server_name'] == '') { $values['server_name'] = get_parameter( @@ -2977,6 +2989,12 @@ switch ($action) { $good_format = true; break; + case 'ncm_backups': + $values['id_agent'] = get_parameter('agent_ncm'); + $values['id_group'] = get_parameter('ncm_group'); + $good_format = true; + break; + default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( @@ -3003,7 +3021,10 @@ switch ($action) { ); } - $values['id_agent'] = get_parameter('id_agent'); + if (isset($values['id_agent']) === false) { + $values['id_agent'] = get_parameter('id_agent'); + } + $values['id_gs'] = get_parameter('id_custom_graph'); if (($values['type'] == 'alert_report_agent') || ($values['type'] == 'event_report_agent') @@ -3117,7 +3138,9 @@ switch ($action) { $values['id_module_group'] = get_parameter( 'combo_modulegroup' ); - $values['id_group'] = get_parameter('combo_group'); + if (isset($values['id_group']) === false) { + $values['id_group'] = get_parameter('combo_group'); + } if ((($values['type'] == 'custom_graph') diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 3da9993933..8956e3adc9 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -968,6 +968,11 @@ function reports_get_report_types($template=false, $not_editor=false) 'name' => __('Network configuration changes'), ]; + $types['ncm_backups'] = [ + 'optgroup' => __('NCM'), + 'name' => __('Network backups'), + ]; + if (enterprise_installed() === true) { $types['top_n_agents_sh'] = [ 'optgroup' => __('Security hardening'), diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 383a3b40d5..b050ba3b31 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -28,6 +28,7 @@ use PandoraFMS\Enterprise\Metaconsole\Node; use PandoraFMS\ITSM\ITSM; +use PandoraFMS\Enterprise\NetworkManager; global $config; @@ -72,6 +73,7 @@ if (is_ajax()) { $get_node_agent = (bool) get_parameter('get_node_agent', false); $get_agent_inventory_modules = (bool) get_parameter('get_agent_inventory_modules', false); $get_agent_inventory_dates = (bool) get_parameter('get_agent_inventory_dates', false); + $get_ncm_agents = (bool) get_parameter('get_ncm_agents', false); $refresh_contact = get_parameter('refresh_contact', 0); @@ -213,6 +215,30 @@ if (is_ajax()) { return; } + + // Get ncm Agent. + if ($get_ncm_agents === true) { + $fields = [ + '`tncm_agent`.id_agent', + '`tagente`.alias', + ]; + $id_group = (int) get_parameter('id_group'); + + $filter['filter_id_group'] = $id_group; + // Retrieve data. + $ncm_data = NetworkManager::agents( + // Fields. + $fields, + // Filter. + $filter, + ); + + echo json_encode($ncm_data); + return; + } + + + if ($get_modules_group_json === true) { $id_group = (int) get_parameter('id_module_group', 0); $id_agents = get_parameter('id_agents', null); From e062db2439ca1499f6ab6e93dd6fd5a456fec88d Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 30 Oct 2023 08:39:20 +0100 Subject: [PATCH 060/264] #8365 NCM add backup id to ncm queue --- pandora_console/pandoradb.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 1d7374bc03..8a4fca2917 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4226,6 +4226,7 @@ CREATE TABLE IF NOT EXISTS `tncm_agent_data` ( `id` SERIAL, `id_agent` INT UNSIGNED NOT NULL, `script_type` INT UNSIGNED NOT NULL, + `id_agent_data` INT NOT NULL DEFAULT 0, `data` LONGBLOB, `status` INT NOT NULL DEFAULT 5, `updated_at` BIGINT NOT NULL DEFAULT 0, From 63c74e2aa958355b0471de1b38ebd608dc4f38dc Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 30 Oct 2023 08:55:21 +0100 Subject: [PATCH 061/264] #8365 recovery after vscode revert error --- pandora_console/extras/mr/67.sql | 6 +-- pandora_console/pandoradb.sql | 4 +- pandora_server/lib/PandoraFMS/Tools.pm | 61 ++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index aa44ceea56..d15e49cf38 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -1,7 +1,7 @@ START TRANSACTION; ALTER TABLE `tncm_queue` -ADD COLUMN `id_agent_data` INT NOT NULL DEFAULT 0 AFTER `id_script`; +ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`, +ADD CONSTRAINT `fk_tncm_queue_tncm_agent_data` FOREIGN KEY (`id_agent_data`) REFERENCES `tncm_agent_data`(`id`) ON UPDATE CASCADE ON DELETE SET NULL; - -COMMIT; \ No newline at end of file +COMMIT; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 8a4fca2917..de34968f68 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4240,10 +4240,12 @@ CREATE TABLE IF NOT EXISTS `tncm_queue` ( `id` SERIAL, `id_agent` INT UNSIGNED NOT NULL, `id_script` BIGINT UNSIGNED NOT NULL, + `id_agent_data` bigint unsigned, `utimestamp` INT UNSIGNED NOT NULL, `scheduled` INT UNSIGNED DEFAULT NULL, FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE + FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_agent_data`) REFERENCES `tncm_agent_data`(`id`) ON UPDATE CASCADE ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 70d697dab4..a0cc1c15ac 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -30,6 +30,9 @@ use Scalar::Util qw(looks_like_number); use LWP::UserAgent; use threads; use threads::shared; +use MIME::Base64; +use Crypt::CBC; +use Digest::SHA qw(hmac_sha256_base64); use JSON; use Encode qw/decode_utf8 encode_utf8/; @@ -181,6 +184,7 @@ our @EXPORT = qw( check_cron_value check_cron_element cron_check + decrypt_AES ); # ID of the different servers @@ -2983,6 +2987,63 @@ sub get_server_name { return "UNKNOWN"; } +############################################################################### +# Encrypt with AES cypher +############################################################################### +sub encrypt_AES { + my ($str_to_encrypt, $password) = @_; + + if (!defined($password)) { + $password = "default_salt"; + } + my $cipher = _get_cipher($password); + + my $cipher_text = $cipher->encrypt($str_to_encrypt); + my $b64str = encode_base64($cipher_text, ''); + + return $b64str; +} + +############################################################################### +# Decrypt with AES cypher +############################################################################### +sub decrypt_AES { + my ($str_to_decrypt, $password) = @_; + + if (!defined($password)) { + $password = "default_salt"; + } + my $cipher = _get_cipher($password); + + my $cipher_text = decode_base64($str_to_decrypt); + my $decrypted_str = $cipher->decrypt($cipher_text); + + return $decrypted_str; +} + +############################################################################### +# Get cipher for AES encrypt and decrypt +############################################################################### +sub _get_cipher { + my ($password) = @_; + + my $hash_base64 = substr(Digest::SHA::hmac_sha256_base64($password,''), 0, 16); + + my $iv = '0000000000000000'; + + my $cipher = Crypt::CBC->new( + -key => $hash_base64, + -cipher => 'Cipher::AES', + -iv => $iv, + -header => 'none', + -padding => 'standard', # PKCS7 padding + -keysize => 16, + -literal_key => 1 + ); + + return $cipher; +} + 1; __END__ From 84b9ac14fb66f5942637c819aef09475a598df00 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 30 Oct 2023 10:18:29 +0100 Subject: [PATCH 062/264] #8365Added viewer report for ncm backups --- pandora_console/include/functions_reporting.php | 8 ++++++++ pandora_console/operation/reporting/reporting_viewer.php | 1 + 2 files changed, 9 insertions(+) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 39f1642fa0..19c3f80b10 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -972,6 +972,14 @@ function reporting_make_reporting_data( ); break; + case 'ncm_backups': + $report['contents'][] = reporting_ncm_backups( + $report, + $content, + $pdf + ); + break; + case 'top_n_agents_sh': $report['contents'][] = reporting_top_n_agents_sh( $report, diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index cc42d7e6ac..4bc5a05b61 100755 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -335,6 +335,7 @@ $table2->data[0][3] = $html_menu_export; $searchForm = '
'; $searchForm .= html_print_table($table2, true); $searchForm .= html_print_input_hidden('id_report', $id_report, true); +$Actionbuttons = ''; if ((bool) is_metaconsole() === true) { $Actionbuttons .= html_print_submit_button( From 307fd7b8cb66e0c2cd35821ccbc9c25a8062e04e Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 30 Oct 2023 10:52:13 +0100 Subject: [PATCH 063/264] #8365 remove fk tncm_queue --- pandora_console/extras/mr/67.sql | 3 +-- pandora_console/pandoradb.sql | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index d15e49cf38..2f6824f1f2 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -1,7 +1,6 @@ START TRANSACTION; ALTER TABLE `tncm_queue` -ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`, -ADD CONSTRAINT `fk_tncm_queue_tncm_agent_data` FOREIGN KEY (`id_agent_data`) REFERENCES `tncm_agent_data`(`id`) ON UPDATE CASCADE ON DELETE SET NULL; +ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`; COMMIT; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index de34968f68..65e2459bdb 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4244,8 +4244,7 @@ CREATE TABLE IF NOT EXISTS `tncm_queue` ( `utimestamp` INT UNSIGNED NOT NULL, `scheduled` INT UNSIGNED DEFAULT NULL, FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_agent_data`) REFERENCES `tncm_agent_data`(`id`) ON UPDATE CASCADE ON DELETE SET NULL + FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- From 7db3e3bb2b52c03290523778e550416ddb761d8e Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 30 Oct 2023 17:20:58 +0100 Subject: [PATCH 064/264] #8365 Added html report for ncm backups --- .../include/functions_reporting_html.php | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 99f3af63ad..8fc6f3cf79 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -480,6 +480,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust reporting_html_ncm_config($table, $item); break; + case 'ncm_backups': + reporting_html_ncm_backups($table, $item); + break; + case 'top_n_agents_sh': reporting_html_top_n_agents_sh($table, $item); break; @@ -7380,3 +7384,49 @@ function reporting_html_ncm_config($table, $item, $pdf=0) return $content; } } + + +/** + * HTML content for ncm backup report. + * + * @param array $item Content generated by reporting_ncm_config. + * + * @return string HTML code. + */ +function reporting_html_ncm_backups($table, $item, $pdf=0) +{ + ui_require_javascript_file('diff2html-ui.min'); + ui_require_css_file('diff2html.min'); + ui_require_css_file('highlight.min'); + ui_require_css_file('highlight/vs.min'); + ui_require_javascript_file('highlight.min'); + ui_require_javascript_file('highlightjs-line-numbers.min'); + ui_require_javascript_file('languages/plaintext.min'); + ui_require_javascript_file('functions_ncm', ENTERPRISE_DIR.'/include/javascript/'); + + // Create table info. + $table_ncm = new stdClass(); + $table_ncm->width = '100%'; + $table_ncm->class = 'info_table'; + $table_ncm->styleTable = 'table-layout: fixed;'; + $table_ncm->rowstyle['title'] = 'text-align: center; font-weight: bolder'; + $table_ncm->head = []; + $table_ncm->head[0] = __('Date'); + $table_ncm->head[1] = __('Diff'); + + $table_ncm->data = []; + foreach ($item['data'] as $key => $row) { + $table_ncm->data[] = [ + $row['updated_at'], + $row['diff'], + ]; + } + + if ($pdf === 0) { + return $table->data[] = html_print_table( + $table_ncm, + true + ); + } + +} From b327c824da86c620a3aa383dff7e7c5be9d43ca4 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 31 Oct 2023 13:45:26 +0100 Subject: [PATCH 065/264] #8365 NCM new special templates --- pandora_console/extras/mr/67.sql | 27 +++++++++++++++++++++++++++ pandora_console/pandoradb.sql | 26 ++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index 2f6824f1f2..9da40c6829 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -3,4 +3,31 @@ START TRANSACTION; ALTER TABLE `tncm_queue` ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`; +CREATE TABLE IF NOT EXISTS `tncm_special_template` ( + `id` SERIAL, + `name` TEXT, + `vendors` TEXT, + `models` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +ALTER TABLE `tncm_agent` +ADD COLUMN `id_special_template` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `id_template`; + +CREATE TABLE IF NOT EXISTS `tncm_special_template_scripts` ( + `id` SERIAL, + `id_special_template` BIGINT UNSIGNED NOT NULL, + `id_script` BIGINT UNSIGNED NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_special_template`) REFERENCES `tncm_special_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +ALTER TABLE `tncm_agent` +ADD COLUMN `special_cron_interval` VARCHAR(100) NULL DEFAULT '' AFTER `cron_interval`; + +ALTER TABLE `tncm_agent` +ADD COLUMN `special_event_on_change` INT UNSIGNED NULL DEFAULT NULL AFTER `event_on_change`; + + COMMIT; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 65e2459bdb..24020ffb0f 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4191,6 +4191,29 @@ CREATE TABLE IF NOT EXISTS `tncm_template_scripts` ( FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; +-- ---------------------------------------------------------------------- +-- Table `tncm_special_template` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tncm_special_template` ( + `id` SERIAL, + `name` TEXT, + `vendors` TEXT, + `models` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +-- ---------------------------------------------------------------------- +-- Table `tncm_special_template_scripts` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tncm_special_template_scripts` ( + `id` SERIAL, + `id_special_template` BIGINT UNSIGNED NOT NULL, + `id_script` BIGINT UNSIGNED NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_special_template`) REFERENCES `tncm_special_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + -- ---------------------------------------------------------------------- -- Table `tncm_agent` -- ---------------------------------------------------------------------- @@ -4206,10 +4229,13 @@ CREATE TABLE IF NOT EXISTS `tncm_agent` ( `updated_at` BIGINT NOT NULL DEFAULT 0, `config_backup_id` BIGINT UNSIGNED DEFAULT NULL, `id_template` BIGINT UNSIGNED, + `id_special_template` BIGINT UNSIGNED, `execute_type` INT UNSIGNED NOT NULL DEFAULT 0, `execute` INT UNSIGNED NOT NULL DEFAULT 0, `cron_interval` VARCHAR(100) DEFAULT '', + `special_cron_interval` VARCHAR(100) DEFAULT '', `event_on_change` INT UNSIGNED DEFAULT null, + `special_event_on_change` INT UNSIGNED DEFAULT null, `last_error` TEXT, PRIMARY KEY (`id_agent`), FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, From 98332d728e9e84c80639e1f7cd989c7195ec1eac Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 31 Oct 2023 16:55:35 +0100 Subject: [PATCH 066/264] #8365 change name ncm agent data --- pandora_console/extras/mr/67.sql | 14 +++++++------- pandora_console/pandoradb.sql | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index 9da40c6829..b2b34e5ce4 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -3,7 +3,7 @@ START TRANSACTION; ALTER TABLE `tncm_queue` ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`; -CREATE TABLE IF NOT EXISTS `tncm_special_template` ( +CREATE TABLE IF NOT EXISTS `tncm_agent_data_template` ( `id` SERIAL, `name` TEXT, `vendors` TEXT, @@ -12,22 +12,22 @@ CREATE TABLE IF NOT EXISTS `tncm_special_template` ( ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; ALTER TABLE `tncm_agent` -ADD COLUMN `id_special_template` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `id_template`; +ADD COLUMN `id_agent_data_template` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `id_template`; -CREATE TABLE IF NOT EXISTS `tncm_special_template_scripts` ( +CREATE TABLE IF NOT EXISTS `tncm_agent_data_template_scripts` ( `id` SERIAL, - `id_special_template` BIGINT UNSIGNED NOT NULL, + `id_agent_data_template` BIGINT UNSIGNED NOT NULL, `id_script` BIGINT UNSIGNED NOT NULL, PRIMARY KEY (`id`), - FOREIGN KEY (`id_special_template`) REFERENCES `tncm_special_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_agent_data_template`) REFERENCES `tncm_agent_data_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; ALTER TABLE `tncm_agent` -ADD COLUMN `special_cron_interval` VARCHAR(100) NULL DEFAULT '' AFTER `cron_interval`; +ADD COLUMN `agent_data_cron_interval` VARCHAR(100) NULL DEFAULT '' AFTER `cron_interval`; ALTER TABLE `tncm_agent` -ADD COLUMN `special_event_on_change` INT UNSIGNED NULL DEFAULT NULL AFTER `event_on_change`; +ADD COLUMN `agent_data_event_on_change` INT UNSIGNED NULL DEFAULT NULL AFTER `event_on_change`; COMMIT; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 24020ffb0f..8b83b26011 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4192,9 +4192,9 @@ CREATE TABLE IF NOT EXISTS `tncm_template_scripts` ( ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- --- Table `tncm_special_template` +-- Table `tncm_agent_data_template` -- ---------------------------------------------------------------------- -CREATE TABLE IF NOT EXISTS `tncm_special_template` ( +CREATE TABLE IF NOT EXISTS `tncm_agent_data_template` ( `id` SERIAL, `name` TEXT, `vendors` TEXT, @@ -4203,14 +4203,14 @@ CREATE TABLE IF NOT EXISTS `tncm_special_template` ( ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- --- Table `tncm_special_template_scripts` +-- Table `tncm_agent_data_template_scripts` -- ---------------------------------------------------------------------- -CREATE TABLE IF NOT EXISTS `tncm_special_template_scripts` ( +CREATE TABLE IF NOT EXISTS `tncm_agent_data_template_scripts` ( `id` SERIAL, - `id_special_template` BIGINT UNSIGNED NOT NULL, + `id_agent_data_template` BIGINT UNSIGNED NOT NULL, `id_script` BIGINT UNSIGNED NOT NULL, PRIMARY KEY (`id`), - FOREIGN KEY (`id_special_template`) REFERENCES `tncm_special_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_agent_data_template`) REFERENCES `tncm_agent_data_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; @@ -4229,13 +4229,13 @@ CREATE TABLE IF NOT EXISTS `tncm_agent` ( `updated_at` BIGINT NOT NULL DEFAULT 0, `config_backup_id` BIGINT UNSIGNED DEFAULT NULL, `id_template` BIGINT UNSIGNED, - `id_special_template` BIGINT UNSIGNED, + `id_agent_data_template` BIGINT UNSIGNED, `execute_type` INT UNSIGNED NOT NULL DEFAULT 0, `execute` INT UNSIGNED NOT NULL DEFAULT 0, `cron_interval` VARCHAR(100) DEFAULT '', - `special_cron_interval` VARCHAR(100) DEFAULT '', + `agent_data_cron_interval` VARCHAR(100) DEFAULT '', `event_on_change` INT UNSIGNED DEFAULT null, - `special_event_on_change` INT UNSIGNED DEFAULT null, + `agent_data_event_on_change` INT UNSIGNED DEFAULT null, `last_error` TEXT, PRIMARY KEY (`id_agent`), FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, From f5e7ac8d4af9a6aa6ac39b44f1e1313748f8a225 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Tue, 31 Oct 2023 17:27:28 +0100 Subject: [PATCH 067/264] #8365 PDF report added for ncm backups --- .../include/functions_reporting_html.php | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 8fc6f3cf79..76f0920e34 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -7389,44 +7389,57 @@ function reporting_html_ncm_config($table, $item, $pdf=0) /** * HTML content for ncm backup report. * - * @param array $item Content generated by reporting_ncm_config. + * @param array $item Content generated by reporting_ncm_backups. * * @return string HTML code. */ function reporting_html_ncm_backups($table, $item, $pdf=0) { - ui_require_javascript_file('diff2html-ui.min'); ui_require_css_file('diff2html.min'); ui_require_css_file('highlight.min'); ui_require_css_file('highlight/vs.min'); + ui_require_javascript_file('diff2html-ui.min'); ui_require_javascript_file('highlight.min'); ui_require_javascript_file('highlightjs-line-numbers.min'); ui_require_javascript_file('languages/plaintext.min'); ui_require_javascript_file('functions_ncm', ENTERPRISE_DIR.'/include/javascript/'); - // Create table info. + // Create table diff. $table_ncm = new stdClass(); $table_ncm->width = '100%'; $table_ncm->class = 'info_table'; $table_ncm->styleTable = 'table-layout: fixed;'; - $table_ncm->rowstyle['title'] = 'text-align: center; font-weight: bolder'; + $table_ncm->headstyle[0] = 'width: 250px'; $table_ncm->head = []; $table_ncm->head[0] = __('Date'); $table_ncm->head[1] = __('Diff'); $table_ncm->data = []; - foreach ($item['data'] as $key => $row) { - $table_ncm->data[] = [ - $row['updated_at'], - $row['diff'], - ]; - } if ($pdf === 0) { + foreach ($item['data'] as $key => $row) { + $table_ncm->data[] = [ + $row['updated_at'], + $row['diff'], + ]; + } + return $table->data[] = html_print_table( $table_ncm, true ); + } else { + foreach ($item['data'] as $key => $row) { + $table_ncm->data[] = [ + $row['updated_at'], + ($row['diffstr'] === '') ? $row['diff'] : str_replace("\n", '
', $row['diffstr']), + ]; + } + + return html_print_table( + $table_ncm, + true + ); } } From 3031e7ddbddb52a6a7aea8381904bd4cf92825b5 Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Wed, 1 Nov 2023 10:13:44 -0600 Subject: [PATCH 068/264] Add export Encrypt AES to tools --- pandora_server/lib/PandoraFMS/Tools.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index a0cc1c15ac..48a46ea740 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -185,6 +185,7 @@ our @EXPORT = qw( check_cron_element cron_check decrypt_AES + encrypt_AES ); # ID of the different servers From 1a021c96899c1cd6af25eb09421445d0baa490c1 Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Thu, 2 Nov 2023 11:24:50 +0100 Subject: [PATCH 069/264] Added Rijndael encryption for python pandoraPlugintools and PandoraFMS::Tools --- .../extras/pandoraPlugintools/encryption.py | 89 +++++++++++++++++- pandora_server/lib/PandoraFMS/Tools.pm | 92 +++++++++---------- 2 files changed, 132 insertions(+), 49 deletions(-) diff --git a/pandora_server/extras/pandoraPlugintools/encryption.py b/pandora_server/extras/pandoraPlugintools/encryption.py index b1ec3c9315..576ae31ae3 100644 --- a/pandora_server/extras/pandoraPlugintools/encryption.py +++ b/pandora_server/extras/pandoraPlugintools/encryption.py @@ -39,7 +39,7 @@ def _print_debug( #### # Internal use only: Get AES cipher ######################################################################################### -def _get_cipher( +def _get_cipher_AES( password: str = _PASSWORD ) -> AES: ''' @@ -78,7 +78,7 @@ def encrypt_AES( Returns: str: The encrypted string in base64 encoding. ''' - cipher = _get_cipher(password) + cipher = _get_cipher_AES(password) try: msg_padded = pad(str_to_encrypt.encode(), AES.block_size, style='pkcs7') @@ -106,11 +106,94 @@ def decrypt_AES( Returns: str: The decrypted string. ''' - cipher = _get_cipher(password) + cipher = _get_cipher_AES(password) try: decrypted_str = unpad(cipher.decrypt(base64.b64decode(str_to_decrypt)), AES.block_size, style='pkcs7').decode().strip() except: decrypted_str = '' + return decrypted_str + +#### +# Internal use only: Get Rijndael cipher +######################################################################################### +def _get_cipher_Rijndael( + password: str = _PASSWORD + ) -> AES: + ''' + Internal use only: Get Rijndael cipher for encryption and decryption. + + Args: + password (str): The password used to derive the encryption key. + + Returns: + AES: An AES cipher instance for encryption and decryption. + ''' + key = b'' + msg = password.encode('utf-8') + hash_obj = hmac.new(key, msg, hashlib.sha256) + hash_result = hash_obj.digest() + hash_base64 = base64.b64encode(hash_result)[:16].decode() + + iv = b'0000000000000000' + + return AES.new(hash_base64.encode(), AES.MODE_CBC, iv) + +#### +# Return encrypted string +######################################################################################### +def encrypt_Rijndael( + str_to_encrypt: str = "", + password: str = _PASSWORD + ) -> str: + ''' + Encrypt a string using Rijndael encryption. + + Args: + str_to_encrypt (str): The string to be encrypted. + password (str): The password used to derive the encryption key. + + Returns: + str: The encrypted string in base64 encoding. + ''' + cipher = _get_cipher_Rijndael(password) + + block_size = 16 # Rijndael block size is 16 bytes + padding_length = block_size - (len(str_to_encrypt) % block_size) + padded_data = str_to_encrypt + chr(padding_length) * padding_length + + try: + b64str = base64.b64encode(cipher.encrypt(padded_data.encode())).decode() + except Exception as e: + b64str = '' + + return b64str + +#### +# Return decrypted string +######################################################################################### +def decrypt_Rijndael( + str_to_decrypt: str = "", + password: str = _PASSWORD + ) -> str: + ''' + Decrypt an encrypted string using Rijndael decryption. + + Args: + str_to_decrypt (str): The encrypted string to be decrypted. + password (str): The password used to derive the encryption key. + + Returns: + str: The decrypted string. + ''' + cipher = _get_cipher_Rijndael(password) + + try: + decrypted_data = cipher.decrypt(base64.b64decode(str_to_decrypt)).decode().strip() + padding_length = ord(decrypted_data[-1]) + decrypted_str = decrypted_data[:-padding_length] + except: + decrypted_str = '' + return decrypted_str \ No newline at end of file diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 48a46ea740..cb9ca7c86e 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -31,7 +31,7 @@ use LWP::UserAgent; use threads; use threads::shared; use MIME::Base64; -use Crypt::CBC; +use Crypt::Rijndael; use Digest::SHA qw(hmac_sha256_base64); use JSON; @@ -2989,62 +2989,62 @@ sub get_server_name { } ############################################################################### -# Encrypt with AES cypher +# Get cipher for Rijndael encrypt and decrypt ############################################################################### -sub encrypt_AES { - my ($str_to_encrypt, $password) = @_; - - if (!defined($password)) { - $password = "default_salt"; - } - my $cipher = _get_cipher($password); - - my $cipher_text = $cipher->encrypt($str_to_encrypt); - my $b64str = encode_base64($cipher_text, ''); - - return $b64str; -} - -############################################################################### -# Decrypt with AES cypher -############################################################################### -sub decrypt_AES { - my ($str_to_decrypt, $password) = @_; - - if (!defined($password)) { - $password = "default_salt"; - } - my $cipher = _get_cipher($password); - - my $cipher_text = decode_base64($str_to_decrypt); - my $decrypted_str = $cipher->decrypt($cipher_text); - - return $decrypted_str; -} - -############################################################################### -# Get cipher for AES encrypt and decrypt -############################################################################### -sub _get_cipher { +sub _get_cipher_Rijndael { my ($password) = @_; my $hash_base64 = substr(Digest::SHA::hmac_sha256_base64($password,''), 0, 16); my $iv = '0000000000000000'; - my $cipher = Crypt::CBC->new( - -key => $hash_base64, - -cipher => 'Cipher::AES', - -iv => $iv, - -header => 'none', - -padding => 'standard', # PKCS7 padding - -keysize => 16, - -literal_key => 1 - ); + my $cipher = Crypt::Rijndael->new($hash_base64, Crypt::Rijndael::MODE_CBC()); + $cipher->set_iv($iv); return $cipher; } +############################################################################### +# Encrypt with Rijndael cypher +############################################################################### +sub encrypt_Rijndael { + my ($str_to_encrypt, $password) = @_; + + if (!defined($password)) { + $password = "default_salt"; + } + my $cipher = _get_cipher_Rijndael($password); + + my $block_size = 16; # Rijndael block size is 16 bytes + my $padding_length = $block_size - (length($str_to_encrypt) % $block_size); + my $padded_data = $str_to_encrypt . chr($padding_length) x $padding_length; + + my $cipher_text = $cipher->encrypt($padded_data); + my $b64str = encode_base64($cipher_text, ''); + + return $b64str; +} + +############################################################################### +# Decrypt with Rijndael cypher +############################################################################### +sub decrypt_Rijndael { + my ($str_to_decrypt, $password) = @_; + + if (!defined($password)) { + $password = "default_salt"; + } + my $cipher = _get_cipher_Rijndael($password); + + my $cipher_text = decode_base64($str_to_decrypt); + my $decrypted_data = $cipher->decrypt($cipher_text); + + my $padding_length = ord(substr($decrypted_data, -1)); + my $decrypted_str = substr($decrypted_data, 0, -$padding_length); + + return $decrypted_str; +} + 1; __END__ From dc648167631d38a19f70c66b3617d33399b7d25f Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Thu, 2 Nov 2023 11:26:20 +0100 Subject: [PATCH 070/264] Exported encrypt and decrypt functions in Tools.pm --- pandora_server/lib/PandoraFMS/Tools.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index cb9ca7c86e..cb9b78e1b4 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -184,8 +184,8 @@ our @EXPORT = qw( check_cron_value check_cron_element cron_check - decrypt_AES - encrypt_AES + decrypt_Rijndael + encrypt_Rijndael ); # ID of the different servers From 9e4ba18f49287c18ee108856052281cfc86374f7 Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Thu, 2 Nov 2023 12:52:31 +0100 Subject: [PATCH 071/264] Changed pandoraPlugintools encryption funcion and removed encryption functions from Tools.pm --- .../extras/pandoraPlugintools/encryption.py | 21 +++--- pandora_server/lib/PandoraFMS/Tools.pm | 64 +------------------ 2 files changed, 11 insertions(+), 74 deletions(-) diff --git a/pandora_server/extras/pandoraPlugintools/encryption.py b/pandora_server/extras/pandoraPlugintools/encryption.py index 576ae31ae3..6e456d2fcd 100644 --- a/pandora_server/extras/pandoraPlugintools/encryption.py +++ b/pandora_server/extras/pandoraPlugintools/encryption.py @@ -136,9 +136,7 @@ def _get_cipher_Rijndael( hash_result = hash_obj.digest() hash_base64 = base64.b64encode(hash_result)[:16].decode() - iv = b'0000000000000000' - - return AES.new(hash_base64.encode(), AES.MODE_CBC, iv) + return AES.new(hash_base64.encode(), AES.MODE_ECB) #### # Return encrypted string @@ -159,13 +157,13 @@ def encrypt_Rijndael( ''' cipher = _get_cipher_Rijndael(password) - block_size = 16 # Rijndael block size is 16 bytes - padding_length = block_size - (len(str_to_encrypt) % block_size) - padded_data = str_to_encrypt + chr(padding_length) * padding_length - try: - b64str = base64.b64encode(cipher.encrypt(padded_data.encode())).decode() - except Exception as e: + padded_data = str_to_encrypt.encode() + missing = 16 - (len(padded_data) % 16) + padded_data += bytes([0] * missing) if missing != 16 else b'' + + b64str = base64.b64encode(cipher.encrypt(padded_data)).decode() + except: b64str = '' return b64str @@ -190,9 +188,8 @@ def decrypt_Rijndael( cipher = _get_cipher_Rijndael(password) try: - decrypted_data = cipher.decrypt(base64.b64decode(str_to_decrypt)).decode().strip() - padding_length = ord(decrypted_data[-1]) - decrypted_str = decrypted_data[:-padding_length] + decrypted_data = cipher.decrypt(base64.b64decode(str_to_decrypt)) + decrypted_str = decrypted_data.rstrip(b'\x00').decode() except: decrypted_str = '' diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index cb9b78e1b4..61b68cd2ce 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -30,9 +30,6 @@ use Scalar::Util qw(looks_like_number); use LWP::UserAgent; use threads; use threads::shared; -use MIME::Base64; -use Crypt::Rijndael; -use Digest::SHA qw(hmac_sha256_base64); use JSON; use Encode qw/decode_utf8 encode_utf8/; @@ -184,8 +181,8 @@ our @EXPORT = qw( check_cron_value check_cron_element cron_check - decrypt_Rijndael - encrypt_Rijndael + decrypt_AES + encrypt_AES ); # ID of the different servers @@ -2988,63 +2985,6 @@ sub get_server_name { return "UNKNOWN"; } -############################################################################### -# Get cipher for Rijndael encrypt and decrypt -############################################################################### -sub _get_cipher_Rijndael { - my ($password) = @_; - - my $hash_base64 = substr(Digest::SHA::hmac_sha256_base64($password,''), 0, 16); - - my $iv = '0000000000000000'; - - my $cipher = Crypt::Rijndael->new($hash_base64, Crypt::Rijndael::MODE_CBC()); - $cipher->set_iv($iv); - - return $cipher; -} - -############################################################################### -# Encrypt with Rijndael cypher -############################################################################### -sub encrypt_Rijndael { - my ($str_to_encrypt, $password) = @_; - - if (!defined($password)) { - $password = "default_salt"; - } - my $cipher = _get_cipher_Rijndael($password); - - my $block_size = 16; # Rijndael block size is 16 bytes - my $padding_length = $block_size - (length($str_to_encrypt) % $block_size); - my $padded_data = $str_to_encrypt . chr($padding_length) x $padding_length; - - my $cipher_text = $cipher->encrypt($padded_data); - my $b64str = encode_base64($cipher_text, ''); - - return $b64str; -} - -############################################################################### -# Decrypt with Rijndael cypher -############################################################################### -sub decrypt_Rijndael { - my ($str_to_decrypt, $password) = @_; - - if (!defined($password)) { - $password = "default_salt"; - } - my $cipher = _get_cipher_Rijndael($password); - - my $cipher_text = decode_base64($str_to_decrypt); - my $decrypted_data = $cipher->decrypt($cipher_text); - - my $padding_length = ord(substr($decrypted_data, -1)); - my $decrypted_str = substr($decrypted_data, 0, -$padding_length); - - return $decrypted_str; -} - 1; __END__ From e6f505da5422b0ff60ed98857df396928bcebe6c Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Thu, 2 Nov 2023 12:53:38 +0100 Subject: [PATCH 072/264] Removed encryption functions from Tools.pm exporting --- pandora_server/lib/PandoraFMS/Tools.pm | 2 -- 1 file changed, 2 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 61b68cd2ce..70d697dab4 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -181,8 +181,6 @@ our @EXPORT = qw( check_cron_value check_cron_element cron_check - decrypt_AES - encrypt_AES ); # ID of the different servers From 513a0bc2965ac9c547dd1c3fc8427b2b666713bb Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Fri, 3 Nov 2023 14:25:44 +0100 Subject: [PATCH 073/264] #8365 Added csv report for device lists. Fixed overlay for modals --- .../reporting_builder.item_editor.php | 6 +- .../godmode/reporting/reporting_builder.php | 12 +++ .../include/functions_reporting.php | 2 +- .../include/functions_reporting_html.php | 93 +++++++++++++------ pandora_console/include/functions_reports.php | 12 +-- .../include/javascript/pandora_ui.js | 9 +- .../include/styles/js/jquery-ui_custom.css | 6 ++ 7 files changed, 96 insertions(+), 44 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index d13071c60a..f50b451683 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -1036,7 +1036,8 @@ switch ($action) { break; case 'ncm': - $idAgent = $item['id_agent']; + $id_agent_ncm = $item['id_agent']; + $ncm_group = $item['id_group']; break; case 'ncm_backups': @@ -7835,7 +7836,8 @@ function chooseType() { break; case 'ncm': - $("#row_agent").show(); + $("#row_ncm_group").show(); + $("#row_ncm_agent").show(); break; case 'ncm_backups': diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 349bad535e..f155a89831 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -2051,6 +2051,12 @@ switch ($action) { $good_format = true; break; + case 'ncm': + $values['id_agent'] = get_parameter('agent_ncm'); + $values['id_group'] = get_parameter('ncm_group'); + $good_format = true; + break; + default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( @@ -2995,6 +3001,12 @@ switch ($action) { $good_format = true; break; + case 'ncm': + $values['id_agent'] = get_parameter('agent_ncm'); + $values['id_group'] = get_parameter('ncm_group'); + $good_format = true; + break; + default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 19c3f80b10..54f1284a2c 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -965,7 +965,7 @@ function reporting_make_reporting_data( break; case 'ncm': - $report['contents'][] = reporting_ncm_config( + $report['contents'][] = reporting_ncm_list( $report, $content, $pdf diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 76f0920e34..a74fcb4a47 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -477,7 +477,7 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust break; case 'ncm': - reporting_html_ncm_config($table, $item); + reporting_html_ncm_list($table, $item); break; case 'ncm_backups': @@ -7347,41 +7347,76 @@ function reporting_html_permissions($table, $item, $pdf=0) /** - * HTML content for ncm configuration diff report. + * HTML content for ncm devices list. * - * @param array $item Content generated by reporting_ncm_config. + * @param array $item Content generated by reporting_ncm_list. * * @return string HTML code. */ -function reporting_html_ncm_config($table, $item, $pdf=0) +function reporting_html_ncm_list($table, $item, $pdf=0) { - $key = uniqid(); + // Create table diff. + $table_ncm = new stdClass(); + $table_ncm->width = '100%'; + $table_ncm->class = 'info_table'; + $table_ncm->styleTable = 'table-layout: fixed;'; + $table_ncm->titleclass = 'title_table_pdf'; + + $table_ncm->align = []; + $table_ncm->align['name'] = 'left'; + $table_ncm->align['ip'] = 'left'; + $table_ncm->align['vendor'] = 'left'; + $table_ncm->align['model'] = 'left'; + $table_ncm->align['firmware'] = 'left'; + $table_ncm->align['last_backup_date'] = 'left'; + + $table_ncm->headstyle['name'] = 'text-align: left'; + $table_ncm->headstyle['ip'] = 'text-align: left'; + $table_ncm->headstyle['vendor'] = 'text-align: left'; + $table_ncm->headstyle['model'] = 'text-align: left'; + $table_ncm->headstyle['firmware'] = 'text-align: left'; + $table_ncm->headstyle['last_backup_date'] = 'text-align: left'; + + $table_ncm->head = []; + $table_ncm->head['name'] = __('Name'); + $table_ncm->head['ip'] = __('Ip'); + $table_ncm->head['vendor'] = __('Vendor'); + $table_ncm->head['model'] = __('Model'); + $table_ncm->head['firmware'] = __('Firmware'); + $table_ncm->head['last_backup_date'] = __('Last backup date'); + + $table_ncm->data = []; + foreach ($item['data'] as $key => $row) { + $title = $row['last_error']; + if (empty($title) === true) { + $title = null; + } + + $table_ncm->data[] = [ + $row['alias'], + $row['direccion'], + $row['vendor'], + $row['model'], + $row['firmware'], + $row['last_backup_date'], + ]; + } + if ($pdf === 0) { - ui_require_javascript_file('diff2html-ui.min'); - ui_require_css_file('diff2html.min'); - $script = "$(document).ready(function() { - const configuration = { - drawFileList: false, - collapsed: true, - matching: 'lines', - outputFormat: 'side-by-side', - }; - const diff2htmlUi = new Diff2HtmlUI( - document.getElementById('".$key."'), - atob('".base64_encode($item['data'])."'), - configuration - ); - diff2htmlUi.draw(); - });"; - $content = '
'; - $content .= ''; - $table->data[1] = $content; - $table->colspan[1][0] = 2; + $table->colspan['data']['cell'] = 3; + $table->cellstyle['data']['cell'] = 'text-align: left;'; + $table->data['data']['cell'] = html_print_table( + $table_ncm, + true + ); } else { - $content = '
'; - $content .= str_replace("\n", '
', $item['data']); - $content .= '
'; - return $content; + $table_ncm->titleclass = 'title_table_pdf'; + $table_ncm->titlestyle = 'text-align:left;'; + + return html_print_table( + $table_ncm, + true + ); } } diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 8956e3adc9..c3f6427ac2 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -963,14 +963,14 @@ function reports_get_report_types($template=false, $not_editor=false) ]; } - $types['ncm'] = [ - 'optgroup' => __('NCM'), - 'name' => __('Network configuration changes'), - ]; - $types['ncm_backups'] = [ 'optgroup' => __('NCM'), - 'name' => __('Network backups'), + 'name' => __('NCM configuration changes'), + ]; + + $types['ncm'] = [ + 'optgroup' => __('NCM'), + 'name' => __('NCM devices list'), ]; if (enterprise_installed() === true) { diff --git a/pandora_console/include/javascript/pandora_ui.js b/pandora_console/include/javascript/pandora_ui.js index 45ca47e92b..80ddfd06f5 100644 --- a/pandora_console/include/javascript/pandora_ui.js +++ b/pandora_console/include/javascript/pandora_ui.js @@ -104,11 +104,8 @@ function load_modal(settings) { width = settings.onshow.width; } - if (settings.modal.overlay == undefined) { - settings.modal.overlay = { - opacity: 0.5, - background: "black" - }; + if (settings.modal.overlay === true) { + $("body").append(""); } if (settings.beforeClose == undefined) { @@ -496,7 +493,6 @@ function load_modal(settings) { settings.onshow.maxHeight != undefined ? settings.onshow.maxHeight : "auto", - overlay: settings.modal.overlay, position: { my: "top+20%", at: "top", @@ -518,6 +514,7 @@ function load_modal(settings) { if (settings.cleanup != undefined) { settings.cleanup(); } + $("#modal_overlay").removeClass("ui-widget-overlay"); }, beforeClose: settings.beforeClose() }); diff --git a/pandora_console/include/styles/js/jquery-ui_custom.css b/pandora_console/include/styles/js/jquery-ui_custom.css index 9c17d7fdab..905c3d5d67 100644 --- a/pandora_console/include/styles/js/jquery-ui_custom.css +++ b/pandora_console/include/styles/js/jquery-ui_custom.css @@ -371,3 +371,9 @@ input[type="submit"].ui-button-dialog { .ui_tpicker_time { margin-left: 10px !important; } + +.ui-widget-overlay { + background: #aaa !important; + opacity: 0.3 !important; + z-index: 1114; +} From 92ee718f918c4730e784a089f02b4417661ad5df Mon Sep 17 00:00:00 2001 From: Calvo Date: Fri, 3 Nov 2023 17:48:15 +0100 Subject: [PATCH 074/264] Optimiized monitors view --- .../operation/agentes/status_monitor.php | 115 +++++++++--------- 1 file changed, 60 insertions(+), 55 deletions(-) diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 046fbc5222..5868b73707 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -27,6 +27,7 @@ */ // Begin. +use PandoraFMS\Enterprise\Metaconsole\Node; global $config; check_login(); @@ -188,7 +189,7 @@ $sql_from = ' FROM tagente_modulo INNER JOIN tagente ON tagente_modulo.id_agente = tagente.id_agente LEFT JOIN tagent_secondary_group tasg - ON tagente.id_agente = tasg.id_agent + ON tagente_modulo.id_agente = tasg.id_agent INNER JOIN tagente_estado ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo INNER JOIN tmodule @@ -436,12 +437,22 @@ if ($moduletype != '') { // Freestring selector. if ($ag_freestring != '') { - $sql_conditions .= ' AND (tagente.nombre '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\' - OR tagente.alias '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\' - OR tagente_modulo.nombre '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\' - OR tagente_modulo.descripcion '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\')'; + $sql_conditions .= ' AND EXISTS ( + SELECT 1 + FROM tagente + WHERE tagente.id_agente = tagente_modulo.id_agente + AND ( + tagente.nombre '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\' OR tagente.alias '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\' + ) + AND ( + tagente_modulo.nombre '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\' + OR tagente_modulo.descripcion '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\') + )'; } + + + // Status selector. if ($status == AGENT_MODULE_STATUS_NORMAL) { // Normal. @@ -1348,15 +1359,10 @@ $sql = 'SELECT tagente.nombre AS agent_name, tagente_modulo.nombre AS module_name, tagente_modulo.history_data, - tagente_modulo.flag AS flag, tagente.id_grupo AS id_group, tagente.id_agente AS id_agent, tagente_modulo.id_tipo_modulo AS module_type, tagente_modulo.module_interval, - tagente_modulo.tcp_send, - tagente_modulo.ip_target, - tagente_modulo.snmp_community, - tagente_modulo.snmp_oid, tagente_estado.datos, tagente_estado.estado, tagente_estado.last_status_change, @@ -1370,13 +1376,12 @@ $sql = 'SELECT tagente_modulo.extended_info, tagente_modulo.critical_inverse, tagente_modulo.warning_inverse, - tagente_modulo.critical_instructions, - tagente_modulo.warning_instructions, - tagente_modulo.unknown_instructions, tagente_estado.utimestamp AS utimestamp'.$sql_from.$sql_conditions_all.' GROUP BY tagente_modulo.id_agente_modulo ORDER BY '.$order['field'].' '.$order['order'].' - LIMIT '.$offset.','.$limit_sql; + LIMIT '.$limit_sql.' OFFSET '.$offset; + + hd($sql); // We do not show the modules until the user searches with the filter. if ($autosearch) { @@ -1402,53 +1407,53 @@ if ($autosearch) { $result = []; $count_modules = 0; foreach ($servers as $server) { - // If connection was good then retrieve all data server. - if (metaconsole_connect($server) === NOERR) { - $connection = true; - } else { - $connection = false; - } + try { + $node = new Node((int) $server['id']); + $node->connect(); - $result_server = db_get_all_rows_sql($sql); + $result_server = db_get_all_rows_sql($sql); - if (empty($result_server) === false) { - // Create HASH login info. - $pwd = $server['auth_token']; - $auth_serialized = json_decode($pwd, true); + if (empty($result_server) === false) { + // Create HASH login info. + $pwd = $server['auth_token']; + $auth_serialized = json_decode($pwd, true); - if (is_array($auth_serialized)) { - $pwd = $auth_serialized['auth_token']; - $api_password = $auth_serialized['api_password']; - $console_user = $auth_serialized['console_user']; - $console_password = $auth_serialized['console_password']; + if (is_array($auth_serialized)) { + $pwd = $auth_serialized['auth_token']; + $api_password = $auth_serialized['api_password']; + $console_user = $auth_serialized['console_user']; + $console_password = $auth_serialized['console_password']; + } + + $user = $config['id_user']; + $user_rot13 = str_rot13($config['id_user']); + $hashdata = $user.$pwd; + $hashdata = md5($hashdata); + + foreach ($result_server as $result_element_key => $result_element_value) { + $result_server[$result_element_key]['server_id'] = $server['id']; + $result_server[$result_element_key]['server_name'] = $server['server_name']; + $result_server[$result_element_key]['server_url'] = $server['server_url'].'/'; + $result_server[$result_element_key]['hashdata'] = $hashdata; + $result_server[$result_element_key]['user'] = $config['id_user']; + $result_server[$result_element_key]['groups_in_server'] = agents_get_all_groups_agent( + $result_element_value['id_agent'], + $result_element_value['id_group'] + ); + + $count_modules++; + } + + $result = array_merge($result, $result_server); } - $user = $config['id_user']; - $user_rot13 = str_rot13($config['id_user']); - $hashdata = $user.$pwd; - $hashdata = md5($hashdata); - $url_hash = '&'.'loginhash=auto&'.'loginhash_data='.$hashdata.'&'.'loginhash_user='.$user_rot13; - - foreach ($result_server as $result_element_key => $result_element_value) { - $result_server[$result_element_key]['server_id'] = $server['id']; - $result_server[$result_element_key]['server_name'] = $server['server_name']; - $result_server[$result_element_key]['server_url'] = $server['server_url'].'/'; - $result_server[$result_element_key]['hashdata'] = $hashdata; - $result_server[$result_element_key]['user'] = $config['id_user']; - $result_server[$result_element_key]['groups_in_server'] = agents_get_all_groups_agent( - $result_element_value['id_agent'], - $result_element_value['id_group'] - ); - - $count_modules++; - } - - $result = array_merge($result, $result_server); + usort($result, arrayOutputSorting($sort, $fieldForSorting)); + } catch (\Exception $e) { + $node->disconnect(); + return; + } finally { + $node->disconnect(); } - - usort($result, arrayOutputSorting($sort, $fieldForSorting)); - - metaconsole_restore_db(); } if ($count_modules > $config['block_size']) { From 3506ba1b5a3e6ffe37beb33f0d72d6b65c0bb5bd Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Mon, 6 Nov 2023 15:06:16 +0100 Subject: [PATCH 075/264] Added default NCM templates --- pandora_console/extras/mr/67.sql | 1007 ++++++++++++++++++++++++++++ pandora_console/pandoradb_data.sql | 146 +++- 2 files changed, 1148 insertions(+), 5 deletions(-) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index b2b34e5ce4..2a604941e0 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -29,5 +29,1012 @@ ADD COLUMN `agent_data_cron_interval` VARCHAR(100) NULL DEFAULT '' AFTER `cron_i ALTER TABLE `tncm_agent` ADD COLUMN `agent_data_event_on_change` INT UNSIGNED NULL DEFAULT NULL AFTER `event_on_change`; +-- Add new vendor and model +SET @vendor_name = 'Cisco'; +SET @model_name = 'Cisco-Generic'; +SET @template_name = 'Cisco-Generic'; +SET @agent_data_template_name = 'Cisco-Generic'; +SET @script_test = 'enable\n expect:Password:\s* _enablepass_\n exit\n'; +SET @script_get_config = 'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show running-config\n exit\n'; +SET @script_set_config = 'enable\n expect:Password:\s* _enablepass_\n term length 0\n config terminal\n _applyconfigbackup_\n exit\n'; +SET @script_get_firmware = 'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show version | i IOS Software\n exit\n'; +SET @script_set_firmware = 'copy tftp flash\n expect:\]\? _TFTP_SERVER_IP_\n expect:\]\? _SOURCE_FILE_NAME_\n expect:\]\? _DESTINATION_FILE_NAME_\n show flash\n reload\n expect:confirm y\n config terminal\n boot system _DESTINATION_FILE_NAME_\n'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Juniper'; +SET @model_name = 'Juniper-Generic'; +SET @template_name = 'Juniper-Generic'; +SET @agent_data_template_name = 'Juniper-Generic'; +SET @script_test = 'expect:root@% cli\n exit\n'; +SET @script_get_config = 'expect:root@% cli\n expect:root> capture:show configuration\n capture:\n quit\n expect:root@% exit\n'; +SET @script_set_config = 'expect:root@% cli\n expect:root> configure\n load override terminal\n _applyconfigbackup_\n commit\n exit\n'; +SET @script_get_firmware = 'expect:root@% cli\n expect:root> capture:show version|match Junos:\n capture: \n quit\n expect:root@% exit\n'; +SET @script_set_firmware = 'expect:root@% cli\n expect:root> save software from tftp _TFTP_SERVER_IP_ _FIRMWARE_NAME_ to flash\n reset\n exit\n'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Palo Alto'; +SET @model_name = 'Palo Alto-Generic'; +SET @template_name = 'Palo Alto-Generic'; +SET @agent_data_template_name = 'Palo Alto-Generic'; +SET @script_test = 'sleep:1 exit\n'; +SET @script_get_config = 'set cli pager off \n capture:show config running\n exit\n'; +SET @script_set_config = 'set cli terminal width 500\n set cli scripting-mode on\n configure\n _applyconfigbackup_\n commit\n'; +SET @script_get_firmware = 'set cli pager off \n capture:show system info | match app-version:\n sleep:1 expect:app-version:\s* exit \n'; +SET @script_set_firmware = 'tftp import software from _TFTP_SERVER_IP_ file _FIRMWARE_NAME_\n request system software install version\n reboot\n exit\n'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'A10'; +SET @model_name = 'A10-Generic'; +SET @template_name = 'A10-Generic'; +SET @agent_data_template_name = 'A10-Generic'; +SET @script_test = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n'; +SET @script_get_config = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'; +SET @script_set_config = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n _applyconfigbackup_\n exit\n'; +SET @script_get_firmware = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'; +SET @script_set_firmware = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n expect:(config) restore _TFTP_SERVER_IP_/_FIRMWARE_NAME_\n expect:Password:\s* _enablepass_\n expect:skip port map yes\n expect: see the diff yes\n sleep:1 expect:Proceed with reboot yes\n expect:eof'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Alcatel-Lucent Enterprise'; +SET @model_name = 'Alcatel-Generic'; +SET @template_name = 'Alcatel-Generic'; +SET @agent_data_template_name = 'Alcatel-Generic'; +SET @script_test = 'enable\n expect:Password:\s* _enablepass_\n exit\n'; +SET @script_get_config = 'enable\n expect:Password:\s* _enablepass_\n capture:admin display-config\n logout\n'; +SET @script_set_config = ''; +SET @script_get_firmware = 'enable\n expect:Password:\s* _enablepass_\n capture:show version\n logout\n'; +SET @script_set_firmware = ''; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Aruba'; +SET @model_name = 'Aruba-Generic'; +SET @template_name = 'Aruba-Generic'; +SET @agent_data_template_name = 'Aruba-Generic'; +SET @script_test = 'enable\n expect:Password:\s* _enablepass_\n exit\n'; +SET @script_get_config = 'enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'; +SET @script_set_config = 'configure terminal\n load replace /var/tmp/file.conf\n end\n write memory\n exit\n'; +SET @script_get_firmware = 'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'; +SET @script_set_firmware = 'copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_.swi secondary\n boot system flash secondary\n copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_ primary\n boot system flash primary\n'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Mikrotik'; +SET @model_name = 'Mikrotik-Generic'; +SET @template_name = 'Mikrotik-Generic'; +SET @agent_data_template_name = 'Mikrotik-Generic'; +SET @script_test = 'sleep:1 exit\n\r'; +SET @script_get_config = 'sleep:1 capture:system resource print\n\r exit\n\r'; +SET @script_set_config = 'sleep:1 system backup load name=_nameBackup_ password=_passwordBackup_\n\r expect:Restore yes\n\r exit\n\r'; +SET @script_get_firmware = 'sleep:1 capture:/system package print\n\r exit\n\r'; +SET @script_set_firmware = 'sleep:1 /system routerboard upgrade\n\r expect:Do yes\n\r exit\n\r'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); COMMIT; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 47365fcc6e..8229c96ee7 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2512,11 +2512,32 @@ INSERT INTO `tncm_vendor` (`id`, `name`) VALUES (11, 'Netlink'), (12, 'Ascom'), (13, 'Synology Inc.'), - (14, 'Fujitsu Network Communications, Inc.'); + (14, 'Fujitsu Network Communications, Inc.'), + (15, 'Juniper'), + (16, 'Palo Alto'), + (17, 'A10'), + (18, 'Aruba'), + (19, 'Mikrotik'); -INSERT INTO `tncm_model` VALUES (1,1,'7200'); +INSERT INTO `tncm_model` VALUES + (1,1,'7200'), + (2,1,'Cisco-Generic'), + (3,15,'Juniper-Generic'), + (4,16,'Palo Alto-Generic'), + (5,17,'A10-Generic'), + (6,4,'Alcatel-Generic'), + (7,18,'Aruba-Generic'), + (8,19,'Mikrotik-Generic'); -INSERT INTO `tncm_template` VALUES (1,'cisco-base','[\"1\"]','[\"1\"]'); +INSERT INTO `tncm_template` VALUES + (1,'cisco-base','[\"1\"]','[\"1\"]'), + (2,'Cisco-Generic','[\"1\"]','[\"2\"]'), + (3,'Juniper-Generic','[\"15\"]','[\"3\"]'), + (4,'Palo Alto-Generic','[\"16\"]','[\"4\"]'), + (5,'A10-Generic','[\"17\"]','[\"5\"]'), + (6,'Alcatel-Generic','[\"4\"]','[\"6\"]'), + (7,'Aruba-Generic','[\"18\"]','[\"7\"]'), + (8,'Mikrotik-Generic','[\"19\"]','[\"8\"]'); INSERT INTO `tncm_script` VALUES (1,0,'enable expect:Password:\s* _enablepass_ exit'), @@ -2524,9 +2545,124 @@ INSERT INTO `tncm_script` VALUES (3,2,'enable expect:Password:\s* _enablepass_ term length 0 config terminal _applyconfigbackup_ exit '), (4,3,'enable expect:Password:\s* _enablepass_ term length 0 capture:show version | i IOS Software exit '), (5,5,'enable expect:Password:\s* _enablepass_ term length 0 config term end end exit '), - (6,4,'copy tftp flash expect:\]\? _TFTP_SERVER_IP_ expect:\]\? _SOURCE_FILE_NAME_ expect:\]\? _DESTINATION_FILE_NAME_ show flash reload expect:confirm y config terminal boot system _DESTINATION_FILE_NAME_'); + (6,4,'copy tftp flash expect:\]\? _TFTP_SERVER_IP_ expect:\]\? _SOURCE_FILE_NAME_ expect:\]\? _DESTINATION_FILE_NAME_ show flash reload expect:confirm y config terminal boot system _DESTINATION_FILE_NAME_'), + (7,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), + (8,1,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show running-config\n exit\n'), + (9,2,'enable\n expect:Password:\s* _enablepass_\n term length 0\n config terminal\n _applyconfigbackup_\n exit\n'), + (10,3,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show version | i IOS Software\n exit\n'), + (11,4,'copy tftp flash\n expect:\]\? _TFTP_SERVER_IP_\n expect:\]\? _SOURCE_FILE_NAME_\n expect:\]\? _DESTINATION_FILE_NAME_\n show flash\n reload\n expect:confirm y\n config terminal\n boot system _DESTINATION_FILE_NAME_\n'), + (12,5,''), + (13,7,''), + (14,0,'expect:root@% cli\n exit\n'), + (15,1,'expect:root@% cli\n expect:root> capture:show configuration\n capture:\n quit\n expect:root@% exit\n'), + (16,2,'expect:root@% cli\n expect:root> configure\n load override terminal\n _applyconfigbackup_\n commit\n exit\n'), + (17,3,'expect:root@% cli\n expect:root> capture:show version|match Junos:\n capture: \n quit\n expect:root@% exit\n'), + (18,4,'expect:root@% cli\n expect:root> save software from tftp _TFTP_SERVER_IP_ _FIRMWARE_NAME_ to flash\n reset\n exit\n'), + (19,5,''), + (20,7,''), + (21,0,'sleep:1 exit\n'), + (22,1,'set cli pager off \n capture:show config running\n exit\n'), + (23,2,'set cli terminal width 500\n set cli scripting-mode on\n configure\n _applyconfigbackup_\n commit\n'), + (24,3,'set cli pager off \n capture:show system info | match app-version:\n sleep:1 expect:app-version:\s* exit \n'), + (25,4,'tftp import software from _TFTP_SERVER_IP_ file _FIRMWARE_NAME_\n request system software install version\n reboot\n exit\n'), + (26,5,''), + (27,7,''), + (28,0,'sleep:1 enable\n expect:Password:\s* _enablepass_\n'), + (29,1,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), + (30,2,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n _applyconfigbackup_\n exit\n'), + (31,3,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), + (32,4,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n expect:(config) restore _TFTP_SERVER_IP_/_FIRMWARE_NAME_\n expect:Password:\s* _enablepass_\n expect:skip port map yes\n expect: see the diff yes\n sleep:1 expect:Proceed with reboot yes\n expect:eof'), + (33,5,''), + (34,7,''), + (35,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), + (36,1,'enable\n expect:Password:\s* _enablepass_\n capture:admin display-config\n logout\n'), + (37,2,''), + (38,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n logout\n'), + (39,4,''), + (40,5,''), + (41,7,''), + (42,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), + (43,1,'enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), + (44,2,'configure terminal\n load replace /var/tmp/file.conf\n end\n write memory\n exit\n'), + (45,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), + (46,4,'copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_.swi secondary\n boot system flash secondary\n copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_ primary\n boot system flash primary\n'), + (47,5,''), + (48,7,''), + (49,0,'sleep:1 exit\n\r'), + (50,1,'sleep:1 capture:system resource print\n\r exit\n\r'), + (51,2,'sleep:1 system backup load name=_nameBackup_ password=_passwordBackup_\n\r expect:Restore yes\n\r exit\n\r'), + (52,3,'sleep:1 capture:/system package print\n\r exit\n\r'), + (53,4,'sleep:1 /system routerboard upgrade\n\r expect:Do yes\n\r exit\n\r'), + (54,5,''), + (55,7,''); -INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6); +INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES + (1,1), + (1,2), + (1,3), + (1,4), + (1,5), + (1,6), + (2,7), + (2,8), + (2,9), + (2,10), + (2,11), + (2,12), + (3,14), + (3,15), + (3,16), + (3,17), + (3,18), + (3,19), + (4,21), + (4,22), + (4,23), + (4,24), + (4,25), + (4,26), + (5,28), + (5,29), + (5,30), + (5,31), + (5,32), + (5,33), + (6,35), + (6,36), + (6,37), + (6,38), + (6,39), + (6,40), + (7,42), + (7,43), + (7,44), + (7,45), + (7,46), + (7,47), + (8,49), + (8,50), + (8,51), + (8,52), + (8,53), + (8,54); + +INSERT INTO `tncm_agent_data_template` VALUES + (1,'Cisco-Generic','[\"1\"]','[\"2\"]'), + (2,'Juniper-Generic','[\"15\"]','[\"3\"]'), + (3,'Palo Alto-Generic','[\"16\"]','[\"4\"]'), + (4,'A10-Generic','[\"17\"]','[\"5\"]'), + (5,'Alcatel-Generic','[\"4\"]','[\"6\"]'), + (6,'Aruba-Generic','[\"18\"]','[\"7\"]'), + (7,'Mikrotik-Generic','[\"19\"]','[\"8\"]'); + +INSERT INTO `tncm_agent_data_template_scripts`(`id_agent_data_template`, `id_script`) VALUES + (1,13), + (2,20), + (3,27), + (4,34), + (5,41), + (6,48), + (7,55), INSERT INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar'); From c266640f39c64c1b747ff6cb8f934b4c8972dadc Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Mon, 6 Nov 2023 15:07:43 +0100 Subject: [PATCH 076/264] Fixed syntax error in SQL --- pandora_console/pandoradb_data.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 8229c96ee7..7f3664620a 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2662,7 +2662,7 @@ INSERT INTO `tncm_agent_data_template_scripts`(`id_agent_data_template`, `id_scr (4,34), (5,41), (6,48), - (7,55), + (7,55); INSERT INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar'); From 26ed76b82109a765bfda684fb0bd98932178bf0f Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Mon, 6 Nov 2023 16:41:37 +0100 Subject: [PATCH 077/264] Fixed SQL issue --- pandora_console/pandoradb_data.sql | 302 ++++++++++++++--------------- 1 file changed, 151 insertions(+), 151 deletions(-) diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 7f3664620a..7e4bee1954 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -369,11 +369,11 @@ INSERT INTO `tusuario_perfil` (`id_up`, `id_usuario`, `id_perfil`, `id_grupo`, ` -- INSERT INTO `tperfil` VALUES - (1,'Operator (Read)',1,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0), - (2,'Operator (Write)',1,0,0,0,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,0,0), - (3,'Chief Operator',1,0,0,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,1,0,0,0), - (4,'Group coordinator',1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0), - (5,'Pandora Administrator',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); + (1,'Operator (Read)',1,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0), + (2,'Operator (Write)',1,0,0,0,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,0,0), + (3,'Chief Operator',1,0,0,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,1,0,0,0), + (4,'Group coordinator',1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0), + (5,'Pandora Administrator',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); -- -- Dumping data for table `tnews` @@ -388,7 +388,7 @@ INSERT INTO tmodule VALUES (5,'Prediction module'); INSERT INTO tmodule VALUES (6,'WMI module'); INSERT INTO tmodule VALUES (7, 'Web module'); INSERT INTO tmodule VALUES (8, 'Wux module'); -INSERT INTO tmodule VALUES (9, 'Wizard module'); +INSERT INTO tmodule VALUES (9, 'Wizard module'); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (1,'OS Total process','Total process in Operating System (UNIX MIB)',13,15,0,0,300,0,'','','public','HOST-RESOURCES-MIB::hrSystemProcesses.0 ',4,2,0,NULL,NULL,NULL,0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); @@ -732,11 +732,11 @@ INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `t INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (513,'MSDTC TransactionsPersec','Transactions performed per second.',22,1,0,0,300,0,'','','','select TransactionsPersec from Win32_PerfRawData_MSDTC_DistributedTransactionCoordinator',3,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (514,'c2900InfoPeakBuffersUsed','ftp://ftp.cisco.com/pub/mibs/oid/CISCO-C2900-MIB.oid',23,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.87.1.1.2.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (515,'c2900InfoTotalBufferDepth','ftp://ftp.cisco.com/pub/mibs/oid/CISCO-C2900-MIB.oid',23,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.87.1.1.3.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (516,'c2900BandwidthUsageCurrent ','ftp://ftp.cisco.com/pub/mibs/oid/CISCO-C2900-MIB.oid',23,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.87.1.5.1.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (516,'c2900BandwidthUsageCurrent ','ftp://ftp.cisco.com/pub/mibs/oid/CISCO-C2900-MIB.oid',23,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.87.1.5.1.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (517,'Latest Message ','Get the last message sent in Syslog',2,17,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.41.1.2.3.1.5.12',1,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (518,'Latest Message date','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.41.1.2.3.1.6.12',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (519,'CPU avgBusy1min ','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.2.1.57.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (520,'CPU avgBusy5min ','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.2.1.58.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (519,'CPU avgBusy1min ','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.2.1.57.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (520,'CPU avgBusy5min ','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.2.1.58.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (521,'Software Image running ','',2,17,0,0,1800,0,'','','public','1.3.6.1.4.1.9.2.1.73.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (522,'nvRAMUsed','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.3.6.8.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (523,'Printers BytesPrintedPersec','Number of bytes per second printed on a print queue.',24,1,0,0,300,0,'','','','select BytesPrintedPersec from Win32_PerfRawData_Spooler_PrintQueue where NAME = '_total'',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); @@ -748,7 +748,7 @@ INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `t INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (529,'Printers OutofPaperErrors','Total number of out-of-paper errors in a print queue after the last restart.',24,1,0,0,300,0,'','','','select OutofPaperErrors from Win32_PerfRawData_Spooler_PrintQueue where NAME = '_total'',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (530,'Printers TotalJobsPrinted','Total number of jobs printed on a print queue after the last restart.',24,1,0,0,300,0,'','','','select TotalJobsPrinted from Win32_PerfRawData_Spooler_PrintQueue where NAME = '_total'',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (531,'Printers TotalPagesPrinted','Total number of pages printed through GDI on a print queue after the last restart.',24,1,0,0,300,0,'','','','select TotalPagesPrinted from Win32_PerfRawData_Spooler_PrintQueue where NAME = '_total'',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (532,'Printers Availability','Availability and status of the device\r\n\r\nValue Meaning\r\n\r\n10x1 Other\r\n\r\n20x2 Unknown\r\n\r\n30x3 Running or Full Power\r\n\r\n40x4 Warning\r\n\r\n50x5 In Test\r\n\r\n60x6 Not Applicable\r',24,3,0,0,300,0,'','','','select Availability from Win32_Printer',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (532,'Printers Availability','Availability and status of the device\r\n\r\nValue Meaning\r\n\r\n10x1 Other\r\n\r\n20x2 Unknown\r\n\r\n30x3 Running or Full Power\r\n\r\n40x4 Warning\r\n\r\n50x5 In Test\r\n\r\n60x6 Not Applicable\r',24,3,0,0,300,0,'','','','select Availability from Win32_Printer',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (533,'Serv_IISAdmin','IIS Administration Server service status.',26,2,0,0,300,0,'','','Running','Select State from Win32_Service WHERE name = 'IISAdmin'',3,6,0,'Administrador','6683','',0,1,0.00,0.00,'',0.00,0.00,'',0,'','','',0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (534,'Serv_MSSQL_server','Displays if MS SQL SERVER is running',27,2,0,0,0,0,'','','Running','select state from Win32_Service where name = "MSSQLSERVER"',7,6,0,'','','',0,1,0.00,0.00,'',0.00,0.00,'',0,'','','',0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (535,'SQLServer_DataFilesSizeKB','Sql database size in kb ',27,1,0,0,0,0,'','','','select state from Win32_Service where name = "MSSQLSERVER"',7,6,0,'','','',0,1,0.00,0.00,'',0.00,0.00,'',0,'','','',0,0,0.0000000000000,'basic','','','','','',''); @@ -1290,8 +1290,8 @@ INSERT INTO `tcontainer` SET `name` = 'Default graph container'; -- Dumping data for table `tlog_graph_models` -- INSERT INTO tlog_graph_models VALUES (1, 'Apache log model', - '^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+', - 'pagina, html_err_code, _tiempo_', 1); + '^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+', + 'pagina, html_err_code, _tiempo_', 1); INSERT INTO tlog_graph_models VALUES (2, 'Apache accesses per client and status', '(.*?)\ -.*1.1"\ (\d+)\ \d+', @@ -1347,13 +1347,13 @@ UPDATE `tnotification_source` SET `enabled`=1 WHERE `description` = 'System INSERT INTO `tpen` VALUES - (9,'cisco','Cisco System'), - (11,'hp','Hewlett Packard'), - (2021,'general_snmp','U.C. Davis, ECE Dept. Tom'), - (2636,'juniper','Juniper Networks'), - (3375,'f5','F5 Labs'), - (8072,'general_snmp','Net SNMP'), - (12356,'fortinet','Fortinet') + (9,'cisco','Cisco System'), + (11,'hp','Hewlett Packard'), + (2021,'general_snmp','U.C. Davis, ECE Dept. Tom'), + (2636,'juniper','Juniper Networks'), + (3375,'f5','F5 Labs'), + (8072,'general_snmp','Net SNMP'), + (12356,'fortinet','Fortinet') ; -- @@ -2500,7 +2500,7 @@ INSERT IGNORE INTO `tpen` VALUES (171,'dlink','D-Link Systems, Inc.'),(14988,'mi INSERT INTO `tncm_vendor` (`id`, `name`) VALUES (1,'Cisco'), - (2, 'D-Link Systems, Inc.'), + (2, 'D-Link Systems, Inc.'), (3, 'MikroTik'), (4, 'Alcatel-Lucent Enterprise'), (5, 'Ubiquiti Networks, Inc.'), @@ -2520,149 +2520,149 @@ INSERT INTO `tncm_vendor` (`id`, `name`) VALUES (19, 'Mikrotik'); INSERT INTO `tncm_model` VALUES - (1,1,'7200'), - (2,1,'Cisco-Generic'), - (3,15,'Juniper-Generic'), - (4,16,'Palo Alto-Generic'), - (5,17,'A10-Generic'), - (6,4,'Alcatel-Generic'), - (7,18,'Aruba-Generic'), - (8,19,'Mikrotik-Generic'); + (1,1,'7200'), + (2,1,'Cisco-Generic'), + (3,15,'Juniper-Generic'), + (4,16,'Palo Alto-Generic'), + (5,17,'A10-Generic'), + (6,4,'Alcatel-Generic'), + (7,18,'Aruba-Generic'), + (8,19,'Mikrotik-Generic'); INSERT INTO `tncm_template` VALUES - (1,'cisco-base','[\"1\"]','[\"1\"]'), - (2,'Cisco-Generic','[\"1\"]','[\"2\"]'), - (3,'Juniper-Generic','[\"15\"]','[\"3\"]'), - (4,'Palo Alto-Generic','[\"16\"]','[\"4\"]'), - (5,'A10-Generic','[\"17\"]','[\"5\"]'), - (6,'Alcatel-Generic','[\"4\"]','[\"6\"]'), - (7,'Aruba-Generic','[\"18\"]','[\"7\"]'), - (8,'Mikrotik-Generic','[\"19\"]','[\"8\"]'); + (1,'cisco-base','[\"1\"]','[\"1\"]'), + (2,'Cisco-Generic','[\"1\"]','[\"2\"]'), + (3,'Juniper-Generic','[\"15\"]','[\"3\"]'), + (4,'Palo Alto-Generic','[\"16\"]','[\"4\"]'), + (5,'A10-Generic','[\"17\"]','[\"5\"]'), + (6,'Alcatel-Generic','[\"4\"]','[\"6\"]'), + (7,'Aruba-Generic','[\"18\"]','[\"7\"]'), + (8,'Mikrotik-Generic','[\"19\"]','[\"8\"]'); INSERT INTO `tncm_script` VALUES (1,0,'enable expect:Password:\s* _enablepass_ exit'), (2,1,'enable expect:Password:\s* _enablepass_ term length 0 capture:show running-config exit '), - (3,2,'enable expect:Password:\s* _enablepass_ term length 0 config terminal _applyconfigbackup_ exit '), - (4,3,'enable expect:Password:\s* _enablepass_ term length 0 capture:show version | i IOS Software exit '), - (5,5,'enable expect:Password:\s* _enablepass_ term length 0 config term end end exit '), - (6,4,'copy tftp flash expect:\]\? _TFTP_SERVER_IP_ expect:\]\? _SOURCE_FILE_NAME_ expect:\]\? _DESTINATION_FILE_NAME_ show flash reload expect:confirm y config terminal boot system _DESTINATION_FILE_NAME_'), - (7,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), - (8,1,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show running-config\n exit\n'), - (9,2,'enable\n expect:Password:\s* _enablepass_\n term length 0\n config terminal\n _applyconfigbackup_\n exit\n'), - (10,3,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show version | i IOS Software\n exit\n'), - (11,4,'copy tftp flash\n expect:\]\? _TFTP_SERVER_IP_\n expect:\]\? _SOURCE_FILE_NAME_\n expect:\]\? _DESTINATION_FILE_NAME_\n show flash\n reload\n expect:confirm y\n config terminal\n boot system _DESTINATION_FILE_NAME_\n'), - (12,5,''), - (13,7,''), - (14,0,'expect:root@% cli\n exit\n'), - (15,1,'expect:root@% cli\n expect:root> capture:show configuration\n capture:\n quit\n expect:root@% exit\n'), - (16,2,'expect:root@% cli\n expect:root> configure\n load override terminal\n _applyconfigbackup_\n commit\n exit\n'), - (17,3,'expect:root@% cli\n expect:root> capture:show version|match Junos:\n capture: \n quit\n expect:root@% exit\n'), - (18,4,'expect:root@% cli\n expect:root> save software from tftp _TFTP_SERVER_IP_ _FIRMWARE_NAME_ to flash\n reset\n exit\n'), - (19,5,''), - (20,7,''), - (21,0,'sleep:1 exit\n'), - (22,1,'set cli pager off \n capture:show config running\n exit\n'), - (23,2,'set cli terminal width 500\n set cli scripting-mode on\n configure\n _applyconfigbackup_\n commit\n'), - (24,3,'set cli pager off \n capture:show system info | match app-version:\n sleep:1 expect:app-version:\s* exit \n'), - (25,4,'tftp import software from _TFTP_SERVER_IP_ file _FIRMWARE_NAME_\n request system software install version\n reboot\n exit\n'), - (26,5,''), - (27,7,''), - (28,0,'sleep:1 enable\n expect:Password:\s* _enablepass_\n'), - (29,1,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), - (30,2,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n _applyconfigbackup_\n exit\n'), - (31,3,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), - (32,4,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n expect:(config) restore _TFTP_SERVER_IP_/_FIRMWARE_NAME_\n expect:Password:\s* _enablepass_\n expect:skip port map yes\n expect: see the diff yes\n sleep:1 expect:Proceed with reboot yes\n expect:eof'), - (33,5,''), - (34,7,''), - (35,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), - (36,1,'enable\n expect:Password:\s* _enablepass_\n capture:admin display-config\n logout\n'), - (37,2,''), - (38,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n logout\n'), - (39,4,''), - (40,5,''), - (41,7,''), - (42,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), - (43,1,'enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), - (44,2,'configure terminal\n load replace /var/tmp/file.conf\n end\n write memory\n exit\n'), - (45,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), - (46,4,'copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_.swi secondary\n boot system flash secondary\n copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_ primary\n boot system flash primary\n'), - (47,5,''), - (48,7,''), - (49,0,'sleep:1 exit\n\r'), - (50,1,'sleep:1 capture:system resource print\n\r exit\n\r'), - (51,2,'sleep:1 system backup load name=_nameBackup_ password=_passwordBackup_\n\r expect:Restore yes\n\r exit\n\r'), - (52,3,'sleep:1 capture:/system package print\n\r exit\n\r'), - (53,4,'sleep:1 /system routerboard upgrade\n\r expect:Do yes\n\r exit\n\r'), - (54,5,''), - (55,7,''); + (3,2,'enable expect:Password:\s* _enablepass_ term length 0 config terminal _applyconfigbackup_ exit '), + (4,3,'enable expect:Password:\s* _enablepass_ term length 0 capture:show version | i IOS Software exit '), + (5,5,'enable expect:Password:\s* _enablepass_ term length 0 config term end end exit '), + (6,4,'copy tftp flash expect:\]\? _TFTP_SERVER_IP_ expect:\]\? _SOURCE_FILE_NAME_ expect:\]\? _DESTINATION_FILE_NAME_ show flash reload expect:confirm y config terminal boot system _DESTINATION_FILE_NAME_'), + (7,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), + (8,1,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show running-config\n exit\n'), + (9,2,'enable\n expect:Password:\s* _enablepass_\n term length 0\n config terminal\n _applyconfigbackup_\n exit\n'), + (10,3,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show version | i IOS Software\n exit\n'), + (11,4,'copy tftp flash\n expect:\]\? _TFTP_SERVER_IP_\n expect:\]\? _SOURCE_FILE_NAME_\n expect:\]\? _DESTINATION_FILE_NAME_\n show flash\n reload\n expect:confirm y\n config terminal\n boot system _DESTINATION_FILE_NAME_\n'), + (12,5,''), + (13,7,''), + (14,0,'expect:root@% cli\n exit\n'), + (15,1,'expect:root@% cli\n expect:root> capture:show configuration\n capture:\n quit\n expect:root@% exit\n'), + (16,2,'expect:root@% cli\n expect:root> configure\n load override terminal\n _applyconfigbackup_\n commit\n exit\n'), + (17,3,'expect:root@% cli\n expect:root> capture:show version|match Junos:\n capture: \n quit\n expect:root@% exit\n'), + (18,4,'expect:root@% cli\n expect:root> save software from tftp _TFTP_SERVER_IP_ _FIRMWARE_NAME_ to flash\n reset\n exit\n'), + (19,5,''), + (20,7,''), + (21,0,'sleep:1 exit\n'), + (22,1,'set cli pager off \n capture:show config running\n exit\n'), + (23,2,'set cli terminal width 500\n set cli scripting-mode on\n configure\n _applyconfigbackup_\n commit\n'), + (24,3,'set cli pager off \n capture:show system info | match app-version:\n sleep:1 expect:app-version:\s* exit \n'), + (25,4,'tftp import software from _TFTP_SERVER_IP_ file _FIRMWARE_NAME_\n request system software install version\n reboot\n exit\n'), + (26,5,''), + (27,7,''), + (28,0,'sleep:1 enable\n expect:Password:\s* _enablepass_\n'), + (29,1,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), + (30,2,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n _applyconfigbackup_\n exit\n'), + (31,3,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), + (32,4,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n expect:(config) restore _TFTP_SERVER_IP_/_FIRMWARE_NAME_\n expect:Password:\s* _enablepass_\n expect:skip port map yes\n expect: see the diff yes\n sleep:1 expect:Proceed with reboot yes\n expect:eof'), + (33,5,''), + (34,7,''), + (35,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), + (36,1,'enable\n expect:Password:\s* _enablepass_\n capture:admin display-config\n logout\n'), + (37,2,''), + (38,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n logout\n'), + (39,4,''), + (40,5,''), + (41,7,''), + (42,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), + (43,1,'enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), + (44,2,'configure terminal\n load replace /var/tmp/file.conf\n end\n write memory\n exit\n'), + (45,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), + (46,4,'copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_.swi secondary\n boot system flash secondary\n copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_ primary\n boot system flash primary\n'), + (47,5,''), + (48,7,''), + (49,0,'sleep:1 exit\n\r'), + (50,1,'sleep:1 capture:system resource print\n\r exit\n\r'), + (51,2,'sleep:1 system backup load name=_nameBackup_ password=_passwordBackup_\n\r expect:Restore yes\n\r exit\n\r'), + (52,3,'sleep:1 capture:/system package print\n\r exit\n\r'), + (53,4,'sleep:1 /system routerboard upgrade\n\r expect:Do yes\n\r exit\n\r'), + (54,5,''), + (55,7,''); INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES - (1,1), - (1,2), - (1,3), - (1,4), - (1,5), - (1,6), - (2,7), - (2,8), - (2,9), - (2,10), - (2,11), - (2,12), - (3,14), - (3,15), - (3,16), - (3,17), - (3,18), - (3,19), - (4,21), - (4,22), - (4,23), - (4,24), - (4,25), - (4,26), - (5,28), - (5,29), - (5,30), - (5,31), - (5,32), - (5,33), - (6,35), - (6,36), - (6,37), - (6,38), - (6,39), - (6,40), - (7,42), - (7,43), - (7,44), - (7,45), - (7,46), - (7,47), - (8,49), - (8,50), - (8,51), - (8,52), - (8,53), - (8,54); + (1,1), + (1,2), + (1,3), + (1,4), + (1,5), + (1,6), + (2,7), + (2,8), + (2,9), + (2,10), + (2,11), + (2,12), + (3,14), + (3,15), + (3,16), + (3,17), + (3,18), + (3,19), + (4,21), + (4,22), + (4,23), + (4,24), + (4,25), + (4,26), + (5,28), + (5,29), + (5,30), + (5,31), + (5,32), + (5,33), + (6,35), + (6,36), + (6,37), + (6,38), + (6,39), + (6,40), + (7,42), + (7,43), + (7,44), + (7,45), + (7,46), + (7,47), + (8,49), + (8,50), + (8,51), + (8,52), + (8,53), + (8,54); INSERT INTO `tncm_agent_data_template` VALUES - (1,'Cisco-Generic','[\"1\"]','[\"2\"]'), - (2,'Juniper-Generic','[\"15\"]','[\"3\"]'), - (3,'Palo Alto-Generic','[\"16\"]','[\"4\"]'), - (4,'A10-Generic','[\"17\"]','[\"5\"]'), - (5,'Alcatel-Generic','[\"4\"]','[\"6\"]'), - (6,'Aruba-Generic','[\"18\"]','[\"7\"]'), - (7,'Mikrotik-Generic','[\"19\"]','[\"8\"]'); + (1,'Cisco-Generic','[\"1\"]','[\"2\"]'), + (2,'Juniper-Generic','[\"15\"]','[\"3\"]'), + (3,'Palo Alto-Generic','[\"16\"]','[\"4\"]'), + (4,'A10-Generic','[\"17\"]','[\"5\"]'), + (5,'Alcatel-Generic','[\"4\"]','[\"6\"]'), + (6,'Aruba-Generic','[\"18\"]','[\"7\"]'), + (7,'Mikrotik-Generic','[\"19\"]','[\"8\"]'); INSERT INTO `tncm_agent_data_template_scripts`(`id_agent_data_template`, `id_script`) VALUES - (1,13), - (2,20), - (3,27), - (4,34), - (5,41), - (6,48), - (7,55); + (1,13), + (2,20), + (3,27), + (4,34), + (5,41), + (6,48), + (7,55); INSERT INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar'); From 86804398fe8b619aab7a488b6728be41993082f2 Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Mon, 6 Nov 2023 16:50:54 +0100 Subject: [PATCH 078/264] Fixed SQL issue --- pandora_console/pandoradb_data.sql | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 7e4bee1954..e7327e578b 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2516,8 +2516,7 @@ INSERT INTO `tncm_vendor` (`id`, `name`) VALUES (15, 'Juniper'), (16, 'Palo Alto'), (17, 'A10'), - (18, 'Aruba'), - (19, 'Mikrotik'); + (18, 'Aruba'); INSERT INTO `tncm_model` VALUES (1,1,'7200'), @@ -2527,7 +2526,7 @@ INSERT INTO `tncm_model` VALUES (5,17,'A10-Generic'), (6,4,'Alcatel-Generic'), (7,18,'Aruba-Generic'), - (8,19,'Mikrotik-Generic'); + (8,3,'Mikrotik-Generic'); INSERT INTO `tncm_template` VALUES (1,'cisco-base','[\"1\"]','[\"1\"]'), @@ -2537,7 +2536,7 @@ INSERT INTO `tncm_template` VALUES (5,'A10-Generic','[\"17\"]','[\"5\"]'), (6,'Alcatel-Generic','[\"4\"]','[\"6\"]'), (7,'Aruba-Generic','[\"18\"]','[\"7\"]'), - (8,'Mikrotik-Generic','[\"19\"]','[\"8\"]'); + (8,'Mikrotik-Generic','[\"3\"]','[\"8\"]'); INSERT INTO `tncm_script` VALUES (1,0,'enable expect:Password:\s* _enablepass_ exit'), @@ -2653,7 +2652,7 @@ INSERT INTO `tncm_agent_data_template` VALUES (4,'A10-Generic','[\"17\"]','[\"5\"]'), (5,'Alcatel-Generic','[\"4\"]','[\"6\"]'), (6,'Aruba-Generic','[\"18\"]','[\"7\"]'), - (7,'Mikrotik-Generic','[\"19\"]','[\"8\"]'); + (7,'Mikrotik-Generic','[\"3\"]','[\"8\"]'); INSERT INTO `tncm_agent_data_template_scripts`(`id_agent_data_template`, `id_script`) VALUES (1,13), From aaa590b65fd8ac0ee75e4b2e0ca52c9f7ecca8e6 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 7 Nov 2023 09:20:48 +0100 Subject: [PATCH 079/264] VC Public links pandora_enterprise#12329 --- pandora_console/ajax.php | 4 +- .../javascript/pandora_visual_console.js | 4 +- .../rest-api/models/VisualConsole/Item.php | 8 ++-- .../operation/visual_console/public_view.php | 48 +++++++++---------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/pandora_console/ajax.php b/pandora_console/ajax.php index b3b9463ee6..a5dcf2cb0d 100644 --- a/pandora_console/ajax.php +++ b/pandora_console/ajax.php @@ -183,7 +183,9 @@ if (isset($config['force_instant_logout']) === true $_SESSION = []; session_destroy(); header_remove('Set-Cookie'); - setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/'); + if (isset($_COOKIE[session_name()]) === true) { + setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/'); + } if ($config['auth'] === 'saml' && empty($public_hash) === true) { include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php'; diff --git a/pandora_console/include/javascript/pandora_visual_console.js b/pandora_console/include/javascript/pandora_visual_console.js index adcbd3ce0c..0e16bb303f 100755 --- a/pandora_console/include/javascript/pandora_visual_console.js +++ b/pandora_console/include/javascript/pandora_visual_console.js @@ -808,8 +808,8 @@ function loadVisualConsoleData( getVisualConsoleItems: 1, size: size, visualConsoleId: vcId, - id_user: typeof id_user == undefined ? id_user : null, - auth_hash: typeof hash == undefined ? hash : null, + id_user: typeof id_user !== undefined ? id_user : null, + auth_hash: typeof hash !== undefined ? hash : null, mode: mode, widthScreen: widthScreen }, diff --git a/pandora_console/include/rest-api/models/VisualConsole/Item.php b/pandora_console/include/rest-api/models/VisualConsole/Item.php index 0db9d999c2..411d605c0e 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Item.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Item.php @@ -1196,7 +1196,7 @@ class Item extends CachedModel 'operation/visual_console/view', ['id' => $vcId], // No autologin from the public view. - !$config['public_view'], + !$config['public_access'], $mobile_navigation, [ 'page' => 'visualmap', @@ -1302,7 +1302,7 @@ class Item extends CachedModel 'enterprise/operation/services/services', ['id_service' => $serviceId], // No autologin from the public view. - !$config['public_view'] + !$config['public_access'] ); } else { // A regular module. @@ -1312,7 +1312,7 @@ class Item extends CachedModel 'operation/agentes/status_monitor', ['id_module' => $moduleId], // No autologin from the public view. - !((isset($config['public_view']) === true) ? $config['public_view'] : false), + !((isset($config['public_access']) === true) ? $config['public_access'] : false), $mobile_navigation, [ 'id' => $moduleId, @@ -1377,7 +1377,7 @@ class Item extends CachedModel 'operation/agentes/ver_agente', ['id_agente' => $agentId], // No autologin from the public view. - !$config['public_view'], + !$config['public_access'], $mobile_navigation, [ 'id' => $agentId, diff --git a/pandora_console/operation/visual_console/public_view.php b/pandora_console/operation/visual_console/public_view.php index 46dd4e43b4..64529133b4 100644 --- a/pandora_console/operation/visual_console/public_view.php +++ b/pandora_console/operation/visual_console/public_view.php @@ -33,7 +33,7 @@ require_once $config['homedir'].'/vendor/autoload.php'; ui_require_css_file('register', 'include/styles/', true); // Connection lost alert. -ui_require_javascript_file('connection_check', 'include/javascript/', true); +// ui_require_javascript_file('connection_check', 'include/javascript/', true); set_js_value('absolute_homeurl', ui_get_full_url(false, false, false, false)); $conn_title = __('Connection with console has been lost'); $conn_text = __('Connection to the console has been lost. Please check your internet connection.'); @@ -47,7 +47,7 @@ global $vc_public_view; global $config; $vc_public_view = true; -$config['public_view'] = true; +$config['public_access'] = true; // This starts the page head. In the call back function, // things from $page['head'] array will be processed into the head. @@ -62,12 +62,6 @@ require_once 'include/functions_visual_map.php'; $hash = (string) get_parameter('hash'); -// For public link issue. -$force_instant_logout = true; -if (isset($config['id_user']) === true) { - $force_instant_logout = false; -} - // Check input hash. // DO NOT move it after of get parameter user id. if (User::validatePublicHash($hash) !== true) { @@ -256,17 +250,17 @@ $visualConsoleItems = VisualConsole::getItemsFromDB( if (menuLinks !== null) { menuLinks.forEach(function (menuLink) { menuLink.href = menuLink.href.replace(regex, replacement); - menuLink.href = menuLink.href.replace( - regex_hash, - replacement_hash - ); + //menuLink.href = menuLink.href.replace( + // regex_hash, + // replacement_hash + //); }); } // Change the URL (if the browser has support). if ("history" in window) { var href = window.location.href.replace(regex, replacement); - href = href.replace(regex_hash, replacement_hash); + //href = href.replace(regex_hash, replacement_hash); window.history.replaceState({}, document.title, href); } } @@ -321,20 +315,24 @@ $visualConsoleItems = VisualConsole::getItemsFromDB( } } }); - - - // No click enabled when user not logged. - $( "a" ).on( "click", function( event ) { - event.preventDefault(); - $('#visual-console-container').removeClass('is-updating'); - $('.div-visual-console-spinner').remove(); - }); - 0) { + ob_end_flush(); } \ No newline at end of file From 194a3ca8c4668d73dceb3f2d472b8d6a56c3fb8e Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 7 Nov 2023 12:36:05 +0100 Subject: [PATCH 080/264] #12381 fix dropdown select2 modal position --- .../godmode/agentes/module_manager_editor_common.php | 2 +- pandora_console/include/styles/pandora.css | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index ca74b7d171..de08a299de 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -1387,7 +1387,7 @@ $table_advanced->data['made_enabled'][0] = html_print_checkbox_switch( 'made_enabled', 1, (bool) $made_enabled, - false, + true, false, '', false, diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 63179618b1..dd6723dfb2 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12798,3 +12798,7 @@ tr.shown td.details-control { position: relative; top: -92px; } + +.tags_selected_container > span.select2 { + background-color: white !important; +} From 8700d1146117c2b303bd9ea3eb238ff6355bea6c Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Tue, 7 Nov 2023 13:13:45 +0100 Subject: [PATCH 081/264] Fixed agent data scripts on pandoradb_data.sql --- pandora_console/pandoradb_data.sql | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index e7327e578b..123940c22e 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2551,49 +2551,49 @@ INSERT INTO `tncm_script` VALUES (10,3,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show version | i IOS Software\n exit\n'), (11,4,'copy tftp flash\n expect:\]\? _TFTP_SERVER_IP_\n expect:\]\? _SOURCE_FILE_NAME_\n expect:\]\? _DESTINATION_FILE_NAME_\n show flash\n reload\n expect:confirm y\n config terminal\n boot system _DESTINATION_FILE_NAME_\n'), (12,5,''), - (13,7,''), + (13,7,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show version | i IOS Software\n exit\n'), (14,0,'expect:root@% cli\n exit\n'), (15,1,'expect:root@% cli\n expect:root> capture:show configuration\n capture:\n quit\n expect:root@% exit\n'), (16,2,'expect:root@% cli\n expect:root> configure\n load override terminal\n _applyconfigbackup_\n commit\n exit\n'), (17,3,'expect:root@% cli\n expect:root> capture:show version|match Junos:\n capture: \n quit\n expect:root@% exit\n'), (18,4,'expect:root@% cli\n expect:root> save software from tftp _TFTP_SERVER_IP_ _FIRMWARE_NAME_ to flash\n reset\n exit\n'), (19,5,''), - (20,7,''), + (20,7,'expect:root@% cli\n expect:root> capture:show version|match Junos:\n capture: \n quit\n expect:root@% exit\n'), (21,0,'sleep:1 exit\n'), (22,1,'set cli pager off \n capture:show config running\n exit\n'), (23,2,'set cli terminal width 500\n set cli scripting-mode on\n configure\n _applyconfigbackup_\n commit\n'), (24,3,'set cli pager off \n capture:show system info | match app-version:\n sleep:1 expect:app-version:\s* exit \n'), (25,4,'tftp import software from _TFTP_SERVER_IP_ file _FIRMWARE_NAME_\n request system software install version\n reboot\n exit\n'), (26,5,''), - (27,7,''), + (27,7,'set cli pager off \n capture:show system info | match app-version:\n sleep:1 expect:app-version:\s* exit \n'), (28,0,'sleep:1 enable\n expect:Password:\s* _enablepass_\n'), (29,1,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), (30,2,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n _applyconfigbackup_\n exit\n'), (31,3,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), (32,4,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n expect:(config) restore _TFTP_SERVER_IP_/_FIRMWARE_NAME_\n expect:Password:\s* _enablepass_\n expect:skip port map yes\n expect: see the diff yes\n sleep:1 expect:Proceed with reboot yes\n expect:eof'), (33,5,''), - (34,7,''), + (34,7,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), (35,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), (36,1,'enable\n expect:Password:\s* _enablepass_\n capture:admin display-config\n logout\n'), (37,2,''), (38,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n logout\n'), (39,4,''), (40,5,''), - (41,7,''), + (41,7,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n logout\n'), (42,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), (43,1,'enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), (44,2,'configure terminal\n load replace /var/tmp/file.conf\n end\n write memory\n exit\n'), (45,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), (46,4,'copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_.swi secondary\n boot system flash secondary\n copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_ primary\n boot system flash primary\n'), (47,5,''), - (48,7,''), + (48,7,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), (49,0,'sleep:1 exit\n\r'), (50,1,'sleep:1 capture:system resource print\n\r exit\n\r'), (51,2,'sleep:1 system backup load name=_nameBackup_ password=_passwordBackup_\n\r expect:Restore yes\n\r exit\n\r'), (52,3,'sleep:1 capture:/system package print\n\r exit\n\r'), (53,4,'sleep:1 /system routerboard upgrade\n\r expect:Do yes\n\r exit\n\r'), (54,5,''), - (55,7,''); + (55,7,'sleep:1 capture:/system package print\n\r exit\n\r'); INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1), From 46a74c2e220efaad8e520bef24cf61bdb33c1378 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 7 Nov 2023 13:35:08 +0100 Subject: [PATCH 082/264] #12345 Fixed enable/disable --- .../godmode/agentes/configurar_agente.php | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 88d4b0e4ed..baf0a24524 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -2149,6 +2149,28 @@ if ($update_module || $create_module || ($module_in_policy && !$module_linked) ) { if ($success_action > 0) { + if (empty($old_configuration_data) === true + && empty($configuration_data) === true && $disabled === '0' + && ($enable_module || $disable_module) + ) { + $modulo_nombre = io_safe_output( + db_get_value( + 'nombre', + 'tagente_modulo', + 'id_agente_modulo', + (empty($disable_module) === false) ? $disable_module : $enable_module + ) + ); + + $old_configuration_data = config_agents_get_module_from_conf( + $id_agente, + $modulo_nombre + ); + $configuration_data = $old_configuration_data; + + $disabled = (empty($disable_module) === false) ? true : false; + } + enterprise_hook( 'config_agents_write_module_in_conf', [ @@ -2297,7 +2319,6 @@ if ($disable_module) { $modulo_nombre = io_safe_output($modulo_nombre['nombre']); if ($result === NOERR) { - enterprise_hook('config_agents_disable_module_conf', [$id_agente, $disable_module]); db_pandora_audit( AUDIT_LOG_MODULE_MANAGEMENT, 'Disable #'.$disable_module.' | '.$modulo_nombre.' | '.$agent['alias'] From 2d7895b39b7a4a258da9698bd133185b39220247 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Tue, 7 Nov 2023 15:22:22 +0100 Subject: [PATCH 083/264] #8365 Fixed ncm reports of html type --- .../godmode/reporting/reporting_builder.item_editor.php | 7 +++++++ pandora_console/include/functions_reporting_html.php | 7 ++++++- pandora_console/include/styles/pandora.css | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index f50b451683..c16cbd4a05 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -8146,10 +8146,17 @@ function filterNcmAgentChange() { }, success: function(data) { $("#agent_ncm").empty(); + var optionAny = $("") + .attr("value",0) + .html("Any"); + // Add any option. + $("#agent_ncm").append(optionAny); + data.map(item => { var option = $("") .attr("value", item.id_agent) .html(item.alias); + // Add agents options. $("#agent_ncm").append(option); }); }, diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index a74fcb4a47..d2d4f5850f 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -7437,6 +7437,7 @@ function reporting_html_ncm_backups($table, $item, $pdf=0) ui_require_javascript_file('highlight.min'); ui_require_javascript_file('highlightjs-line-numbers.min'); ui_require_javascript_file('languages/plaintext.min'); + ui_require_javascript_file('jquery', ENTERPRISE_DIR.'/include/javascript/'); ui_require_javascript_file('functions_ncm', ENTERPRISE_DIR.'/include/javascript/'); // Create table diff. @@ -7448,6 +7449,8 @@ function reporting_html_ncm_backups($table, $item, $pdf=0) $table_ncm->head = []; $table_ncm->head[0] = __('Date'); $table_ncm->head[1] = __('Diff'); + $table_ncm->caption = $item['caption']; + $table_ncm->id = 'ncm_backups'; $table_ncm->data = []; @@ -7459,7 +7462,9 @@ function reporting_html_ncm_backups($table, $item, $pdf=0) ]; } - return $table->data[] = html_print_table( + $table->colspan['ncm_backups']['cell'] = 3; + $table->cellstyle['ncm_backups']['cell'] = 'text-align: left;'; + $table->data['ncm_backups']['cell'] = html_print_table( $table_ncm, true ); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 63179618b1..7e9669bc21 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12798,3 +12798,7 @@ tr.shown td.details-control { position: relative; top: -92px; } + +#ncm_backups > caption > h4 { + color: black; +} From 14fff848760653ab06d9b61f2b65e99479dcf873 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 8 Nov 2023 11:56:32 +0100 Subject: [PATCH 084/264] queries remove field transactional_agent pandora_enterprise#12334 --- pandora_console/extras/mr/67.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 pandora_console/extras/mr/67.sql diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql new file mode 100644 index 0000000000..0a5fcd9fb0 --- /dev/null +++ b/pandora_console/extras/mr/67.sql @@ -0,0 +1,13 @@ +START TRANSACTION; + +SET @exist = (SELECT count(*) FROM information_schema.columns WHERE TABLE_NAME='tmetaconsole_agent' AND COLUMN_NAME='transactional_agent' AND table_schema = DATABASE()); +SET @sqlstmt = IF (@exist>0, 'ALTER TABLE `tmetaconsole_agent` DROP COLUMN `transactional_agent`', 'SELECT ""'); +prepare stmt from @sqlstmt; +execute stmt; + +SET @exist = (SELECT count(*) FROM information_schema.columns WHERE TABLE_NAME='tagente' AND COLUMN_NAME='transactional_agent' AND table_schema = DATABASE()); +SET @sqlstmt = IF (@exist>0, 'ALTER TABLE `tagente` DROP COLUMN `transactional_agent`', 'SELECT ""'); +prepare stmt from @sqlstmt; +execute stmt; + +COMMIT; From 98bc73a83ab0b6308703b90132187392a9a8e2ae Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Wed, 8 Nov 2023 14:40:47 +0100 Subject: [PATCH 085/264] #8365 Fix ncm report for multiple agents --- pandora_console/extras/mr/67.sql | 3 + .../reporting_builder.item_editor.php | 6 +- .../godmode/reporting/reporting_builder.php | 11 ++- .../include/functions_reporting_html.php | 71 ++++++++++--------- pandora_console/pandoradb.sql | 1 + 5 files changed, 54 insertions(+), 38 deletions(-) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index 2a604941e0..2913cd8248 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -29,6 +29,9 @@ ADD COLUMN `agent_data_cron_interval` VARCHAR(100) NULL DEFAULT '' AFTER `cron_i ALTER TABLE `tncm_agent` ADD COLUMN `agent_data_event_on_change` INT UNSIGNED NULL DEFAULT NULL AFTER `event_on_change`; +ALTER TABLE `treport_content` +ADD COLUMN `ncm_agents` MEDIUMTEXT NULL AFTER `status_of_check`; + -- Add new vendor and model SET @vendor_name = 'Cisco'; SET @model_name = 'Cisco-Generic'; diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index c16cbd4a05..49c7ac7f80 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -1036,12 +1036,12 @@ switch ($action) { break; case 'ncm': - $id_agent_ncm = $item['id_agent']; + $id_agent_ncm = json_decode($item['ncm_agents']); $ncm_group = $item['id_group']; break; case 'ncm_backups': - $id_agent_ncm = $item['id_agent']; + $id_agent_ncm = json_decode($item['ncm_agents']); $ncm_group = $item['id_group']; break; @@ -1973,7 +1973,7 @@ if (is_metaconsole() === true) { $all_agents = agents_get_agents_selected($ncm_group); html_print_select( $all_agents, - 'agent_ncm', + 'agent_ncm[]', $id_agent_ncm, '', __('Any'), diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index f155a89831..e449b766ff 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -2046,13 +2046,15 @@ switch ($action) { break; case 'ncm_backups': - $values['id_agent'] = get_parameter('agent_ncm'); + $agents_ncm = get_parameter('agent_ncm'); + $values['ncm_agents'] = json_encode($agents_ncm); $values['id_group'] = get_parameter('ncm_group'); $good_format = true; break; case 'ncm': - $values['id_agent'] = get_parameter('agent_ncm'); + $agents_ncm = get_parameter('agent_ncm'); + $values['ncm_agents'] = json_encode($agents_ncm); $values['id_group'] = get_parameter('ncm_group'); $good_format = true; break; @@ -2996,12 +2998,15 @@ switch ($action) { break; case 'ncm_backups': - $values['id_agent'] = get_parameter('agent_ncm'); + $agents_ncm = get_parameter('agent_ncm'); + $values['ncm_agents'] = json_encode($agents_ncm); $values['id_group'] = get_parameter('ncm_group'); $good_format = true; break; case 'ncm': + $agents_ncm = get_parameter('agent_ncm'); + $values['ncm_agents'] = json_encode($agents_ncm); $values['id_agent'] = get_parameter('agent_ncm'); $values['id_group'] = get_parameter('ncm_group'); $good_format = true; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index d2d4f5850f..0fbae441ec 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -7441,45 +7441,52 @@ function reporting_html_ncm_backups($table, $item, $pdf=0) ui_require_javascript_file('functions_ncm', ENTERPRISE_DIR.'/include/javascript/'); // Create table diff. - $table_ncm = new stdClass(); - $table_ncm->width = '100%'; - $table_ncm->class = 'info_table'; - $table_ncm->styleTable = 'table-layout: fixed;'; - $table_ncm->headstyle[0] = 'width: 250px'; - $table_ncm->head = []; - $table_ncm->head[0] = __('Date'); - $table_ncm->head[1] = __('Diff'); - $table_ncm->caption = $item['caption']; - $table_ncm->id = 'ncm_backups'; - - $table_ncm->data = []; - - if ($pdf === 0) { - foreach ($item['data'] as $key => $row) { - $table_ncm->data[] = [ - $row['updated_at'], - $row['diff'], - ]; + foreach ($item['data'] as $ncm_agent_key => $ncm_agent) { + $table_ncm = new stdClass(); + if ($pdf === 1) { + $table_ncm->width = '100%'; } - $table->colspan['ncm_backups']['cell'] = 3; - $table->cellstyle['ncm_backups']['cell'] = 'text-align: left;'; - $table->data['ncm_backups']['cell'] = html_print_table( - $table_ncm, - true - ); - } else { - foreach ($item['data'] as $key => $row) { - $table_ncm->data[] = [ - $row['updated_at'], - ($row['diffstr'] === '') ? $row['diff'] : str_replace("\n", '
', $row['diffstr']), - ]; + $table_ncm->class = 'info_table'; + $table_ncm->styleTable = 'table-layout: fixed;'; + $table_ncm->headstyle[0] = 'width: 250px'; + $table_ncm->head = []; + $table_ncm->head[0] = __('Date'); + $table_ncm->head[1] = __('Diff'); + $table_ncm->id = 'ncm_backups'; + $table_ncm->name = 'ncm_backups'; + $table_ncm->title = $ncm_agent['caption']; + $row = []; + foreach ($ncm_agent['data'] as $ncm_agent_data) { + if ($pdf === 1) { + $row[] = [ + $ncm_agent_data['updated_at'], + ($ncm_agent_data['diffstr'] === '') ? $ncm_agent_data['diff'] : str_replace("\n", '
', $ncm_agent_data['diffstr']), + ]; + } else { + $row[] = [ + $ncm_agent_data['updated_at'], + $ncm_agent_data['diff'], + ]; + } + + $table_ncm->data = $row; } - return html_print_table( + $table->colspan[$ncm_agent_key]['cell'] = 3; + $table->cellstyle[$ncm_agent_key]['cell'] = 'text-align: left;'; + $table->data[$ncm_agent_key]['cell'] = html_print_table( $table_ncm, true ); } + if ($pdf === 1) { + $table->width = '100%'; + return html_print_table( + $table, + true + ); + } + } diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 8b83b26011..334afe02b2 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1645,6 +1645,7 @@ CREATE TABLE IF NOT EXISTS `treport_content` ( `cat_security_hardening` INT NOT NULL DEFAULT 0, `ignore_skipped` INT NOT NULL DEFAULT 0, `status_of_check` TINYTEXT, + `ncm_agents` MEDIUMTEXT, PRIMARY KEY(`id_rc`), FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`) ON UPDATE CASCADE ON DELETE CASCADE From f773230ebf3851f65c85f339017650d817c5f8fc Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Thu, 9 Nov 2023 16:18:06 -0500 Subject: [PATCH 086/264] Modify pandora_cps_enabled function --- pandora_server/lib/PandoraFMS/Core.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index afd3e8e865..797268f032 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -5778,9 +5778,9 @@ sub pandora_inhibit_alerts { sub pandora_cps_enabled($$) { my ($agent, $module) = @_; - return 1 if ($agent->{'cps'} > 0); + return 1 if ($agent->{'cps'} >= 0); - return 1 if ($module->{'cps'} > 0); + return 1 if ($module->{'cps'} >= 0); return 0; } From 1fcc263046aa69d254b81f3707c91d95f866734c Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Fri, 10 Nov 2023 11:24:34 +0100 Subject: [PATCH 087/264] implemented demo data load --- pandora_console/godmode/setup/demo.php | 221 +++++++++++++++--- .../include/ajax/demo_data.ajax.php | 158 ++++++++++--- 2 files changed, 315 insertions(+), 64 deletions(-) diff --git a/pandora_console/godmode/setup/demo.php b/pandora_console/godmode/setup/demo.php index 9af7e2721e..d0d65c748f 100644 --- a/pandora_console/godmode/setup/demo.php +++ b/pandora_console/godmode/setup/demo.php @@ -34,6 +34,14 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user return; } +config_update_value('demo_data_load_progress', 0); + +html_print_input_hidden('demo_items_count', 0); + +$submit_value = (string) get_parameter('update_button', ''); +$demo_items_count = db_get_value('count(*)', 'tdemo_data'); +$demo_agents_count = db_get_value('count(*)', 'tdemo_data', 'table_name', 'tagente'); + // Basic/Advanced mode. $mode = (string) get_parameter('mode', 'basic'); @@ -85,7 +93,7 @@ ui_print_standard_header( ); $table_aux = new stdClass(); -$table_aux->id = 'table-password-policy'; +$table_aux->id = 'table-demo'; $table_aux->class = 'filter-table-adv'; $table_aux->width = '100%'; $table_aux->data = []; @@ -124,20 +132,34 @@ $table_aux->data['row1'][] = html_print_label_input_block( 'agents_num', $config['gis_default_icon'], '', - '', - '', + '30', + 30, true, false, true, 'w80px' - ).'  '.__('(%d demo agents currently in the system)').'', + ).'  '.__('(%d demo agents currently in the system)', $demo_agents_count).'', ], true ) ); +$table_aux->data['row2'][] = progress_bar( + 0, + 100, + 20, + '', + 0, + false, + ((int) 0 !== -1) ? false : '#f3b200', + [ + 'class' => 'progress_bar', + 'id' => 'progress_bar', + ] +).html_print_input_hidden('js_timer_'.$operation['id'], 0, true); + if ($mode === 'advanced') { - $table_aux->data['row2'][] = html_print_label_input_block( + $table_aux->data['row3'][] = html_print_label_input_block( __('Generate historical data for all agents (15 days by default)'), html_print_checkbox_switch( 'enable_pass_policy_admin', @@ -147,7 +169,7 @@ if ($mode === 'advanced') { ) ); - $table_aux->data['row3'][] = html_print_label_input_block( + $table_aux->data['row4'][] = html_print_label_input_block( __('Create services, visual console, dashboard, reports, clusters and network maps'), html_print_checkbox_switch( 'enable_pass_policy_admin', @@ -157,7 +179,7 @@ if ($mode === 'advanced') { ) ); - $table_aux->data['row4'][] = html_print_label_input_block( + $table_aux->data['row5'][] = html_print_label_input_block( __('Generate custom/combined graphs'), html_print_checkbox_switch( 'enable_pass_policy_admin', @@ -167,7 +189,7 @@ if ($mode === 'advanced') { ) ); - $table_aux->data['row5'][] = html_print_label_input_block( + $table_aux->data['row6'][] = html_print_label_input_block( __('Generate netflow demo data'), html_print_checkbox_switch( 'enable_pass_policy_admin', @@ -177,7 +199,7 @@ if ($mode === 'advanced') { ) ); - $table_aux->data['row6'][] = html_print_label_input_block( + $table_aux->data['row7'][] = html_print_label_input_block( __('Generate logs for each agent'), html_print_checkbox_switch( 'enable_pass_policy_admin', @@ -187,7 +209,7 @@ if ($mode === 'advanced') { ) ); - $table_aux->data['row7'][] = html_print_label_input_block( + $table_aux->data['row8'][] = html_print_label_input_block( __('Generate inventory data for each agent'), html_print_checkbox_switch( 'enable_pass_policy_admin', @@ -197,7 +219,7 @@ if ($mode === 'advanced') { ) ); - $table_aux->data['row8'][] = html_print_label_input_block( + $table_aux->data['row9'][] = html_print_label_input_block( __('Generate SNMP traps for each agent'), html_print_checkbox_switch( 'enable_pass_policy_admin', @@ -207,7 +229,7 @@ if ($mode === 'advanced') { ) ); - $table_aux->data['row9'][] = html_print_label_input_block( + $table_aux->data['row10'][] = html_print_label_input_block( __('Days of historical data to insert in the agent data'), html_print_input_text( 'days_hist_data', @@ -250,18 +272,21 @@ $actionButtons[] = html_print_submit_button( __('Create demo data'), 'update_button', false, - [ 'icon' => 'update' ], + [ + 'icon' => 'update', + 'fixed_id' => 'btn-create-demo-data', + ], true ); -$actionButtons[] = html_print_button( +$actionButtons[] = html_print_submit_button( __('Delete demo data'), - 'delete_session_users', + 'update_button', false, - '', [ - 'icon' => 'delete', - 'mode' => 'secondary', + 'icon' => 'delete', + 'mode' => 'secondary', + 'fixed_id' => 'btn-delete-demo-data', ], true ); @@ -271,29 +296,161 @@ html_print_action_buttons( ); echo ''; - ?> \ No newline at end of file diff --git a/pandora_console/include/ajax/demo_data.ajax.php b/pandora_console/include/ajax/demo_data.ajax.php index 1016903e57..c2d163054a 100644 --- a/pandora_console/include/ajax/demo_data.ajax.php +++ b/pandora_console/include/ajax/demo_data.ajax.php @@ -20,17 +20,23 @@ * ============================================================================ */ +global $config; + +// Login check. +check_login(); + include $config['homedir'].'/include/functions_inventory.php'; $action = (string) get_parameter('action', null); if ($action === 'create_demo_data') { + config_update_value('demo_data_load_progress', 0); $agents_num = (int) get_parameter('agents_num', 0); - hd("qqqq ".$agents_num, true); + if ($agents_num > 0) { // Read all ini files. $parsed_ini[] = parse_ini_file($config['homedir'].'/extras/demodata/agents/linux.ini', true, INI_SCANNER_TYPED); -hd($parsed_ini, true); + $ag_groups_num = ($agents_num / 10); // Create new group per group of ten agents that are to be created. @@ -88,6 +94,7 @@ hd($parsed_ini, true); $agent_last_id = (int) explode(' ', $agent_alias)[1]; } + // Traverse ini files and create items. foreach ($parsed_ini as $ini_so_data) { $agent_data = $ini_so_data['agent_data']; $modules_data = $ini_so_data['modules']; @@ -109,6 +116,21 @@ hd($parsed_ini, true); if ($id_os === false) { continue; } + + if ($id_os > 0) { + // Register created OS in tdemo_data. + $values = [ + 'item_id' => $id_os, + 'table_name' => 'tconfig_os', + ]; + $result = (bool) db_process_sql_insert('tdemo_data', $values); + + if ($result === false) { + // Rollback OS creation if could not be registered in tdemo_data. + db_process_sql_delete('tconfig_os', ['id_os' => $id_os]); + continue; + } + } } // Define agents to be created per group of 10. @@ -122,7 +144,7 @@ hd($parsed_ini, true); $agents_to_create = ($ag_groups_num * $agents_per_os[$os_name]); - for ($i=0; $i < $agents_to_create; $i++) { + for ($i = 0; $i < $agents_to_create; $i++) { $next_ip_address = calculateNextHostAddress($address_network); $os_version = current($os_versions); @@ -163,6 +185,15 @@ hd($parsed_ini, true); $agents_created_count++; + $percentage_inc = ((($agents_created_count * 100) / $agents_to_create) / count($parsed_ini)); + $current_progress_val = db_get_value_filter('value', 'tconfig', ['token' => 'demo_data_load_progress']); + + if ($current_progress_val === false) { + $current_progress_val = 0; + } + + config_update_value('demo_data_load_progress', ($current_progress_val + $percentage_inc)); + if (($agents_created_count % 10) === 0) { $group_idx++; } @@ -249,6 +280,7 @@ hd($parsed_ini, true); $current_date_time = $date_time->format('Y-m-d H:i:s'); while (1) { + // Insert in tmodule_inventory. $modules_array = []; foreach ($inventory as $key => $value) { $modules_array[$key] = ($value[$module_access_idx] ?? null); @@ -266,7 +298,6 @@ hd($parsed_ini, true); 'id_os' => 1, ]; - // STEP 1: tmodule_inventory. $created_inventory_mod_id = inventory_create_inventory_module($values); if ($created_inventory_mod_id > 0) { @@ -286,18 +317,7 @@ hd($parsed_ini, true); $module_access_idx++; - // STEP 2: tagent_module_inventory. - $values = [ - 'id_agente' => $created_agent_id, - 'id_module_inventory' => $created_inventory_mod_id, - 'interval' => 300, - 'utimestamp' => time(), - 'timestamp' => $current_date_time, - ]; - - - - // STEP 3: Create inventory values (tagente_datos_inventory). + // Insert in tagent_module_inventory and tagente_datos_inventory. $field_idx = 1; $values_array = explode(';', $modules_array['values']); @@ -309,9 +329,6 @@ hd($parsed_ini, true); ARRAY_FILTER_USE_KEY ); - hd("INV VALUES", true); - hd($selected_inventory_values, true); - $data_lines = []; while (1) { $line_values = array_column($selected_inventory_values, $field_idx); @@ -326,19 +343,40 @@ hd($parsed_ini, true); $data_str = implode('\n', $data_lines); - hd("DATA STR",true); - hd($data_str, true); + $values = [ + 'id_agente' => $created_agent_id, + 'id_module_inventory' => $created_inventory_mod_id, + 'interval' => 300, + 'utimestamp' => time(), + 'timestamp' => $current_date_time, + 'data' => $data_str, + ]; + + $created_module_inventory_id = db_process_sql_insert('tagent_module_inventory', $values); + + if ($created_module_inventory_id > 0) { + // Register created demo item in tdemo_data. + $values = [ + 'item_id' => $created_module_inventory_id, + 'table_name' => 'tagent_module_inventory', + ]; + $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('tagent_module_inventory', ['id_agent_module_inventory' => $created_module_inventory_id]); + continue; + } + } $inventory_data_values = [ - 'data' => $data_str, - 'utimestamp' => time(), - 'timestamp' => $current_date_time, + 'id_agent_module_inventory' => $created_module_inventory_id, + 'data' => $data_str, + 'utimestamp' => time(), + 'timestamp' => $current_date_time, ]; $created_inventory_data = db_process_sql_insert('tagente_datos_inventory', $inventory_data_values); - hd("CID",true); - hd($inventory_data_values, true); - hd($created_inventory_data, true); if ($created_inventory_data > 0) { // Register created inventory data element in tdemo_data. @@ -363,9 +401,65 @@ hd($parsed_ini, true); } } + $demo_agents_count = db_get_value('count(*)', 'tdemo_data', 'table_name', 'tagente'); + echo json_encode(['agents_count' => $demo_agents_count]); + return; } +if ($action === 'cleanup_demo_data') { + config_update_value('demo_data_load_progress', 0); + + $demo_items = db_get_all_rows_in_table('tdemo_data'); + + foreach ($demo_items as $item) { + $table_id_field_dict = [ + 'tconfig_os' => 'id_os', + 'tagente' => 'id_agente', + 'tgrupo' => 'id_grupo', + 'tagente_modulo' => 'id_agente_modulo', + 'tmodule_inventory' => 'id_module_inventory', + 'tagent_module_inventory' => 'id_agent_module_inventory', + 'tagente_datos_inventory' => 'id_agent_module_inventory', + ]; + + $table_id_field = $table_id_field_dict[$item['table_name']]; + + $result = db_process_sql_delete( + $item['table_name'], + [$table_id_field => $item['item_id']] + ); + + if ($result !== false) { + db_process_sql_delete( + 'tdemo_data', + ['item_id' => $item['item_id']] + ); + } + } + + echo 1; +} + +if ($action === 'get_progress_bar') { + $operation = (string) get_parameter('operation'); + + if ($operation === 'create') { + $current_progress_val = db_get_value_filter('value', 'tconfig', ['token' => 'demo_data_load_progress']); + + if ($current_progress_val === false) { + $current_progress_val = 0; + } + } else if ($operation === 'cleanup') { + $demo_items_to_cleanup = (int) get_parameter('demo_items_to_cleanup'); + $count_current_demo_items = db_get_value('count(*)', 'tdemo_data'); + $current_progress_val = ((($demo_items_to_cleanup - $count_current_demo_items) * 100) / $demo_items_to_cleanup); + } + + echo $current_progress_val; + + return; +} function calculateNextHostAddress($ip) { list($network, $subnet) = explode('/', $ip); @@ -374,13 +468,13 @@ function calculateNextHostAddress($ip) { $octets = explode('.', $network); // Convert the last octet to an integer. - $lastOctet = (int)$octets[3]; + $lastOctet = (int) $octets[3]; // Increment the last octet, and wrap around if it exceeds 255. - $lastOctet = ($lastOctet + 1) % 256; + $lastOctet = (($lastOctet + 1) % 256); // Assemble the next host address. - $nextHost = implode('.', array($octets[0], $octets[1], $octets[2], $lastOctet)); + $nextHost = implode('.', [$octets[0], $octets[1], $octets[2], $lastOctet]); - return $nextHost . '/' . $subnet; -} \ No newline at end of file + return $nextHost.'/'.$subnet; +} From 5eb5df61906cdf0f1e98aa6213af79660fa00eaf Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Fri, 10 Nov 2023 13:13:57 +0100 Subject: [PATCH 088/264] change url pandorarc name --- pandora_console/godmode/setup/setup.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 0fd6bebff8..c0d59fbde9 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -184,7 +184,7 @@ $buttons['ITSM'] = [ $buttons['ehorus'] = [ 'active' => false, - 'text' => ''.html_print_image( + 'text' => ''.html_print_image( 'images/RC.png', true, [ @@ -297,7 +297,7 @@ switch ($section) { $help_header = 'setup_flow_tab'; break; - case 'ehorus': + case 'pandorarc': $buttons['ehorus']['active'] = true; $subpage = __('Pandora RC'); $help_header = 'setup_ehorus_tab'; @@ -438,7 +438,7 @@ switch ($section) { include_once $config['homedir'].'/godmode/setup/setup_visuals.php'; break; - case 'ehorus': + case 'pandorarc': include_once $config['homedir'].'/godmode/setup/setup_ehorus.php'; break; From ad90fb74b2b3615cbb2be60ba5bc08b0e2a8e752 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 13 Nov 2023 10:42:25 +0100 Subject: [PATCH 089/264] #12390 Fixed group --- pandora_console/include/class/Heatmap.class.php | 6 +++++- pandora_console/include/lib/Dashboard/Widgets/heatmap.php | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/class/Heatmap.class.php b/pandora_console/include/class/Heatmap.class.php index 05d6152030..3ed4b3cc72 100644 --- a/pandora_console/include/class/Heatmap.class.php +++ b/pandora_console/include/class/Heatmap.class.php @@ -549,8 +549,12 @@ class Heatmap global $config; $filter_group = ''; - if (empty($this->filter) === false && current($this->filter) != -1) { + if (empty($this->filter) === false && current($this->filter) != -1 + && implode(',', $this->filter) !== '' + ) { $filter_group = 'AND am.id_module_group IN ('.implode(',', $this->filter).')'; + } else { + return false; } $filter_name = ''; diff --git a/pandora_console/include/lib/Dashboard/Widgets/heatmap.php b/pandora_console/include/lib/Dashboard/Widgets/heatmap.php index 363ea1489e..e199a80ad8 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/heatmap.php +++ b/pandora_console/include/lib/Dashboard/Widgets/heatmap.php @@ -320,6 +320,10 @@ class HeatmapWidget extends Widget $module_groups[$module_group['id_mg']] = $module_group['name']; } + if (empty($values['module_groups'][0]) === true) { + $values['module_groups'][0] = 0; + } + $inputs[] = [ 'label' => __('Module group'), 'style' => ($values['type'] === '2') ? '' : 'display:none', @@ -332,7 +336,7 @@ class HeatmapWidget extends Widget 'return' => true, 'multiple' => true, 'nothing' => __('Not assigned'), - 'nothing_value' => 0, + 'nothing_value' => '0', ], ]; From 04649dee00d8d0b25ffa8cab410d7f687a6768d3 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 13 Nov 2023 13:41:47 +0100 Subject: [PATCH 090/264] #12168 Fixed sql bringing main services --- .../include/class/TreeService.class.php | 16 ++++++---------- .../include/javascript/tree/TreeController.js | 1 + 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php index b218468de3..a627794f0e 100644 --- a/pandora_console/include/class/TreeService.class.php +++ b/pandora_console/include/class/TreeService.class.php @@ -738,19 +738,15 @@ class TreeService extends Tree $filterResult = db_get_all_rows_sql($sqlFilter); + $services = []; foreach ($filterResult as $key => $result) { - $ancestors = services_get_services_ancestors($result['id']); - $idAncestors = implode(',', $ancestors); - $numAncestors = count($ancestors); - if ($numAncestors > 1) { - $whereAncestors = ' AND tse.id_service_child in ('.$idAncestors.')'; - } else if ($numAncestors == 1) { - $whereAncestors = ' AND ts.id ='.$idAncestors; - } else { - $whereAncestors = ' AND ts.id ='.$result['id']; - } + $services_ancestors = services_get_services_ancestors($result['id']); + $services[] = array_pop($services_ancestors); } + $services_list = array_unique($services, SORT_NUMERIC); + $whereAncestors = ' AND tse.id_service IN ('.implode(',', $services_list).')'; + return $whereAncestors; } diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index d8a6daf468..4f850e32d5 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -1561,6 +1561,7 @@ var TreeController = { * Filter the tree based on a search criterion */ function _filterItems(rawTree, searched) { + console.log(rawTree); const ancestors = []; const father = []; const newTree = []; From d49c5e4954336fa79371fc7eb6a8e965bd4d6641 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 13 Nov 2023 15:12:55 +0100 Subject: [PATCH 091/264] delete agents pandora_db pandora_enterprise#12293 --- pandora_server/util/pandora_db.pl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 92c6c5f9ce..b68e71c469 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -142,10 +142,18 @@ sub pandora_purgedb ($$$) { # Delete manually disabled agents after some period if (defined ($conf->{'_delete_disabled_agents'}) && $conf->{'_delete_disabled_agents'} > 0) { log_message('PURGE', "Deleting old disabled agents (More than " . $conf->{'_delete_disabled_agents'} . " days)."); - db_do ($dbh, "DELETE FROM tagente - WHERE UNIX_TIMESTAMP(ultimo_contacto) + ? < UNIX_TIMESTAMP(NOW()) - AND disabled = 1 - AND modo != 2", $conf->{'_delete_disabled_agents'} * 8600); + my @agents_to_delete = get_db_rows ( + $dbh, + "SELECT id_agente FROM tagente + WHERE UNIX_TIMESTAMP(ultimo_contacto) + ? < UNIX_TIMESTAMP(NOW()) + AND disabled = 1 + AND modo != 2", + $conf->{'_delete_disabled_agents'} * 8600 + ); + + foreach my $agent_to_delete (@agents_to_delete) { + pandora_delete_agent($dbh, $agent_to_delete->{'id_agente'}); + } } # Delete old data From c2bf6e6bf52614c88448dd83e4035cfb65c93b40 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Mon, 13 Nov 2023 17:34:38 +0100 Subject: [PATCH 092/264] fix pgrep process in ubuntu --- pandora_console/include/functions_cron_task.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_cron_task.php b/pandora_console/include/functions_cron_task.php index 9de0520ccd..40a6e159cc 100644 --- a/pandora_console/include/functions_cron_task.php +++ b/pandora_console/include/functions_cron_task.php @@ -459,17 +459,17 @@ function cron_task_start_gotty(bool $restart_mode=true) // Check prev process running and kill it (only if port changed in setup params). if (empty($config['restart_gotty_next_cron_port']) === false) { - config_update_value('restart_gotty_next_cron_port', ''); - - $prevProcessRunning = shell_exec("pgrep -f 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."'"); + $prevProcessRunning = shell_exec("pgrep -af 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."' | grep -v 'pgrep'"); if (empty($prevProcessRunning) === false) { shell_exec("pkill -f 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."'"); } + + config_update_value('restart_gotty_next_cron_port', ''); } // Check if gotty is running on the configured port. - $processRunning = shell_exec("pgrep -f 'pandora_gotty.*-p ".$config['gotty_port']."'"); + $processRunning = shell_exec("pgrep -af 'pandora_gotty.*-p ".$config['gotty_port']."' | grep -v 'pgrep'"); $start_proc = true; From f725752f3201b52645c6360cddbad5a6e5d2b45e Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Tue, 14 Nov 2023 12:33:29 +0100 Subject: [PATCH 093/264] #12168 fixed filter in service tree genealogy --- .../include/javascript/tree/TreeController.js | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 4f850e32d5..06274600ed 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -1561,27 +1561,21 @@ var TreeController = { * Filter the tree based on a search criterion */ function _filterItems(rawTree, searched) { - console.log(rawTree); const ancestors = []; const father = []; const newTree = []; + const tmpTree = []; rawTree.map((raw, index) => { if (raw.type === "services") { if (raw.servicesChildren.length !== 0) { // search at parent level - let findedPadre = raw.description.indexOf(searched); + let descr = raw.description.toLowerCase(); + let sear = searched.toLowerCase(); + let findedPadre = descr.indexOf(sear); if (findedPadre === -1) { - // search for children - raw.servicesChildren.map(child => { - let finded = child.description.indexOf(searched); - if (finded === 0) { - //we keep the father of the child that contains it - ancestors.push(child.ancestor); - } else if (findedPadre === -1 && finded === -1) { - //we save the father - father.push(raw.id); - } - }); + father.push(raw.id); + } else if (findedPadre >= 0) { + ancestors.push(raw.id); } else { //we mark the father as found controller.finded = 1; @@ -1607,9 +1601,16 @@ var TreeController = { if (father.length >= 1) { let filterfather = [...new Set(father)]; - const newTree = rawTree.filter( - item => !filterfather.includes(item.id) - ); + + filterfather.map(father => { + tmpTree.push(rawTree.filter(raw => raw.id == father)); + }); + + let tree = [...new Set(tmpTree)]; + tree.map(item => { + let tmpItem = item[0]; + newTree.push(tmpItem); + }); return newTree; } From 4fec6a1ccbef81a0c4bbe9721d32ff635f6a73f9 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 14 Nov 2023 17:04:31 +0100 Subject: [PATCH 094/264] #12296 restyling agent detail filters --- pandora_console/include/styles/pandora.css | 16 ++++++++ .../operation/agentes/estado_agente.php | 41 +++++++++++++------ 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 7c740bba2b..43b3823153 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -10214,6 +10214,14 @@ div#err_msg_centralised { align-items: flex-start; } +.div-col-4 { + width: 25%; + display: flex; + flex-direction: column; + align-items: flex-start; + margin-top: 10px; +} + .div-span { width: 100%; color: #161628; @@ -12792,3 +12800,11 @@ tr.shown td.details-control { position: relative; top: -92px; } + +.span_as_label { + font-size: 13px; + line-height: 16px; + color: #161628; + font-weight: bold; + margin-bottom: 10px; +} diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index d126b19144..d3543b0a7c 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -320,6 +320,7 @@ $table->size[0] = '50%'; $table->size[1] = '50%'; $table->class = 'filter-table-adv'; +$table->cellstyle['group'][0] = 'display: flex;width: 95% !important;'; $table->data['group'][0] = html_print_label_input_block( __('Group'), html_print_select_groups( @@ -336,7 +337,8 @@ $table->data['group'][0] = html_print_label_input_block( true, '', false - ) + ), + ['div_class' => 'w100p'] ); $table->data['group'][0] .= html_print_label_input_block( @@ -346,11 +348,7 @@ $table->data['group'][0] .= html_print_label_input_block( 1, $recursion, true - ), - [ - 'div_class' => 'add-input-reverse', - 'label_class' => 'label-thin', - ] + ) ); $table->data['group'][1] = html_print_label_input_block( @@ -405,7 +403,7 @@ foreach ($pre_fields as $key => $value) { $table->data[1][0] = html_print_label_input_block( __('Operating System'), - html_print_select($fields, 'os', $os, '', 'All', 0, true) + html_print_select($fields, 'os', $os, '', 'All', 0, true, false, true, 'w100p', false, 'width:100%') ); $table->data[1][1] = html_print_label_input_block( @@ -428,9 +426,22 @@ if (function_exists('policies_get_policies') === true) { } } -$table->data[2][0] = html_print_label_input_block( +$table->data[2][1] = html_print_label_input_block( __('Policies'), - html_print_select($fields, 'policies[]', $policies, '', 'All', 0, true, true) + html_print_select( + $fields, + 'policies', + $policies, + 'this.form.submit()', + __('All'), + 0, + true, + false, + true, + 'w100p', + false, + 'width: 100%' + ) ); $custom_fields = db_get_all_fields_in_table('tagent_custom_fields'); @@ -438,7 +449,7 @@ if ($custom_fields === false) { $custom_fields = []; } -$div_custom_fields = '
'; +$div_custom_fields = '
'; foreach ($custom_fields as $custom_field) { $custom_field_value = ''; if (empty($ag_custom_fields) === false) { @@ -448,10 +459,10 @@ foreach ($custom_fields as $custom_field) { } } - $div_custom_fields .= '
'; + $div_custom_fields .= '
'; $div_custom_fields .= '
'; - $div_custom_fields .= ''.$custom_field['name'].''; + $div_custom_fields .= ''.$custom_field['name'].''; $div_custom_fields .= '
'; $div_custom_fields .= '
'; @@ -890,7 +901,11 @@ if ($group_id > 0) { $groups = array_keys($user_groups); } -$all_policies = in_array(0, ($policies ?? [])); +if (is_array($policies)) { + $all_policies = in_array(0, ($policies ?? [])); +} else { + $all_policies = []; +} $id_os_sql = ''; $policies_sql = ''; From 78a5a3bfe8116b0c10b11b8c725301a0eaf102ae Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Tue, 14 Nov 2023 17:12:22 +0100 Subject: [PATCH 095/264] #12168 Hierarchy is added to the title of services --- .../include/class/TreeService.class.php | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php index a627794f0e..177a45a54f 100644 --- a/pandora_console/include/class/TreeService.class.php +++ b/pandora_console/include/class/TreeService.class.php @@ -333,6 +333,7 @@ class TreeService extends Tree $services[$service['id']]['id'] = $service['id']; $services[$service['id']]['description'] = $service['description']; $services[$service['id']]['serviceDetail'] = 'index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int) $service['id']; + $services[$service['id']]['title'] = services_get_parents_title((int) $service['id']); } return $services; @@ -732,20 +733,8 @@ class TreeService extends Tree if (isset($this->filter['searchService']) === true && empty($this->filter['searchService']) === false ) { - $sqlFilter = 'SELECT ts.id FROM tservice ts - where ts.name LIKE "%'.$this->filter['searchService'].'%" - OR ts.description LIKE "%'.$this->filter['searchService'].'%"'; - - $filterResult = db_get_all_rows_sql($sqlFilter); - - $services = []; - foreach ($filterResult as $key => $result) { - $services_ancestors = services_get_services_ancestors($result['id']); - $services[] = array_pop($services_ancestors); - } - - $services_list = array_unique($services, SORT_NUMERIC); - $whereAncestors = ' AND tse.id_service IN ('.implode(',', $services_list).')'; + $whereAncestors = ' AND ts.name LIKE "%'.$this->filter['searchService'].'%" + OR ts.description LIKE "%'.$this->filter['searchService'].'%"'; return $whereAncestors; } From c34515549c1fc5a830ba4981025976d21e88bf20 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Wed, 15 Nov 2023 11:23:10 +0100 Subject: [PATCH 096/264] #12456 fixed size of cards containing Agents hive information --- .../lib/Dashboard/Widgets/AgentHive.php | 26 +++++++++++++------ pandora_console/include/styles/dashboards.css | 4 +-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php b/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php index 3b881ca344..c663670df1 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php +++ b/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php @@ -435,11 +435,17 @@ class AgentHive extends Widget $output .= html_print_div( [ 'content' => (empty($data['os_version']) === true) - ? get_os_name((int) $data['id_os']) - : $data['os_version'], - 'style' => 'font-size: 6pt; display: - flex;justify-content: start;align-items: start; - color: #9FA5B1; font-weight: 600;margin-bottom: 5px', + ? ui_print_truncate_text(get_os_name((int) $data['id_os'])) + : ui_print_truncate_text($data['os_version']), + 'style' => 'font-size: 6pt; + display: flex; + justify-content: start; + align-items: start; + color: #9FA5B1; + font-weight: 600; + margin: 5px; + float: right; + word-break: break-all;', ], true ); @@ -455,8 +461,10 @@ class AgentHive extends Widget true, '…', ), - 'style' => 'text-align: left;min-height: 42px; - font-size: 8pt;max-height: 42px; margin-bottom: 10px', + 'style' => 'text-align: left; + min-height: 42px; font-size: 8pt; + max-height: 42px; + margin: 2px 0px 2px 0px', ], true ); @@ -466,7 +474,9 @@ class AgentHive extends Widget [ 'content' => $data['direccion'], 'style' => 'font-size: 10pt;color: #14524f; - font-weight: 600; text-align: left', + font-weight: 600; + text-align: left; + margin-top: 5px', ], true ); diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css index 818e523316..1e048bab85 100644 --- a/pandora_console/include/styles/dashboards.css +++ b/pandora_console/include/styles/dashboards.css @@ -663,9 +663,9 @@ form.modal-dashboard justify-content: center; align-items: start; min-width: 150px; - max-width: 150px; + max-width: 200px; min-height: 150px; - max-height: 150px; + max-height: 200px; margin: 8px; padding: 5px; border: 1px solid #eceef2; From 4579fe21d98e1215413afc262154542271e3deaa Mon Sep 17 00:00:00 2001 From: alejandro Date: Wed, 15 Nov 2023 14:24:42 +0100 Subject: [PATCH 097/264] update version in mr --- pandora_console/extras/mr/67.sql | 6 ++++++ pandora_console/pandoradb_data.sql | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 pandora_console/extras/mr/67.sql diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql new file mode 100644 index 0000000000..48d44b6255 --- /dev/null +++ b/pandora_console/extras/mr/67.sql @@ -0,0 +1,6 @@ +START TRANSACTION; + +UPDATE `tdiscovery_apps` SET `version` = '1.2' WHERE `short_name` = 'pandorafms.vmware'; + +COMMIT; + diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 9ce5355361..6813173de7 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2653,7 +2653,7 @@ SET @short_name = 'pandorafms.vmware'; SET @name = 'VMware'; SET @section = 'app'; SET @description = 'Monitor ESXi hosts, datastores and VMs from a specific datacenter'; -SET @version = '1.1'; +SET @version = '1.2'; INSERT IGNORE INTO `tdiscovery_apps` (`id_app`, `short_name`, `name`, `section`, `description`, `version`) VALUES ('', @short_name, @name, @section, @description, @version); SELECT @id_app := `id_app` FROM `tdiscovery_apps` WHERE `short_name` = @short_name; From 4b0e134fba568048df1cb7f897f136033b1edca8 Mon Sep 17 00:00:00 2001 From: alejandro Date: Wed, 15 Nov 2023 15:13:08 +0100 Subject: [PATCH 098/264] update md5 hash --- .../extras/discovery/DiscoveryApplicationsMigrateCodes.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini b/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini index 6323aec140..1ba02194d2 100644 --- a/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini +++ b/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini @@ -1,4 +1,4 @@ -pandorafms.vmware=9959cc3e5cc6bfcfadd6d05b56d4a11b +pandorafms.vmware=54251ae54994c55b478867cd35a98e6c pandorafms.mysql=fadb4750d18285c0eca34f47c6aa3cfe pandorafms.mssql=1cc215409741d19080269ffba112810e pandorafms.oracle=2d9320a514d1e48a0b2804e1653c31c6 From 804970719d502de1adb91f2b32a055a116830427 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 15 Nov 2023 16:32:02 +0100 Subject: [PATCH 099/264] #12385 Fixed group --- .../agentes/pandora_networkmap.view.php | 51 ------------------- 1 file changed, 51 deletions(-) diff --git a/pandora_console/operation/agentes/pandora_networkmap.view.php b/pandora_console/operation/agentes/pandora_networkmap.view.php index 5256c10871..3cbe53e815 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.view.php +++ b/pandora_console/operation/agentes/pandora_networkmap.view.php @@ -1205,57 +1205,6 @@ if (is_ajax() === true) { return; } - if ($get_agents_in_group) { - $id = (int) get_parameter('id', 0); - $group = (int) get_parameter('group', -1); - - $return = []; - $return['correct'] = false; - - if ($group != -1) { - $where_id_agente = ' 1=1 '; - - $agents_in_networkmap = db_get_all_rows_filter( - 'titem', - [ - 'id_map' => $id, - 'deleted' => 0, - ] - ); - if ($agents_in_networkmap !== false) { - $ids = []; - foreach ($agents_in_networkmap as $agent) { - if ($agent['type'] == 0) { - $ids[] = $agent['source_data']; - } - } - - $where_id_agente = ' id_agente NOT IN ('.implode(',', $ids).')'; - } - - - $sql = 'SELECT id_agente, alias - FROM tagente - WHERE id_grupo = '.$group.' AND '.$where_id_agente.' - ORDER BY alias ASC'; - - $agents = db_get_all_rows_sql($sql); - - if ($agents !== false) { - $return['agents'] = []; - foreach ($agents as $agent) { - $return['agents'][$agent['id_agente']] = $agent['alias']; - } - - $return['correct'] = true; - } - } - - echo json_encode($return); - - return; - } - if ($get_agent_info) { $id_agent = (int) get_parameter('id_agent'); From 811363cbec0d8483eafac415bc3bf0147f5f218c Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Wed, 15 Nov 2023 17:07:47 +0100 Subject: [PATCH 100/264] #12200 snow effect added --- .../lib/TacticalView/GeneralTacticalView.php | 5 +- pandora_console/include/styles/pandora.css | 478 ++++++++++++++++++ pandora_console/index.php | 20 +- 3 files changed, 500 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/lib/TacticalView/GeneralTacticalView.php b/pandora_console/include/lib/TacticalView/GeneralTacticalView.php index d61b748bca..df259bfab2 100644 --- a/pandora_console/include/lib/TacticalView/GeneralTacticalView.php +++ b/pandora_console/include/lib/TacticalView/GeneralTacticalView.php @@ -170,10 +170,11 @@ class GeneralTacticalView $name = ''; } + // 👋 if (empty($name) === true) { - $message = __('Welcome back! 👋'); + $message = __('Welcome back! 🎅'); } else { - $message = __('Welcome back %s! 👋', $name); + $message = __('Welcome back %s! 🎅', $name); } return html_print_div( diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 7c740bba2b..238a4a72c7 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12792,3 +12792,481 @@ tr.shown td.details-control { position: relative; top: -92px; } + +@-moz-keyframes nieve { + from { + top: -40px; + } + to { + top: 101%; + } +} +@-webkit-keyframes nieve { + from { + top: -40px; + } + to { + top: 2000px; + } +} +@keyframes nieve { + from { + top: -40px; + } + to { + top: 2000px; + } +} + +@-moz-keyframes horiz2 { + 20% { + transform: translateX(0); + } + 50% { + transform: translateX(150px); + } + 80% { + transform: translateX(0); + } +} +@-webkit-keyframes horiz2 { + 20% { + transform: translateX(0); + } + 50% { + transform: translateX(150px); + } + 80% { + transform: translateX(0); + } +} +@keyframes horiz2 { + 20% { + transform: translateX(0); + } + 50% { + transform: translateX(-70px); + } + 80% { + transform: translateX(0); + } +} + +@-moz-keyframes horiz { + 20% { + transform: translateX(0); + } + 50% { + transform: translateX(150px); + } + 80% { + transform: translateX(0); + } +} +@-webkit-keyframes horiz { + 20% { + transform: translateX(0); + } + 50% { + transform: translateX(150px); + } + 80% { + transform: translateX(0); + } +} +@keyframes horiz { + 20% { + transform: translateX(0); + } + 50% { + transform: translateX(150px); + } + 80% { + transform: translateX(0); + } +} + +#container-snow > div { + position: fixed; + -webkit-animation: ease-in infinite normal; + -moz-animation: ease-in infinite normal; + animation: ease-in infinite normal; +} + +#container-snow > div { + z-index: 9999999999999; + width: 15px; + height: 15px; + -moz-border-radius: 50%; + -webkit-border-radius: 50%; + border-radius: 50%; + background-color: #e8ede5; + -webkit-animation-name: nieve, horiz; + -moz-animation-name: nieve, horiz; + animation-name: nieve, horiz; +} +#container-snow > div:nth-of-type(odd) { + width: 5px; + height: 5px; + -webkit-animation-name: nieve, horiz2; + -moz-animation-name: nieve, horiz2; + animation-name: nieve, horiz2; +} + +#container-snow > div:nth-of-type(1) { + left: 40px; + -webkit-animation-duration: 5.5s; + -moz-animation-duration: 5.5s; + animation-duration: 5.5s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(2) { + left: 120px; + -webkit-animation-duration: 7s; + -moz-animation-duration: 7s; + animation-duration: 7s; +} +#container-snow > div:nth-of-type(3) { + left: 200px; + -webkit-animation-duration: 8s; + -moz-animation-duration: 8s; + animation-duration: 8s; +} +#container-snow > div:nth-of-type(4) { + left: 20%; + -webkit-animation-duration: 6s; + -moz-animation-duration: 6s; + animation-duration: 6s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(5) { + left: 30%; + -webkit-animation-duration: 9s; + -moz-animation-duration: 9s; + animation-duration: 9s; +} +#container-snow > div:nth-of-type(6) { + left: 40%; + -webkit-animation-duration: 7.2s; + -moz-animation-duration: 7.2s; + animation-duration: 7.2s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(7) { + left: 50%; + -webkit-animation-duration: 10s; + -moz-animation-duration: 10s; + animation-duration: 10s; +} +#container-snow > div:nth-of-type(8) { + left: 60%; + -webkit-animation-duration: 6.4s; + -moz-animation-duration: 6.4s; + animation-duration: 6.4s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(9) { + left: 70%; + -webkit-animation-duration: 10s; + -moz-animation-duration: 10s; + animation-duration: 10s; + -webkit-animation-delay: 1.4s; + -moz-animation-delay: 1.4s; + animation-delay: 1.4s; +} +#container-snow > div:nth-of-type(10) { + left: 80%; + -webkit-animation-duration: 8s; + -moz-animation-duration: 8s; + animation-duration: 8s; +} +#container-snow > div:nth-of-type(11) { + left: 90%; + -webkit-animation-duration: 7.1s; + -moz-animation-duration: 7.1s; + animation-duration: 7.1s; + -webkit-animation-delay: 2s; + -moz-animation-delay: 2s; + animation-delay: 2s; +} +#container-snow > div:nth-of-type(12) { + left: 99%; + -webkit-animation-duration: 6.6s; + -moz-animation-duration: 6.6s; + animation-duration: 6.6s; + -webkit-animation-delay: 1.6s; + -moz-animation-delay: 1.6s; + animation-delay: 1.6s; +} +#container-snow > div:nth-of-type(13) { + left: 10px; + -webkit-animation-duration: 10.2s; + -moz-animation-duration: 10.2s; + animation-duration: 10.2s; +} +#container-snow > div:nth-of-type(14) { + left: 180px; + -webkit-animation-duration: 12s; + -moz-animation-duration: 12s; + animation-duration: 12s; +} +#container-snow > div:nth-of-type(15) { + left: 213px; + -webkit-animation-duration: 7.3s; + -moz-animation-duration: 7.3s; + animation-duration: 7.3s; + -webkit-animation-delay: 0.5s; + -moz-animation-delay: 0.5s; + animation-delay: 0.5s; +} +#container-snow > div:nth-of-type(16) { + left: 23%; + -webkit-animation-duration: 9.2s; + -moz-animation-duration: 9.2s; + animation-duration: 9.2s; +} +#container-snow > div:nth-of-type(17) { + left: 38%; + -webkit-animation-duration: 5s; + -moz-animation-duration: 5s; + animation-duration: 5s; +} +#container-snow > div:nth-of-type(18) { + left: 45%; + -webkit-animation-duration: 15s; + -moz-animation-duration: 15s; + animation-duration: 15s; +} +#container-snow > div:nth-of-type(19) { + left: 58%; + -webkit-animation-duration: 5s; + -moz-animation-duration: 5s; + animation-duration: 5s; +} +#container-snow > div:nth-of-type(20) { + left: 64%; + -webkit-animation-duration: 12s; + -moz-animation-duration: 12s; + animation-duration: 12s; +} +#container-snow > div:nth-of-type(21) { + left: 76%; + -webkit-animation-duration: 5.6s; + -moz-animation-duration: 5.6s; + animation-duration: 5.6s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(22) { + left: 86%; + -webkit-animation-duration: 8.5s; + -moz-animation-duration: 8.5s; + animation-duration: 8.5s; +} +#container-snow > div:nth-of-type(23) { + left: 83%; + -webkit-animation-duration: 14.4s; + -moz-animation-duration: 14.4s; + animation-duration: 14.4s; +} +#container-snow > div:nth-of-type(24) { + left: 95%; + -webkit-animation-duration: 12s; + -moz-animation-duration: 12s; + animation-duration: 12s; +} +#container-snow > div:nth-of-type(25) { + left: 55px; + -webkit-animation-duration: 8.7s; + -moz-animation-duration: 8.7s; + animation-duration: 8.7s; + -webkit-animation-delay: 1.2s; + -moz-animation-delay: 1.2s; + animation-delay: 1.2s; +} +#container-snow > div:nth-of-type(26) { + left: 133px; + -webkit-animation-duration: 5.2s; + -moz-animation-duration: 5.2s; + animation-duration: 5.2s; +} +#container-snow > div:nth-of-type(27) { + left: 215px; + -webkit-animation-duration: 10.4s; + -moz-animation-duration: 10.4s; + animation-duration: 10.4s; + -webkit-animation-delay: 1.6s; + -moz-animation-delay: 1.6s; + animation-delay: 1.6s; +} +#container-snow > div:nth-of-type(28) { + left: 26%; + -webkit-animation-duration: 9s; + -moz-animation-duration: 9s; + animation-duration: 9s; +} +#container-snow > div:nth-of-type(29) { + left: 33%; + -webkit-animation-duration: 12s; + -moz-animation-duration: 12s; + animation-duration: 12s; +} +#container-snow > div:nth-of-type(30) { + left: 49%; + -webkit-animation-duration: 9.4s; + -moz-animation-duration: 9.4s; + animation-duration: 9.4s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(31) { + left: 55%; + -webkit-animation-duration: 9.1s; + -moz-animation-duration: 9.1s; + animation-duration: 9.1s; +} +#container-snow > div:nth-of-type(32) { + left: 68%; + -webkit-animation-duration: 9.6s; + -moz-animation-duration: 9.6s; + animation-duration: 9.6s; + -webkit-animation-delay: 0.5s; + -moz-animation-delay: 0.5s; + animation-delay: 0.5s; +} +#container-snow > div:nth-of-type(33) { + left: 73%; + -webkit-animation-duration: 12.4s; + -moz-animation-duration: 12.4s; + animation-duration: 12.4s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(34) { + left: 85%; + -webkit-animation-duration: 9s; + -moz-animation-duration: 9s; + animation-duration: 9s; + -webkit-animation-delay: 1.5s; + -moz-animation-delay: 1.5s; + animation-delay: 1.5s; +} +#container-snow > div:nth-of-type(35) { + left: 93%; + -webkit-animation-duration: 5s; + -moz-animation-duration: 5s; + animation-duration: 5s; +} +#container-snow > div:nth-of-type(36) { + left: 99%; + -webkit-animation-duration: 10.6s; + -moz-animation-duration: 10.6s; + animation-duration: 10.6s; +} +#container-snow > div:nth-of-type(37) { + left: 15px; + -webkit-animation-duration: 9.6s; + -moz-animation-duration: 9.6s; + animation-duration: 9.6s; +} +#container-snow > div:nth-of-type(38) { + left: 99px; + -webkit-animation-duration: 7.5s; + -moz-animation-duration: 7.5s; + animation-duration: 7.5s; +} +#container-snow > div:nth-of-type(39) { + left: 260px; + -webkit-animation-duration: 11s; + -moz-animation-duration: 11s; + animation-duration: 11s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(40) { + left: 28%; + -webkit-animation-duration: 19s; + -moz-animation-duration: 19s; + animation-duration: 19s; +} +#container-snow > div:nth-of-type(41) { + left: 35%; + -webkit-animation-duration: 14s; + -moz-animation-duration: 14s; + animation-duration: 14s; +} +#container-snow > div:nth-of-type(42) { + left: 43%; + -webkit-animation-duration: 5.6s; + -moz-animation-duration: 5.6s; + animation-duration: 5.6s; +} +#container-snow > div:nth-of-type(43) { + left: 53%; + -webkit-animation-duration: 8.8s; + -moz-animation-duration: 8.8s; + animation-duration: 8.8s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(44) { + left: 66%; + -webkit-animation-duration: 16s; + -moz-animation-duration: 16s; + animation-duration: 16s; +} +#container-snow > div:nth-of-type(45) { + left: 78%; + -webkit-animation-duration: 6s; + -moz-animation-duration: 6s; + animation-duration: 6s; +} +#container-snow > div:nth-of-type(46) { + left: 88%; + -webkit-animation-duration: 9.5s; + -moz-animation-duration: 9.5s; + animation-duration: 9.5s; + -webkit-animation-delay: 0.5s; + -moz-animation-delay: 0.5s; + animation-delay: 0.5s; +} +#container-snow > div:nth-of-type(47) { + left: 94%; + -webkit-animation-duration: 7.6s; + -moz-animation-duration: 7.6s; + animation-duration: 7.6s; +} +#container-snow > div:nth-of-type(48) { + left: 96%; + -webkit-animation-duration: 8.2s; + -moz-animation-duration: 8.2s; + animation-duration: 8.2s; + -webkit-animation-delay: 0.3s; + -moz-animation-delay: 0.3s; + animation-delay: 0.3s; +} + +@media (max-width: 600px) { + #container-snow > div:nth-of-type(24) ~ * { + display: none; + } +} + +@media (max-width: 800px) { + #container-snow > div:nth-of-type(36) ~ * { + display: none; + } +} diff --git a/pandora_console/index.php b/pandora_console/index.php index fce3421ffe..ff6f27b152 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1198,8 +1198,18 @@ if ($config['pure'] == 0) { // Menu container prepared to autohide menu. $menuCollapsed = (isset($_SESSION['menu_type']) === true && $_SESSION['menu_type'] !== 'classic'); $menuTypeClass = ($menuCollapsed === true) ? 'collapsed' : 'classic'; + // Snow. + $string = '
+
+
+
+
+
+
+
+
'; // Container. - echo '
'; + echo '
'.$string; // Notifications content wrapper echo ''; @@ -1667,4 +1677,12 @@ require 'include/php_to_js_values.php'; $("#"+this.id+" > .subIcon.cog").addClass("rotation"); }); }); + + // Snow animations. + $(document).ready(function() { + setTimeout(() => { + $("#container-snow").addClass('invisible') ; + }, 30000); + }); + From 1a931c71b4114d4f69aa12bd42cf615d56de676e Mon Sep 17 00:00:00 2001 From: alejandro Date: Thu, 16 Nov 2023 10:10:54 +0100 Subject: [PATCH 101/264] update vmwre md5 code --- .../extras/discovery/DiscoveryApplicationsMigrateCodes.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini b/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini index 1ba02194d2..c0cee7d03f 100644 --- a/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini +++ b/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini @@ -1,4 +1,4 @@ -pandorafms.vmware=54251ae54994c55b478867cd35a98e6c +pandorafms.vmware=248788e0fb2cd4e11623e4a52ee7d05b pandorafms.mysql=fadb4750d18285c0eca34f47c6aa3cfe pandorafms.mssql=1cc215409741d19080269ffba112810e pandorafms.oracle=2d9320a514d1e48a0b2804e1653c31c6 From 863561781567df6bb90a1ec18fe476a1ceba42d9 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Thu, 16 Nov 2023 10:24:03 +0100 Subject: [PATCH 102/264] #12200 The Christmas effect is added after 25 clicks on the about image --- pandora_console/include/functions_menu.php | 3 ++- .../include/javascript/pandora_events.js | 12 ++++++++++++ pandora_console/index.php | 15 +++++++++++---- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index 346dee04b5..ac76541162 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -1328,8 +1328,9 @@ if (is_ajax()) {
- + logo + diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 86b84376c5..4c1364c54c 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -1483,6 +1483,18 @@ function show_dialog(dialog) { }, 50); } +function christmas_click() { + let counter = $("#count_click").val(); + counter++; + $("#count_click").val(counter); + if (counter == 25) { + $("#container-snow").removeClass("invisible"); + setTimeout(() => { + $("#container-snow").addClass("invisible"); + }, 30000); + } +} + /* ############################################################################# ## diff --git a/pandora_console/index.php b/pandora_console/index.php index ff6f27b152..63f063c02d 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1199,7 +1199,7 @@ if ($config['pure'] == 0) { $menuCollapsed = (isset($_SESSION['menu_type']) === true && $_SESSION['menu_type'] !== 'classic'); $menuTypeClass = ($menuCollapsed === true) ? 'collapsed' : 'classic'; // Snow. - $string = '
+ $string = '