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 01/70] 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 3af1981b9360cd09e2ce0c23b021c295d794facd Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Mon, 4 Sep 2023 13:21:57 +0200 Subject: [PATCH 02/70] #11510 Fix agent filter on inventory view --- pandora_console/operation/inventory/inventory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/operation/inventory/inventory.php b/pandora_console/operation/inventory/inventory.php index 536f470fe6..5f57b5f397 100755 --- a/pandora_console/operation/inventory/inventory.php +++ b/pandora_console/operation/inventory/inventory.php @@ -615,8 +615,8 @@ $params['show_helptip'] = true; $params['input_name'] = 'agent'; $params['value'] = $inventory_agent; $params['selectbox_id'] = 'module_inventory_general_view'; -$params['javascript_is_function_select'] = true; -$params['javascript_function_action_after_select'] = 'this.form.submit'; +// $params['javascript_is_function_select'] = true; +// $params['javascript_function_action_after_select'] = 'this.form.submit'; $params['use_hidden_input_idagent'] = true; $params['print_hidden_input_idagent'] = true; $params['hidden_input_idagent_id'] = 'hidden-autocomplete_id_agent'; From 1247b5f69591441ac2bdfa378e2c4014caf1bbe5 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 12 Sep 2023 16:04:13 +0200 Subject: [PATCH 03/70] #11495 Create function for service level data --- pandora_console/include/functions_modules.php | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index e82fca400b..fd8461156c 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4762,3 +4762,98 @@ function export_agents_module_csv($filters) return $result; } + + +/** + * Function to return Mean Time Between Failure, Mean Time To Solution (in seconds) + * and Availability of a module + * + * @param string $interval_start Start time of the interval. + * + * @param string $interval_end End time of the interval. + * + * @param string $id_agentmodule id_agentmodule of the module + * + * @return array Returns an array with the data + */ +function service_level_module_data($interval_start, $interval_end, $id_agentmodule) +{ + $data = []; + $data['mtbf'] = false; + $data['mtrs'] = false; + $data['availability'] = false; + + $interval_time = ($interval_end - $interval_start); + $current_time = time(); + $sql = 'SELECT utimestamp, event_type FROM tevento + WHERE id_agentmodule = '.$id_agentmodule.' + AND utimestamp >= '.$interval_start.' + AND utimestamp <= '.$interval_end.' + ORDER BY utimestamp DESC'; + + $events_time = db_get_all_rows_sql($sql); + if ($events_time !== false && count($events_time) > 0) { + $failed_event = []; + $normal_event = []; + foreach ($events_time as $event) { + if ($event['event_type'] === 'going_up_critical') { + $failed_event[] = $event['utimestamp']; + } + + if ($event['event_type'] === 'going_down_normal') { + $normal_event[] = $event['utimestamp']; + } + } + + $mtrs_array = []; + if (empty($normal_event) === true) { + $mtrs_array[] = ($current_time - $failed_event[0]); + } else if (empty($failed_event) === true) { + $mtrs_array[] = 0; + } else { + foreach ($normal_event as $key => $value) { + if (($failed_event[$key] - $normal_event[$key]) < 0) { + $mtrs_array[] = ($normal_event[$key] - $failed_event[$key]); + } else { + $mtrs_array[] = ($failed_event[$key] - $normal_event[$key]); + } + } + } + + $mtbf_array = []; + if (!empty($failed_event) === true) { + if (count($failed_event) > 1) { + for ($i = 1; $i <= array_key_last($failed_event); $i++) { + $mtbf_array[] = ($failed_event[($i - 1)] - $failed_event[$i]); + } + } else { + $mtbf_array[] = ($current_time - $failed_event[0]); + } + } else { + $mtbf_array[] = 0; + } + + $total_time_failed = array_sum($mtbf_array); + $total_time_ok = ($interval_time - $total_time_failed); + if (count($events_time) === 1) { + if ($events_time[0]['event_type'] === 'going_up_critical') { + $availability = '0'; + } + + if ($events_time[0]['event_type'] === 'going_down_normal') { + $availability = '100'; + } + } else { + $availability = round((($total_time_ok / $interval_time) * 100), 2); + } + + $mtbf = round(( $total_time_failed / count($mtbf_array))); + $mtrs = round((array_sum($mtrs_array) / count($mtrs_array))); + + $data['mtbf'] = $mtbf; + $data['mtrs'] = $mtrs; + $data['availability'] = $availability; + } + + return $data; +} From 6966ebf96b4c4300d4cd17ee91d8e6510e37e0ca Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 13 Sep 2023 10:09:05 +0200 Subject: [PATCH 04/70] #11495 Fix service_level_module_data function --- pandora_console/include/functions_modules.php | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index fd8461156c..410cc036f7 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4768,27 +4768,45 @@ function export_agents_module_csv($filters) * Function to return Mean Time Between Failure, Mean Time To Solution (in seconds) * and Availability of a module * - * @param string $interval_start Start time of the interval. + * @param string $datetime_from Start time of the interval. * - * @param string $interval_end End time of the interval. + * @param string $datetime_to End time of the interval. * * @param string $id_agentmodule id_agentmodule of the module * * @return array Returns an array with the data */ -function service_level_module_data($interval_start, $interval_end, $id_agentmodule) +function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule) { $data = []; $data['mtbf'] = false; $data['mtrs'] = false; $data['availability'] = false; - $interval_time = ($interval_end - $interval_start); + $availability = 0; + + $uncompressed_data = db_uncompress_module_data( + $id_agentmodule, + $datetime_from, + $datetime_to + ); + + $first_utimestamp = 0; + foreach ($uncompressed_data as $data_module) { + foreach ($data_module['data'] as $subdata) { + if (!empty($subdata['datos'])) { + $first_utimestamp = $subdata['utimestamp']; + break; + } + } + } + + $interval_time = ($datetime_to - $datetime_from); $current_time = time(); $sql = 'SELECT utimestamp, event_type FROM tevento WHERE id_agentmodule = '.$id_agentmodule.' - AND utimestamp >= '.$interval_start.' - AND utimestamp <= '.$interval_end.' + AND utimestamp >= '.$datetime_from.' + AND utimestamp <= '.$datetime_to.' ORDER BY utimestamp DESC'; $events_time = db_get_all_rows_sql($sql); @@ -4836,17 +4854,14 @@ function service_level_module_data($interval_start, $interval_end, $id_agentmodu $total_time_failed = array_sum($mtbf_array); $total_time_ok = ($interval_time - $total_time_failed); if (count($events_time) === 1) { - if ($events_time[0]['event_type'] === 'going_up_critical') { - $availability = '0'; - } - - if ($events_time[0]['event_type'] === 'going_down_normal') { - $availability = '100'; + if ((string) $first_utimestamp !== '0') { + $availability = round((($total_time_ok / $interval_time) * 100), 2); } } else { $availability = round((($total_time_ok / $interval_time) * 100), 2); } + // hd($availability, true); $mtbf = round(( $total_time_failed / count($mtbf_array))); $mtrs = round((array_sum($mtrs_array) / count($mtrs_array))); From 8dcace04e7290630474f4daaece400ac19b49f6c Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 13 Sep 2023 10:10:39 +0200 Subject: [PATCH 05/70] #11495 Add service level detailed report --- .../reporting_builder.item_editor.php | 50 +++++++++++++++++++ pandora_console/include/functions_reports.php | 4 ++ 2 files changed, 54 insertions(+) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 6343fabe1d..53be2c1f07 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -591,6 +591,16 @@ switch ($action) { ); break; + case 'service_level': + $description = $item['description']; + $idAgentModule = $item['id_agent_module']; + $idAgent = db_get_value_filter( + 'id_agente', + 'tagente_modulo', + ['id_agente_modulo' => $idAgentModule] + ); + break; + case 'alert_report_module': $description = $item['description']; $idAgentModule = $item['id_agent_module']; @@ -870,6 +880,25 @@ switch ($action) { $idAgentModule = $module; break; + case 'service_level': + $description = $item['description']; + // Decode agents and modules. + $id_agents = json_decode( + io_safe_output(base64_decode($es['id_agents'])), + true + ); + $module = json_decode( + io_safe_output(base64_decode($es['module'])), + true + ); + + $recursion = $item['recursion']; + + $group = $item['id_group']; + $modulegroup = $item['id_module_group']; + $idAgentModule = $module; + break; + case 'alert_report_actions': $description = $item['description']; $es = json_decode($item['external_source'], true); @@ -1035,6 +1064,7 @@ switch ($action) { case 'sumatory': case 'database_serialized': case 'last_value': + case 'service_level': case 'monitor_report': case 'min_value': case 'max_value': @@ -5367,8 +5397,13 @@ $(document).ready (function () { switch (type){ case 'agent_module': case 'agent_module_status': + case 'service_level': case 'alert_report_actions': var agents_multiple = $('#id_agents2').val(); + if (agents_multiple.length == 0) { + dialog_message('#message_no_agent'); + return false; + } var modules_multiple = $('#module').val(); $('#hidden-id_agents2-multiple-text').val(JSON.stringify(agents_multiple)); $('#hidden-module-multiple-text').val(JSON.stringify(modules_multiple)); @@ -5394,6 +5429,7 @@ $(document).ready (function () { case 'agent_configuration': case 'module_histogram_graph': case 'increment': + case 'service_level': if ($("#hidden-id_agent").val() == 0) { dialog_message('#message_no_agent'); return false; @@ -5508,8 +5544,13 @@ $(document).ready (function () { switch (type){ case 'agent_module': case 'agent_module_status': + case 'service_level': case 'alert_report_actions': var agents_multiple = $('#id_agents2').val(); + if (agents_multiple.length == 0) { + dialog_message('#message_no_agent'); + return false; + } var modules_multiple = $('#module').val(); $('#hidden-id_agents2-multiple-text').val(JSON.stringify(agents_multiple)); $('#hidden-module-multiple-text').val(JSON.stringify(modules_multiple)); @@ -5535,6 +5576,7 @@ $(document).ready (function () { case 'agent_configuration': case 'module_histogram_graph': case 'increment': + case 'service_level': if ($("#hidden-id_agent").val() == 0) { dialog_message('#message_no_agent'); return false; @@ -6946,6 +6988,14 @@ function chooseType() { $("#row_agent").show(); $("#row_module").show(); break; + + case 'service_level': + $("#row_description").show(); + $("#row_group").show(); + $("#select_agent_modules").show(); + $("#agents_modules_row").show(); + $("#modules_row").show(); + break; case 'alert_report_module': $("#row_description").show(); diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index f13e935b6a..a450675cd6 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -777,6 +777,10 @@ function reports_get_report_types($template=false, $not_editor=false) 'optgroup' => __('Modules'), 'name' => __('Last value'), ]; + $types['service_level'] = [ + 'optgroup' => __('Modules'), + 'name' => __('Service Level Detailed'), + ]; $types['general'] = [ 'optgroup' => __('Grouped'), From 35b5de57f15e359b9ee3c837be319e4f622a1731 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Wed, 13 Sep 2023 11:12:11 +0200 Subject: [PATCH 06/70] The filter group is added in the Service View Widget settings. --- pandora_console/include/ajax/tree.ajax.php | 3 ++- pandora_console/include/class/Tree.class.php | 6 ++++- .../include/class/TreeService.class.php | 17 +++++++++--- .../include/javascript/pandora_dashboards.js | 2 +- .../include/lib/Dashboard/Widget.php | 1 + .../lib/Dashboard/Widgets/service_view.php | 26 +++++++++++++++++++ 6 files changed, 49 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/ajax/tree.ajax.php b/pandora_console/include/ajax/tree.ajax.php index 319b98e168..e9dbbecd52 100644 --- a/pandora_console/include/ajax/tree.ajax.php +++ b/pandora_console/include/ajax/tree.ajax.php @@ -187,7 +187,8 @@ if (is_ajax() === true) { $serverID, $childrenMethod, $access, - $metaID + $metaID, + $filter['groupID'] ); break; diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index b4a41c494d..41868748f5 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -32,6 +32,8 @@ class Tree protected $rootType = null; + protected $idGroup = null; + protected $id = -1; protected $rootID = -1; @@ -87,13 +89,15 @@ class Tree $serverID=false, $childrenMethod='on_demand', $access='AR', - $id_meta_server=0 + $id_meta_server=0, + $id_group=0 ) { $this->type = $type; $this->rootType = !empty($rootType) ? $rootType : $type; $this->id = $id; $this->rootID = !empty($rootID) ? $rootID : $id; $this->serverID = $serverID; + $this->idGroup = $id_group; if (is_metaconsole() && $id_meta_server == 0) { $this->serverName = metaconsole_get_server_by_id($serverID); } diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php index b30877a5b5..a2f9257d14 100644 --- a/pandora_console/include/class/TreeService.class.php +++ b/pandora_console/include/class/TreeService.class.php @@ -88,7 +88,8 @@ class TreeService extends Tree $serverID=false, $childrenMethod='on_demand', $access='AR', - $id_server_meta=0 + $id_server_meta=0, + $id_group=0 ) { global $config; @@ -105,7 +106,8 @@ class TreeService extends Tree $serverID, $childrenMethod, $access, - $id_server_meta + $id_server_meta, + $id_group ); $this->L1fieldName = 'id_group'; @@ -268,6 +270,13 @@ class TreeService extends Tree $groups_acl = 'AND ts.id_group IN ('.implode(',', $this->userGroupsArray).')'; } + // Filter group. + if ((int) $this->idGroup !== 0) { + $filter_group = 'AND ts.id_group = '.$this->idGroup; + } else { + $filter_group = ''; + } + $exclude_children = 'ts.id NOT IN ( SELECT DISTINCT id_service_child FROM tservice_element @@ -300,11 +309,13 @@ class TreeService extends Tree %s %s %s + %s GROUP BY ts.id', $exclude_children, $is_favourite, $service_search, - $groups_acl + $groups_acl, + $filter_group ); $stats = db_get_all_rows_sql($sql); diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index 79fde538b4..a669b22719 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -1058,7 +1058,7 @@ function processServiceTree(settings) { parameters["filter"]["statusAgent"] = ""; parameters["filter"]["searchModule"] = ""; parameters["filter"]["statusModule"] = ""; - parameters["filter"]["groupID"] = ""; + parameters["filter"]["groupID"] = settings.id_group; parameters["filter"]["tagID"] = ""; parameters["filter"]["searchHirearchy"] = 1; parameters["filter"]["show_not_init_agents"] = 1; diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php index 9bedc71f50..876e8aacc6 100644 --- a/pandora_console/include/lib/Dashboard/Widget.php +++ b/pandora_console/include/lib/Dashboard/Widget.php @@ -642,6 +642,7 @@ class Widget $values = []; $values['title'] = \get_parameter('title', ''); $values['background'] = \get_parameter('background', '#ffffff'); + $values['id_group'] = \get_parameter('id_group', ''); if ((bool) \is_metaconsole() === true) { if ($this->shouldSelectNode() === true) { $values['node'] = \get_parameter('node', null); diff --git a/pandora_console/include/lib/Dashboard/Widgets/service_view.php b/pandora_console/include/lib/Dashboard/Widgets/service_view.php index 7e5607af47..b81fbd67ae 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/service_view.php +++ b/pandora_console/include/lib/Dashboard/Widgets/service_view.php @@ -218,6 +218,10 @@ class ServiceViewWidget extends Widget $values['type'] = $decoder['type']; } + if (isset($decoder['id_group']) === true) { + $values['id_group'] = $decoder['id_group']; + } + return $values; } @@ -239,6 +243,13 @@ class ServiceViewWidget extends Widget $values['type'] = 'tree'; } + // Groups. + $return_all_group = false; + + if (users_can_manage_group_all('AR') === true) { + $return_all_group = true; + } + // Type services view. $fields = [ 'tree' => __('Tree'), @@ -256,6 +267,20 @@ class ServiceViewWidget extends Widget ], ]; + $inputs[] = [ + 'label' => __('Group'), + 'arguments' => [ + 'name' => 'id_group', + 'id' => 'id_group', + 'input_class' => 'flex-row', + 'type' => 'select_groups', + 'returnAllGroup' => $return_all_group, + 'selected' => $values['id_group'], + 'return' => true, + 'class' => 'w50p', + ], + ]; + return $inputs; } @@ -335,6 +360,7 @@ class ServiceViewWidget extends Widget $settings['cellId'] = $this->cellId; $settings['baseURL'] = \ui_get_full_url('/', false, false, false); $settings['ajaxURL'] = \ui_get_full_url('ajax.php', false, false, false); + $settings['id_group'] = (empty($values['type']) === false) ? $values['id_group'] : 0; // Show the modal window of an module. $output .= '
'; From 355de3b9bd4d451bd2fccfa78315f8d205ac9725 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 13 Sep 2023 11:41:41 +0200 Subject: [PATCH 07/70] #11495 Fix service level detail function --- pandora_console/include/functions_modules.php | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 410cc036f7..07690151e4 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4784,6 +4784,7 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule $data['availability'] = false; $availability = 0; + $type = ''; $uncompressed_data = db_uncompress_module_data( $id_agentmodule, @@ -4796,6 +4797,10 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule foreach ($data_module['data'] as $subdata) { if (!empty($subdata['datos'])) { $first_utimestamp = $subdata['utimestamp']; + if (isset($subdata['type'])) { + $type = $subdata['type']; + } + break; } } @@ -4862,8 +4867,19 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule } // hd($availability, true); - $mtbf = round(( $total_time_failed / count($mtbf_array))); - $mtrs = round((array_sum($mtrs_array) / count($mtrs_array))); + if (count($mtbf_array) > 1) { + $mtbf = round(( $total_time_failed / count($mtbf_array))); + } else { + $mtbf = false; + } + + if (count($mtrs_array) === 1 && (string) $first_utimestamp !== '0' && $type === 0) { + $mtrs = round($total_time_failed / count($mtrs_array)); + } else if (count($mtrs_array) > 1 && (string) $first_utimestamp !== '0') { + $mtrs = round((array_sum($mtrs_array) / count($mtrs_array))); + } else { + $mtrs = false; + } $data['mtbf'] = $mtbf; $data['mtrs'] = $mtrs; From 5dcc2704cbd7810ab07584f938adeb8c9b151bd7 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 14 Sep 2023 13:49:56 +0200 Subject: [PATCH 08/70] #11495 Fix service level detailed report --- .../reporting_builder.item_editor.php | 88 +++++++++++++++---- .../godmode/reporting/reporting_builder.php | 32 ++++++- pandora_console/include/functions.php | 26 ++++-- pandora_console/include/functions_modules.php | 78 +++++++++++++++- .../include/functions_reporting.php | 61 +++++++++++++ .../include/functions_reporting_html.php | 81 ++++++++++++++++- 6 files changed, 337 insertions(+), 29 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 53be2c1f07..724c5f6772 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -117,6 +117,8 @@ $exception_condition = REPORT_EXCEPTION_CONDITION_EVERYTHING; $exception_condition_value = 10; $modulegroup = 0; $period = SECONDS_1DAY; +$period_time_service_level = '28800'; +$show_agents = false; $search = ''; $full_text = 0; $log_number = 1000; @@ -591,16 +593,6 @@ switch ($action) { ); break; - case 'service_level': - $description = $item['description']; - $idAgentModule = $item['id_agent_module']; - $idAgent = db_get_value_filter( - 'id_agente', - 'tagente_modulo', - ['id_agente_modulo' => $idAgentModule] - ); - break; - case 'alert_report_module': $description = $item['description']; $idAgentModule = $item['id_agent_module']; @@ -882,6 +874,9 @@ switch ($action) { case 'service_level': $description = $item['description']; + $es = json_decode($item['external_source'], true); + $period_time_service_level = $es['period_time_service_level']; + $show_agents = $es['show_agents']; // Decode agents and modules. $id_agents = json_decode( io_safe_output(base64_decode($es['id_agents'])), @@ -1493,6 +1488,53 @@ if (is_metaconsole() === true) { + + + + + + __('1 week'), + '172800' => __('48 hours'), + '86400' => __('24 hours'), + '43200' => __('12 hours'), + '28800' => __('8 hours'), + + ]; + html_print_select( + $fields_time_service_level, + 'period_time_service_level', + $period_time_service_level, + ); + ?> + + + + + + + + + + + + 0) { - $ret .= "$days days "; + if ($size_text === 'short') { + $ret .= str_replace(' ', '', "$days d").' '; + } else { + $ret .= "$days days "; + } } // get the hours $hours = ((intval($seconds) / 360000) % 24); if ($hours > 0) { - $ret .= "$hours hours "; + if ($size_text === 'short') { + $ret .= str_replace(' ', '', "$hours h").' '; + } else { + $ret .= "$hours hours "; + } } // get the minutes $minutes = ((intval($seconds) / 6000) % 60); if ($minutes > 0) { - $ret .= "$minutes minutes "; + if ($size_text === 'short') { + $ret .= str_replace(' ', '', "$minutes m").' '; + } else { + $ret .= "$minutes minutes "; + } } // get the seconds $seconds = ((intval($seconds) / 100) % 60); if ($seconds > 0) { - $ret .= "$seconds seconds"; + if ($size_text === 'short') { + $ret .= str_replace(' ', '', "$seconds s").' '; + } else { + $ret .= "$seconds seconds "; + } } return $ret; diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 07690151e4..a953d66ac1 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4782,10 +4782,29 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule $data['mtbf'] = false; $data['mtrs'] = false; $data['availability'] = false; + $data['critical_events'] = false; + $data['warning_events'] = false; + $data['last_status_change'] = false; + $data['module_name'] = false; $availability = 0; $type = ''; + if ((bool) is_metaconsole() === true) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_id = []; + $server_id['id'] = explode('|', $id_agentmodule)[0]; + $id_agentmodule = explode('|', $id_agentmodule)[1]; + $server_name = db_get_row_filter('tmetaconsole_setup', $server_id, 'server_name'); + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + // Restore db connection. + metaconsole_restore_db(); + return $data; + } + } + } + $uncompressed_data = db_uncompress_module_data( $id_agentmodule, $datetime_from, @@ -4815,6 +4834,24 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule ORDER BY utimestamp DESC'; $events_time = db_get_all_rows_sql($sql); + + // Count events. + $sql = 'SELECT COUNT(*) as critical_events FROM tevento + WHERE id_agentmodule= '.$id_agentmodule.' + AND utimestamp >= '.$datetime_from.' + AND utimestamp <= '.$datetime_to.' + AND (event_type = "going_up_critical" OR event_type = "going_down_critical")'; + + $critical_events = db_get_sql($sql); + + $sql = 'SELECT COUNT(*) as warning_events FROM tevento + WHERE id_agentmodule= '.$id_agentmodule.' + AND utimestamp >= '.$datetime_from.' + AND utimestamp <= '.$datetime_to.' + AND (event_type = "going_up_warning" OR event_type = "going_down_warning")'; + + $warning_events = db_get_sql($sql); + if ($events_time !== false && count($events_time) > 0) { $failed_event = []; $normal_event = []; @@ -4844,6 +4881,7 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule } $mtbf_array = []; + if (!empty($failed_event) === true) { if (count($failed_event) > 1) { for ($i = 1; $i <= array_key_last($failed_event); $i++) { @@ -4866,9 +4904,8 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule $availability = round((($total_time_ok / $interval_time) * 100), 2); } - // hd($availability, true); - if (count($mtbf_array) > 1) { - $mtbf = round(( $total_time_failed / count($mtbf_array))); + if ($critical_events > 1) { + $mtbf = round(( $total_time_failed / $critical_events)); } else { $mtbf = false; } @@ -4884,6 +4921,41 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule $data['mtbf'] = $mtbf; $data['mtrs'] = $mtrs; $data['availability'] = $availability; + } else { + $data['mtbf'] = false; + $data['mtrs'] = false; + $data['availability'] = false; + } + + // Get last status change. + $sql = 'SELECT last_status_change FROM tagente_estado + WHERE id_agente_modulo = '.$id_agentmodule.' '; + + $last_status_change = db_get_sql($sql); + + // Get module name. + /* + $sql = 'SELECT nombre FROM tagente_modulo + WHERE id_agente_modulo = '.$id_agentmodule;*/ + + $sql = 'SELECT tagente_modulo.nombre as nombre, tagente.alias as alias + FROM tagente_modulo INNER JOIN tagente + ON tagente_modulo.id_agente = tagente.id_agente + WHERE id_agente_modulo = '.$id_agentmodule.' '; + $sql_query = db_get_all_rows_sql($sql); + + $data['critical_events'] = $critical_events; + $data['warning_events'] = $warning_events; + $data['last_status_change'] = $last_status_change; + $data['module_name'] = $sql_query[0]['nombre']; + if ((bool) is_metaconsole() === true) { + $data['agent_alias'] = $server_name['server_name'].' ยป '.$sql_query[0]['alias']; + } else { + $data['agent_alias'] = $sql_query[0]['alias']; + } + + if ((bool) is_metaconsole() === true) { + metaconsole_restore_db(); } return $data; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index ee1f04b952..94585ee455 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -778,6 +778,13 @@ function reporting_make_reporting_data( ); break; + case 'service_level': + $report['contents'][] = reporting_service_level_detail( + $report, + $content + ); + break; + case 'alert_report_actions': $report['contents'][] = reporting_alert_report_actions( $report, @@ -3567,6 +3574,60 @@ function reporting_agent_module_status($report, $content) } +/** + * Service level detail + * + * @param array $report Info Report. + * @param array $content Info content. + * + * @return array + */ +function reporting_service_level_detail($report, $content) +{ + global $config; + $return['type'] = 'service_level'; + + $module_data = []; + $interval_range = []; + $service_level_data = []; + $current_timestamp = time(); + + $return['title'] = io_safe_output($content['name']); + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + + $return['description'] = io_safe_output($content['description']); + $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; + $es = json_decode($content['external_source'], true); + $return['date'] = []; + $return['date']['date'] = false; + $return['date']['period'] = $es['period_time_service_level']; + $return['show_agents'] = $es['show_agents']; + + $modules = json_decode(base64_decode($es['module']), true); + $agents = json_decode(base64_decode($es['id_agents']), true); + $interval_range['start'] = ($current_timestamp - $es['period_time_service_level']); + $interval_range['end'] = $current_timestamp; + + foreach ($modules as $module) { + $service_level_data = service_level_module_data($interval_range['start'], $interval_range['end'], $module); + $module_data[$module] = []; + $module_data[$module]['mtrs'] = ($service_level_data['mtrs'] !== false) ? human_milliseconds_to_string(($service_level_data['mtrs'] * 100), 'short') : '-'; + $module_data[$module]['mtbf'] = ($service_level_data['mtbf'] !== false) ? human_milliseconds_to_string(($service_level_data['mtbf'] * 100), 'short') : '-'; + $module_data[$module]['availability'] = ($service_level_data['availability'] !== false) ? $service_level_data['availability'] : '100'; + $module_data[$module]['warning_events'] = ($service_level_data['warning_events'] !== false) ? $service_level_data['warning_events'] : '0'; + $module_data[$module]['critical_events'] = ($service_level_data['critical_events'] !== false) ? $service_level_data['critical_events'] : '0'; + $module_data[$module]['last_status_change'] = ($service_level_data['last_status_change'] !== false) ? $service_level_data['last_status_change'] : ''; + $module_data[$module]['module_name'] = ($service_level_data['module_name'] !== false) ? $service_level_data['module_name'] : ''; + $module_data[$module]['agent_alias'] = ($service_level_data['agent_alias'] !== false) ? $service_level_data['agent_alias'] : ''; + } + + $return['data'] = $module_data; + + return reporting_check_structure_content($return); +} + + function reporting_exception( $report, $content, diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 719ddfd7a3..cd5e1b5e23 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -260,7 +260,6 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust } $table->colspan['description_row']['description'] = 3; - switch ($item['type']) { case 'availability': default: @@ -403,6 +402,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust reporting_html_agent_module_status($table, $item); break; + case 'service_level': + reporting_html_service_level($table, $item); + break; + case 'alert_report_actions': reporting_html_alert_report_actions($table, $item); break; @@ -2452,6 +2455,82 @@ function reporting_html_agent_module_status($table, $item, $pdf=0) } +function reporting_html_service_level($table, $item, $pdf=0) +{ + global $config; + + $return_pdf = ''; + + if (empty($item['data']) === true) { + if ($pdf !== 0) { + $return_pdf .= __('No items'); + } else { + $table->colspan['group_report']['cell'] = 3; + $table->cellstyle['group_report']['cell'] = 'text-align: center;'; + $table->data['group_report']['cell'] = __('No items'); + } + } else { + $table_info = new stdClass(); + $table_info->width = '99%'; + if ($item['show_agents'] === '1') { + $show_agents = 'on'; + } else { + $show_agents = 'off'; + } + + if ($show_agents === 'on') { + $table_info->head[0] = __('Agent / Module'); + } else { + $table_info->head[0] = __('Module'); + } + + $table_info->head[1] = __('% Av.'); + $table_info->head[2] = __('MTBF'); + $table_info->head[3] = __('MTRS'); + $table_info->head[4] = __('Crit. Events'); + $table_info->head[5] = __('Warn. Events'); + $table_info->head[6] = __('Last change'); + $table_info->data = []; + $row = 0; + + foreach ($item['data'] as $agentmodule_id => $module_data) { + if ($show_agents === 'on') { + $table_info->data[$row][0] = $module_data['agent_alias'].' / '.$module_data['module_name']; + } else { + $table_info->data[$row][0] = $module_data['module_name']; + } + + $table_info->data[$row][1] = $module_data['availability'].'%'; + $table_info->data[$row][2] = $module_data['mtbf']; + $table_info->data[$row][3] = $module_data['mtrs']; + $table_info->data[$row][4] = $module_data['critical_events']; + $table_info->data[$row][5] = $module_data['warning_events']; + if ($module_data['last_status_change'] !== '') { + $table_info->data[$row][6] = date(TIME_FORMAT, $module_data['last_status_change']); + } + + // $table_info->data[$row][6] = date(TIME_FORMAT, $module_data['last_status_change']); + $row++; + } + + if ($pdf !== 0) { + $table_info->title = $item['title']; + $table_info->titleclass = 'title_table_pdf'; + $table_info->titlestyle = 'text-align:left;'; + $return_pdf .= html_print_table($table_info, true); + } else { + $table->colspan['data']['cell'] = 3; + $table->cellstyle['data']['cell'] = 'text-align: center;'; + $table->data['data']['cell'] = html_print_table($table_info, true); + } + } + + if ($pdf !== 0) { + return $return_pdf; + } +} + + /** * Function to print to HTML Exception report. * From 55edc30564a68ea222f40c54a9d70aea330cbf41 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 14 Sep 2023 17:11:00 +0200 Subject: [PATCH 09/70] #12065 fix icons --- .../include/javascript/pandora_events.js | 12 +++++++----- .../include/styles/js/jquery-ui_custom.css | 14 ++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 940fd3ce5d..4ff055a9ae 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -1520,8 +1520,9 @@ $(document).ajaxSend(function(event, jqXHR, ajaxOptions) { // Add the minimize icon to the minimize button $("", { - class: "ui-button-icon ui-icon ui-icon-minusthick", - style: "background-color: #fff;" + class: "ui-button-icon ui-icon", + style: + "background-color: rgb(51, 51, 51); -webkit-mask: url('images/arrow-down-white.png') no-repeat right / contain !important;" }).appendTo(minimizeButton); $("", { @@ -1536,13 +1537,14 @@ $(document).ajaxSend(function(event, jqXHR, ajaxOptions) { "ui-corner-all ui-widget ui-button-icon-only ui-dialog-titlebar-disengage", type: "button", title: "Disengage", - style: "float: right;margin-right: 0.5em; position:relative;" + style: "float: right; position:relative;" }).insertBefore(minimizeButton); // Add the disengage icon to the disengage button $("", { - class: "ui-button-icon ui-icon ui-icon-circle-triangle-n", - style: "background-color: #fff;" + class: "ui-button-icon ui-icon", + style: + "background-color: rgb(51, 51, 51); -webkit-mask: url('images/dashboard.menu.png') no-repeat right / contain !important;" }).appendTo(disengageButton); $("", { diff --git a/pandora_console/include/styles/js/jquery-ui_custom.css b/pandora_console/include/styles/js/jquery-ui_custom.css index 9ee92c54d3..16ee9547f0 100644 --- a/pandora_console/include/styles/js/jquery-ui_custom.css +++ b/pandora_console/include/styles/js/jquery-ui_custom.css @@ -53,7 +53,7 @@ padding: 1px; height: 20px; bottom: 30%; - top: 2em; + top: 5px; background-color: #fff !important; } @@ -62,17 +62,15 @@ } .ui-dialog .ui-dialog-titlebar-disengage { - position: relative; - right: 1.5em; - width: 21px; + position: absolute !important; + right: 60px; + top: 5px; + width: 25px; margin: 0px 0 0 0; padding: 1px; - height: 20px; + height: 25px; bottom: 30%; background-color: #fff !important; - -ms-transform: scale(1.2); - -webkit-transform: scale(1.2); - transform: scale(1.2); } .ui-dialog .ui-dialog-titlebar-disengage:hover { From c9966ed9999947744e1c52eeb6add9bc8f9b0312 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 11 Oct 2023 16:16:22 +0200 Subject: [PATCH 10/70] #12132 Limit tips --- pandora_console/include/javascript/tipsWindow.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/javascript/tipsWindow.js b/pandora_console/include/javascript/tipsWindow.js index 94d28c9339..c68e7c9b05 100644 --- a/pandora_console/include/javascript/tipsWindow.js +++ b/pandora_console/include/javascript/tipsWindow.js @@ -134,8 +134,9 @@ function render_counter() { $(".counter-tips img:eq(0)").after( "" ); + var limitRound = totalTips > 28 ? 28 : totalTips; if (totalTips > 1) { - for (let i = 1; i <= totalTips - 1; i++) { + for (let i = 1; i <= limitRound - 1; i++) { $(".count-round-tip:eq(0)").after( "" ); From a456912dd7457fdd39284c965755a6b667c5b297 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Mon, 16 Oct 2023 12:17:42 +0200 Subject: [PATCH 11/70] #12132 Fix welcome tips --- pandora_console/extras/mr/68.sql | 7 +++++++ pandora_console/include/class/TipsWindow.class.php | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 pandora_console/extras/mr/68.sql diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql new file mode 100644 index 0000000000..3095941187 --- /dev/null +++ b/pandora_console/extras/mr/68.sql @@ -0,0 +1,7 @@ +START TRANSACTION; + +DELETE FROM `twelcome_tip` WHERE `title` = 'Automatic agent provision system'; + +INSERT INTO `twelcome_tip` (`id_lang`,`id_profile`,`title`,`text`,`url`,`enable`) VALUES ('en_GB',0,'Automatic agent provision system','The agent self-provisioning system allows an agent recently entered into the system to automatically apply changes to their configuration (such as moving them from group, assigning them certain values in custom fields) and of course applying certain monitoring policies. It is one of the most powerful functionalities, aimed at managing very large system parks.','https://pandorafms.com/manual/start?id=en/documentation/02_installation/05_configuration_agents#conf',1); + +COMMIT; \ No newline at end of file diff --git a/pandora_console/include/class/TipsWindow.class.php b/pandora_console/include/class/TipsWindow.class.php index ae4271fba9..56082611ea 100644 --- a/pandora_console/include/class/TipsWindow.class.php +++ b/pandora_console/include/class/TipsWindow.class.php @@ -744,7 +744,7 @@ class TipsWindow ); $table->data[1][1] = html_print_label_input_block( __('Url'), - html_print_input_text('url', '', '', 35, 100, true) + html_print_input_text('url', '', '', 35, 255, true) ); $table->data[2][0] = html_print_label_input_block( __('Text'), @@ -911,7 +911,7 @@ class TipsWindow ); $table->data[1][1] = html_print_label_input_block( __('Url'), - html_print_input_text('url', $tip['url'], '', 35, 100, true) + html_print_input_text('url', $tip['url'], '', 35, 255, true) ); $table->data[2][0] = html_print_label_input_block( __('Text'), From 202ad6f4f82eeba583b206184fbc87d682f51ae8 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 23 Oct 2023 10:54:06 +0200 Subject: [PATCH 12/70] #12270 widget min height --- pandora_console/include/styles/dashboards.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css index 2cda2de6f4..af3c2a7868 100644 --- a/pandora_console/include/styles/dashboards.css +++ b/pandora_console/include/styles/dashboards.css @@ -148,7 +148,7 @@ h1 { cursor: pointer; } #modal-add-widget { - min-height: 566px !important; + min-height: 625px !important; } #modal-add-widget .container-list-widgets { display: flex; From 76c6567432848e33ee91ebf1f106d6053c4ae6cb Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 25 Oct 2023 11:10:55 +0200 Subject: [PATCH 13/70] #8635 massive ncm add --- pandora_console/include/styles/ncm.css | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/pandora_console/include/styles/ncm.css b/pandora_console/include/styles/ncm.css index 332d891431..2ed71d3338 100644 --- a/pandora_console/include/styles/ncm.css +++ b/pandora_console/include/styles/ncm.css @@ -1,10 +1,3 @@ -span.select2.select2-container.select2-container--default { - max-width: 175px !important; - width: 175px !important; -} - -.edit_discovery_input b { - display: flex; - flex-direction: row; - align-items: center; +.select2-selection__rendered { + max-width: 600px; } From f00ac9ea896a7a9eb8fc0e0a51f3042c4cb112a6 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Thu, 26 Oct 2023 12:19:42 +0200 Subject: [PATCH 14/70] #8365 added donut icon in svg --- pandora_console/images/donut.svg | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 pandora_console/images/donut.svg diff --git a/pandora_console/images/donut.svg b/pandora_console/images/donut.svg new file mode 100644 index 0000000000..67c8733d33 --- /dev/null +++ b/pandora_console/images/donut.svg @@ -0,0 +1,7 @@ + + + donut + + + + \ No newline at end of file From 90249d463116db8014ce1dc78e5b202699ffec9f Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 26 Oct 2023 12:49:30 +0200 Subject: [PATCH 15/70] #8365 NCM add backup id to ncm queue --- pandora_console/extras/mr/67.sql | 7 +++++++ 1 file changed, 7 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..aa44ceea56 --- /dev/null +++ b/pandora_console/extras/mr/67.sql @@ -0,0 +1,7 @@ +START TRANSACTION; + +ALTER TABLE `tncm_queue` +ADD COLUMN `id_agent_data` INT NOT NULL DEFAULT 0 AFTER `id_script`; + + +COMMIT; \ No newline at end of file From 407a505a3e2f20bf185364cc89c90fae6a4e60d3 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Fri, 27 Oct 2023 14:32:48 +0200 Subject: [PATCH 16/70] #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 17/70] #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 18/70] #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 19/70] #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 20/70] #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 21/70] #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 22/70] #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 23/70] #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 24/70] #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 25/70] 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 26/70] 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 27/70] 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 28/70] 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 29/70] 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 30/70] #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 3506ba1b5a3e6ffe37beb33f0d72d6b65c0bb5bd Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Mon, 6 Nov 2023 15:06:16 +0100 Subject: [PATCH 31/70] 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 32/70] 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 33/70] 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 34/70] 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 194a3ca8c4668d73dceb3f2d472b8d6a56c3fb8e Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 7 Nov 2023 12:36:05 +0100 Subject: [PATCH 35/70] #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 36/70] 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 37/70] #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 38/70] #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 98bc73a83ab0b6308703b90132187392a9a8e2ae Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Wed, 8 Nov 2023 14:40:47 +0100 Subject: [PATCH 39/70] #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 ad90fb74b2b3615cbb2be60ba5bc08b0e2a8e752 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 13 Nov 2023 10:42:25 +0100 Subject: [PATCH 40/70] #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 58aeb59b2c1adc4fc769692107137ccf6844ce03 Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Fri, 17 Nov 2023 10:22:52 +0100 Subject: [PATCH 41/70] Updated MR --- pandora_console/extras/mr/67.sql | 2 +- pandora_console/pandoradb_data.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index 2913cd8248..307228f4cb 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -182,7 +182,7 @@ 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_get_config = 'expect:root@% cli\n expect:root> capture:show configuration | no-more\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'; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 123940c22e..1552d16a4c 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2553,7 +2553,7 @@ INSERT INTO `tncm_script` VALUES (12,5,''), (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'), + (15,1,'expect:root@% cli\n expect:root> capture:show configuration | no-more\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'), From d84937e6c9a4e8391ac06459820fec3c8cfc8e9c Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Fri, 17 Nov 2023 12:24:07 +0100 Subject: [PATCH 42/70] Added snippet script to MR and pandoradb_data.sql --- pandora_console/extras/mr/67.sql | 5 +++++ pandora_console/pandoradb_data.sql | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index 307228f4cb..76a2619e00 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -32,6 +32,11 @@ ADD COLUMN `agent_data_event_on_change` INT UNSIGNED NULL DEFAULT NULL AFTER `ev ALTER TABLE `treport_content` ADD COLUMN `ncm_agents` MEDIUMTEXT NULL AFTER `status_of_check`; +-- Add needed snippet script to queue tasks. +SET @type_snippet = 6; +SELECT @id_snippet := `id` FROM `tncm_script` WHERE `type` = @type_snippet; +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_snippet, @type_snippet, 'snippet'); + -- Add new vendor and model SET @vendor_name = 'Cisco'; SET @model_name = 'Cisco-Generic'; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 1552d16a4c..f7f5c5da08 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2593,7 +2593,8 @@ INSERT INTO `tncm_script` VALUES (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,'sleep:1 capture:/system package print\n\r exit\n\r'); + (55,7,'sleep:1 capture:/system package print\n\r exit\n\r'), + (56,6,'snippet'); INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1), From 6fc6bead65c7d29276f12db5e6d115197bc46124 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 21 Nov 2023 16:17:41 +0100 Subject: [PATCH 43/70] #12483 Fixed custom fields view --- .../include/styles/custom_field.css | 85 +++++++++++++++++++ pandora_console/include/styles/pandora.css | 22 +---- .../custom_fields/custom_fields_view.php | 64 +++++--------- 3 files changed, 109 insertions(+), 62 deletions(-) create mode 100644 pandora_console/include/styles/custom_field.css diff --git a/pandora_console/include/styles/custom_field.css b/pandora_console/include/styles/custom_field.css new file mode 100644 index 0000000000..fcb12d492f --- /dev/null +++ b/pandora_console/include/styles/custom_field.css @@ -0,0 +1,85 @@ +/** + * + * Name: Default theme + * Pandora Stylesheet + * + * @category Stylesheet + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ + +.dt-buttons { + float: left; +} + +.dt-button.buttons-csv.buttons-html5 { + box-shadow: none; +} + +.dataTables_filter > label { + color: #000; +} + +.top { + background-color: #fff !important; + color: #000 !important; + border-radius: 5px !important; + border: 1px solid #e5e9ed !important; +} + +.bottom { + background-color: #fff !important; + color: #000 !important; + border-radius: 5px !important; + border: 1px solid #e5e9ed !important; +} + +.dataTables_wrapper .dataTables_paginate .paginate_button.disabled, +.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover, +.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:active { + color: #000 !important; +} + +.dataTables_wrapper .dataTables_paginate .paginate_button.current, +.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover { + color: #fff !important; + background: #14524f !important; +} + +.dataTables_wrapper .dataTables_paginate .paginate_button { + background-color: #f6f7fb !important; + color: #000 !important; + border: 1px solid #cacaca; +} + +.dataTables_wrapper .dataTables_paginate .paginate_button:hover { + background: #e2e2e2 !important; + color: #000 !important; +} + +.dataTables_wrapper .dataTables_paginate .paginate_button.next { + border: 1px solid #cacaca !important; +} + +.dataTables_wrapper .dataTables_paginate .paginate_button.previous { + border: 1px solid #cacaca !important; +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 7c740bba2b..e5e92fea81 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12547,9 +12547,10 @@ form.cfv_status_agent input:checked + label:before { float: left; margin-left: 10px; padding-right: 10px; - max-height: 890px; + max-height: 760px; overflow: auto; background-color: #f9f9f9; + margin-bottom: 20px; } .agents_custom_fields { @@ -12558,15 +12559,6 @@ form.cfv_status_agent input:checked + label:before { margin-bottom: 15px; padding: 25px 5px; } -div.agents_custom_fields #datatables_wrapper div.top, -div.agents_custom_fields #datatables_wrapper div.bottom { - background-color: #414141; - color: #ffffff; - border: none; - padding: 5px; - height: 38px; - width: 99%; -} /*Horizontal tree*/ @@ -12597,16 +12589,6 @@ div.agents_custom_fields #datatables_wrapper div.bottom { margin-top: 15px; } -.custom_fields_view { - width: 30%; - float: left; - margin-left: 10px; - padding-right: 10px; - max-height: 890px; - overflow: auto; - background-color: #f9f9f9; -} - .agents_custom_fields { width: 100%; diff --git a/pandora_console/operation/custom_fields/custom_fields_view.php b/pandora_console/operation/custom_fields/custom_fields_view.php index bd95ab26fd..83d35533c7 100644 --- a/pandora_console/operation/custom_fields/custom_fields_view.php +++ b/pandora_console/operation/custom_fields/custom_fields_view.php @@ -67,12 +67,12 @@ $info_user = get_user_info($config['id_user']); $group = get_parameter('group', 0); $id_custom_fields = get_parameter('id_custom_fields', 0); $id_custom_fields_data = get_parameter('id_custom_fields_data', -1); -$id_status = get_parameter('id_status', AGENT_MODULE_STATUS_NOT_NORMAL); +$id_status = get_parameter('id_status', -1); $module_search = get_parameter('module_search', ''); $search = get_parameter('uptbutton', ''); $id_filter = get_parameter('id_name', 0); $recursion = get_parameter('recursion', 0); -$module_status = get_parameter('module_status', AGENT_MODULE_STATUS_NOT_NORMAL); +$module_status = get_parameter('module_status', -1); // ===================================================================== // Custom filter search @@ -304,21 +304,12 @@ $table->data[2][5] = html_print_submit_button( ); if (check_acl($config['id_user'], 0, 'PM')) { - // Pass the parameters to the page that generates the csv file (arrays) + // Pass the parameters to the page that generates the csv file (arrays). $decode_id_status = base64_encode(json_encode($id_status)); $decode_module_status = base64_encode(json_encode($module_status)); $decode_filters = base64_encode(json_encode($filters)); $table->data[3][5] = '
'; - /* - $table->data[3][5] .= html_print_button( - __('Export to CSV'), - 'csv_export', - false, - "blockResubmit($(this)); location.href='monitoring/custom_fields_csv.php?filters=$decode_filters&id_custom_field=$id_custom_fields&id_status=$decode_id_status&module_status=$decode_module_status'", - 'class="sub next"', - true - );*/ $table->data[3][5] .= '
'; } @@ -367,12 +358,13 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { $id_custom_field_array = $filters['id_custom_fields_data']; } - foreach ($id_custom_field_array as $value) { - /* - $table_agent = html_get_predefined_table(); - $table_agent->style = []; - $table_agent->class = 'tactical_view';*/ + $id_field = db_get_value_filter( + 'id_field', + 'tagent_custom_fields', + ['name' => $id_custom_fields] + ); + foreach ($id_custom_field_array as $value) { $table_agent = new StdClass(); $table_agent->width = '100%'; $table_agent->class = 'tactical_view'; @@ -388,7 +380,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { true, ['title' => __('Agents critical')] ); - $agent_data[1] = ""; + $agent_data[1] = ""; $agent_data[1] .= ""; $agent_data[1] .= format_numeric( $data['counters_name'][$value]['a_critical'] @@ -401,7 +393,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { true, ['title' => __('Agents warning')] ); - $agent_data[3] = ""; + $agent_data[3] = ""; $agent_data[3] .= ""; $agent_data[3] .= format_numeric( $data['counters_name'][$value]['a_warning'] @@ -414,7 +406,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { true, ['title' => __('Agents ok')] ); - $agent_data[5] = ""; + $agent_data[5] = ""; $agent_data[5] .= ""; $agent_data[5] .= format_numeric( $data['counters_name'][$value]['a_normal'] @@ -427,7 +419,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { true, ['title' => __('Agents unknown')] ); - $agent_data[7] = ""; + $agent_data[7] = ""; $agent_data[7] .= ""; $agent_data[7] .= format_numeric( $data['counters_name'][$value]['a_unknown'] @@ -440,7 +432,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { true, ['title' => __('Agents not init')] ); - $agent_data[9] = ""; + $agent_data[9] = ""; $agent_data[9] .= ""; $agent_data[9] .= format_numeric( $data['counters_name'][$value]['a_not_init'] @@ -455,12 +447,6 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { $m_unknown = ($data['counters_name'][$value]['m_unknown'] <= 0) ? '0' : $data['counters_name'][$value]['m_unknown']; $m_not_init = ($data['counters_name'][$value]['m_not_init'] <= 0) ? '0' : $data['counters_name'][$value]['m_not_init']; - // Modules by status table. - /* - $table_mbs = html_get_predefined_table(); - $table_mbs->class = 'tactical_view'; - $table_mbs->style = [];*/ - $table_mbs = new StdClass(); $table_mbs->width = '100%'; $table_mbs->class = 'tactical_view'; @@ -478,7 +464,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { false, true ); - $tdata[1] = ''.$m_critical.''; + $tdata[1] = ''.$m_critical.''; $tdata[2] = html_print_image( 'images/module_warning.png', @@ -489,7 +475,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { false, true ); - $tdata[3] = ''.$m_warning.''; + $tdata[3] = ''.$m_warning.''; $tdata[4] = html_print_image( 'images/module_ok.png', @@ -500,7 +486,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { false, true ); - $tdata[5] = ''.$m_normal.''; + $tdata[5] = ''.$m_normal.''; $tdata[6] = html_print_image( 'images/module_unknown.png', @@ -511,7 +497,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { false, true ); - $tdata[7] = ''.$m_unknown.''; + $tdata[7] = ''.$m_unknown.''; $tdata[8] = html_print_image( 'images/module_notinit.png', @@ -523,7 +509,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { true ); - $tdata[9] = ''.$m_not_init.''; + $tdata[9] = ''.$m_not_init.''; $table_mbs->data[] = $tdata; @@ -714,7 +700,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { echo ''; echo "
"; - echo ""; + echo "
"; echo ''; echo ''; echo ''; @@ -755,6 +741,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { echo ''; ui_require_css_file('datatables.min', 'include/styles/js/'); +ui_require_css_file('custom_field', 'include/styles/'); ui_require_javascript_file_enterprise('functions_csv'); ui_require_javascript_file('datatables.min'); ui_require_javascript_file('buttons.dataTables.min'); @@ -904,7 +891,6 @@ function dialog_filter_cf(title, type_form){ } function table_datatables(filters, indexed_descriptions, processing){ - console.log(indexed_descriptions); array_data = JSON.parse(filters); table = $('#datatables').DataTable({ processing: true, @@ -913,7 +899,6 @@ function table_datatables(filters, indexed_descriptions, processing){ searching: true, pageLength: Number(array_data.block_size), lengthMenu: [ 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 75, 100], - //buttons: [{ extend: 'csvHtml5', text: 'Save as csvHtml5' }], responsive: false, ajax: { type: "POST", @@ -933,21 +918,16 @@ function table_datatables(filters, indexed_descriptions, processing){ 'paging': true, 'ordering': true, 'scrollX': true, - 'scroller': true + 'scroller': true, }, }, language: { processing: processing, lengthMenu: "Show _MENU_ items per page", zeroRecords: "Nothing found. Please change your search term", - //info: "Page _PAGE_ of _PAGES_", infoEmpty: "No results", infoFiltered: "", search: "Search:", - /*paginate:{ - next: "Next", - previous: "Next" - }*/ }, sDom: '<"top"lfp>rt<"bottom"ip><"clear">', columns: [ From 0a9e1275765d39dc09094651754a6bbe4b230437 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 22 Nov 2023 16:12:37 +0100 Subject: [PATCH 44/70] #8365 NCM v3 snipets --- pandora_console/extras/mr/67.sql | 3 +++ pandora_console/pandoradb.sql | 1 + 2 files changed, 4 insertions(+) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index 76a2619e00..565882214a 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -3,6 +3,9 @@ START TRANSACTION; ALTER TABLE `tncm_queue` ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`; +ALTER TABLE `tncm_queue` +ADD COLUMN `snipet` TEXT NULL AFTER `scheduled`; + CREATE TABLE IF NOT EXISTS `tncm_agent_data_template` ( `id` SERIAL, `name` TEXT, diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 334afe02b2..aeb33e9a10 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4270,6 +4270,7 @@ CREATE TABLE IF NOT EXISTS `tncm_queue` ( `id_agent_data` bigint unsigned, `utimestamp` INT UNSIGNED NOT NULL, `scheduled` INT UNSIGNED DEFAULT NULL, + `snipet` TEXT 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 ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; From a277e56672b1875ddc8fefac9b2f9bb2d7f61af8 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 22 Nov 2023 16:47:13 +0100 Subject: [PATCH 45/70] #8365 NCM v3 rename snipet to snippet --- pandora_console/extras/mr/67.sql | 2 +- pandora_console/pandoradb.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index 565882214a..00a357d18a 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -4,7 +4,7 @@ ALTER TABLE `tncm_queue` ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`; ALTER TABLE `tncm_queue` -ADD COLUMN `snipet` TEXT NULL AFTER `scheduled`; +ADD COLUMN `snippet` TEXT NULL AFTER `scheduled`; CREATE TABLE IF NOT EXISTS `tncm_agent_data_template` ( `id` SERIAL, diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index aeb33e9a10..d009554cc6 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4270,7 +4270,7 @@ CREATE TABLE IF NOT EXISTS `tncm_queue` ( `id_agent_data` bigint unsigned, `utimestamp` INT UNSIGNED NOT NULL, `scheduled` INT UNSIGNED DEFAULT NULL, - `snipet` TEXT NULL, + `snippet` TEXT 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 ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; From 51e07930ed16d37bdb246c6a42266dccae54f00a Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 23 Nov 2023 09:51:12 +0100 Subject: [PATCH 46/70] #11495 Align text left --- pandora_console/include/functions_reporting_html.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 71bf7afbc3..e67bd2b173 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2797,13 +2797,16 @@ function reporting_html_service_level($table, $item, $pdf=0) $table_info->head[5] = __('Warn. Events'); $table_info->head[6] = __('Last change'); $table_info->data = []; + $table_info->cellstyle = []; $row = 0; foreach ($item['data'] as $agentmodule_id => $module_data) { if ($show_agents === 'on') { $table_info->data[$row][0] = $module_data['agent_alias'].' / '.$module_data['module_name']; + $table_info->cellstyle[$row][0] = 'text-align:left; padding-left: 30px;'; } else { $table_info->data[$row][0] = $module_data['module_name']; + $table_info->cellstyle[$row][0] = 'text-align:left; padding-left: 30px;'; } $table_info->data[$row][1] = $module_data['availability'].'%'; From 3d3cbd5e96a2b3404dacc1b439d2b63fcbfee290 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 27 Nov 2023 09:39:56 +0100 Subject: [PATCH 47/70] 9753 Fixed group list --- pandora_console/godmode/groups/modu_group_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/groups/modu_group_list.php b/pandora_console/godmode/groups/modu_group_list.php index 560de898e9..a8f7930b26 100644 --- a/pandora_console/godmode/groups/modu_group_list.php +++ b/pandora_console/godmode/groups/modu_group_list.php @@ -154,7 +154,7 @@ if ($is_management_allowed === true && $update_group === true) { $subcheck = db_get_value('name', 'tmodule_group', 'id_mg', $id_group); if ($name) { - if (!$check || $subcheck == $name) { + if ($check === false || strcasecmp($subcheck, $name) === 0) { $result = db_process_sql_update( 'tmodule_group', ['name' => $name], From e7ebbedabc2f6188def055435810ad5f020eb770 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 28 Nov 2023 09:34:10 +0100 Subject: [PATCH 48/70] #12176 formatted error --- .../wizards/DiscoveryTaskList.class.php | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index e831022c23..0872b52e88 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -1474,13 +1474,20 @@ class DiscoveryTaskList extends HTML } else if ((int) $task['type'] === DISCOVERY_EXTENSION) { // Content. $countSummary = 1; + $countErrors = 1; + $tableErrors = new StdClasS(); + $tableErrors->class = 'databox data'; + $tableErrors->width = '75%'; + $tableErrors->styleTable = 'margin: 2em auto 0;border: 1px solid #ddd;background: white;'; + $tableErrors->rowid = []; + $tableErrors->data = []; if (is_array($task['stats']) === true && count(array_filter(array_keys($task['stats']), 'is_numeric')) === count($task['stats'])) { foreach ($task['stats'] as $key => $summary) { - $table->data[$i][0] = ''.__('Summary').' '.$countSummary.''; - $table->data[$i][1] = ''; - $countSummary++; - $i++; if (is_array($summary) === true) { + $table->data[$i][0] = ''.__('Summary').' '.$countSummary.''; + $table->data[$i][1] = ''; + $countSummary++; + $i++; if (empty($summary['summary']) === true && empty($summary['info']) === true) { $table->data[$i][0] = json_encode($summary, JSON_PRETTY_PRINT); $table->data[$i][1] = ''; @@ -1517,8 +1524,12 @@ class DiscoveryTaskList extends HTML $i++; } } else { - $table->data[$i][0] = $summary; - $table->data[$i][1] = ''; + $tableErrors->data[$i][0] = ''.__('Error %s', $countErrors).''; + $tableErrors->data[$i][1] = ''; + $i++; + $tableErrors->data[$i][0] = $summary; + $tableErrors->data[$i][1] = ''; + $countErrors++; $i++; } } @@ -1565,7 +1576,15 @@ class DiscoveryTaskList extends HTML } $output = '
'.__('Summary').'
'; - $output .= html_print_table($table, true).''; + if (is_array($table->data) === true && count($table->data) > 0) { + $output .= html_print_table($table, true); + } + + if (is_array($tableErrors->data) === true && count($tableErrors->data) > 0) { + $output .= html_print_table($tableErrors, true); + } + + $output .= ''; } return $output; From 4ce47cec8ebb2870c2ae8aa5c07d36edefc80eed Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 28 Nov 2023 09:56:51 +0100 Subject: [PATCH 49/70] #12176 control error legacy --- .../wizards/DiscoveryTaskList.class.php | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index 0872b52e88..d088e8c84f 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -1422,6 +1422,14 @@ class DiscoveryTaskList extends HTML $table->rowid = []; $table->data = []; + $countErrors = 1; + $tableErrors = new StdClasS(); + $tableErrors->class = 'databox data'; + $tableErrors->width = '75%'; + $tableErrors->styleTable = 'margin: 2em auto 0;border: 1px solid #ddd;background: white;'; + $tableErrors->rowid = []; + $tableErrors->data = []; + if ($task['review_mode'] == DISCOVERY_RESULTS) { $agents_review = db_get_all_rows_filter( 'tdiscovery_tmp_agents', @@ -1474,13 +1482,6 @@ class DiscoveryTaskList extends HTML } else if ((int) $task['type'] === DISCOVERY_EXTENSION) { // Content. $countSummary = 1; - $countErrors = 1; - $tableErrors = new StdClasS(); - $tableErrors->class = 'databox data'; - $tableErrors->width = '75%'; - $tableErrors->styleTable = 'margin: 2em auto 0;border: 1px solid #ddd;background: white;'; - $tableErrors->rowid = []; - $tableErrors->data = []; if (is_array($task['stats']) === true && count(array_filter(array_keys($task['stats']), 'is_numeric')) === count($task['stats'])) { foreach ($task['stats'] as $key => $summary) { if (is_array($summary) === true) { @@ -1571,7 +1572,13 @@ class DiscoveryTaskList extends HTML $table->data[$i++][1] .= ''; } } else { - $table->data[$i][0] = $task['stats']['summary']; + $tableErrors->data[$i][0] = ''.__('Error %s', $countErrors).''; + $tableErrors->data[$i][1] = ''; + $i++; + $tableErrors->data[$i][0] = $task['stats']['summary']; + $tableErrors->data[$i][1] = ''; + $countErrors++; + $i++; } } From 63945df5fdfbd7263fc33bbe94e2e27e974df8e6 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 29 Nov 2023 09:44:25 +0100 Subject: [PATCH 50/70] #11495 Add tip and fix MTRS bug --- pandora_console/include/functions_modules.php | 4 ++++ pandora_console/include/functions_reporting_html.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 52ce97df12..c3a1eb1ff4 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4872,6 +4872,10 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule $mtrs_array[] = 0; } else { foreach ($normal_event as $key => $value) { + if (isset($failed_event[$key]) === false) { + $failed_event[$key] = end($failed_event); + } + if (($failed_event[$key] - $normal_event[$key]) < 0) { $mtrs_array[] = ($normal_event[$key] - $failed_event[$key]); } else { diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index e67bd2b173..e7eef0ae46 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2793,8 +2793,8 @@ function reporting_html_service_level($table, $item, $pdf=0) $table_info->head[1] = __('% Av.'); $table_info->head[2] = __('MTBF'); $table_info->head[3] = __('MTRS'); - $table_info->head[4] = __('Crit. Events'); - $table_info->head[5] = __('Warn. Events'); + $table_info->head[4] = __('Crit. Events').ui_print_help_tip(__('Counted only critical events generated automatic by the module'), true); + $table_info->head[5] = __('Warn. Events').ui_print_help_tip(__('Counted only warning events generated automatic by the module'), true); $table_info->head[6] = __('Last change'); $table_info->data = []; $table_info->cellstyle = []; From 892048554e60fb688281297ffd825a23d295585e Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 29 Nov 2023 10:27:55 +0100 Subject: [PATCH 51/70] #12468 Fixed instructions --- pandora_console/include/functions_events.php | 7 +++---- pandora_console/operation/events/events.php | 14 +------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 2a91641315..253749ce8e 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -5775,7 +5775,7 @@ function events_get_field_value_by_event_id( } -function events_get_instructions($event) +function events_get_instructions($event, $max_text_length=300) { if (is_array($event) === false) { return ''; @@ -5823,17 +5823,17 @@ function events_get_instructions($event) return ''; } - $max_text_length = 300; $over_text = io_safe_output($value); if (strlen($over_text) > ($max_text_length + 3)) { $over_text = substr($over_text, 0, $max_text_length).'...'; + } else { + return $value; } $output = '
'; $output .= ''; $output .= ''; @@ -5842,7 +5842,6 @@ function events_get_instructions($event) true, ['title' => $over_text] ).''; - $output .= ''; return $output; } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 4bddd880c5..467f8dafd8 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -644,19 +644,7 @@ if (is_ajax() === true) { $tmp->data = ui_print_truncate_text($tmp->data, 10); } - $tmp->instructions = events_get_instructions($item); - if (strlen($tmp->instructions) >= 20) { - $tmp->instructions = ui_print_truncate_text( - $tmp->instructions, - 20, - false, - true, - false, - '…', - true, - true, - ); - } + $tmp->instructions = events_get_instructions($item, 15); $tmp->user_comment = ui_print_comments( event_get_last_comment( From db89c72be577bf4fcae03d7c717e6f337c9256cb Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 29 Nov 2023 16:00:46 +0100 Subject: [PATCH 52/70] fix error empty clusters pandora_enterprise#12511 --- .../godmode/agentes/agent_manager.php | 27 +++++++++++++++-- pandora_console/include/functions_agents.php | 29 +++++++++++++++++-- pandora_console/include/lib/Cluster.php | 4 +++ pandora_console/views/cluster/view.php | 6 +++- 4 files changed, 60 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 557b855e09..a7f979180a 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -1104,11 +1104,24 @@ if ($new_agent === false) { $actionButtons .= html_print_input_hidden('id_agente', $id_agente); if (is_management_allowed() === true) { + $clusters = agents_get_agent_belongs_cluster($id_agente); + $cluster_belongs = ''; + if (empty($clusters) === false) { + $clusters = array_reduce( + $clusters, + function ($carry, $item) { + $carry[] = $item['name']; + return $carry; + } + ); + $cluster_belongs = implode(', ', $clusters); + } + $actionButtons .= html_print_button( __('Delete agent'), 'deleteAgent', false, - 'deleteAgentDialog('.$id_agente.')', + 'deleteAgentDialog('.$id_agente.', "'.$cluster_belongs.'")', [ 'icon' => 'delete', 'mode' => 'secondary dialog_opener', @@ -1156,10 +1169,18 @@ ui_require_jquery_file('bgiframe'); } } - function deleteAgentDialog($idAgente) { + function deleteAgentDialog($idAgente, cluster) { + var msg_cluster = ''; + if(cluster) { + msg_cluster = ""; + msg_cluster += ': '; + msg_cluster += cluster; + msg_cluster += '. '; + } + confirmDialog({ title: "", - message: "", + message: msg_cluster + "", onAccept: function() { window.location.assign('index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente='+$idAgente); } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 2d6803ccd4..32dc0a9312 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -4976,13 +4976,38 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) } +/** + * agent belongs to the clusters. + * + * @param integer $idAgent + * + * @return array Names clusters. + */ +function agents_get_agent_belongs_cluster(int $idAgent): array +{ + $sql = sprintf( + 'SELECT tcluster.name + FROM tcluster + INNER JOIN tcluster_agent + ON tcluster.id = tcluster_agent.id_cluster + WHERE tcluster_agent.id_agent = %d', + $idAgent + ); + + $result = db_get_all_rows_sql($sql); + if ($result === false) { + $result = []; + } + + return $result; +} + + /** * Return an array with a list of status agents * * @return array. */ - - function agents_status_list() { $status_list = []; diff --git a/pandora_console/include/lib/Cluster.php b/pandora_console/include/lib/Cluster.php index b7bd21d929..46e7ba4324 100644 --- a/pandora_console/include/lib/Cluster.php +++ b/pandora_console/include/lib/Cluster.php @@ -213,6 +213,10 @@ class Cluster extends Entity public function getCounters() :array { $id_agent_modules = $this->getIdsModulesInvolved(); + if (empty($id_agent_modules) === true) { + return []; + } + $sql = sprintf( 'SELECT SUM( IF(estado = 1, 1, 0) ) AS critical, SUM( IF(estado = 2, 1, 0) ) AS warning, diff --git a/pandora_console/views/cluster/view.php b/pandora_console/views/cluster/view.php index 32bcdb0736..93894ba7e5 100644 --- a/pandora_console/views/cluster/view.php +++ b/pandora_console/views/cluster/view.php @@ -151,7 +151,11 @@ $agentCountModules = html_print_div( true ); -$alive_animation = agents_get_starmap(0, 180, 30, $module_involved_ids); +$alive_animation = ''; +if (empty($module_involved_ids) === false) { + $alive_animation = agents_get_starmap(0, 180, 30, $module_involved_ids); +} + $output = '
'; $output .= '
'; From 7a5201db4ff30baf0cd826319317127ff5bdd22a Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 29 Nov 2023 16:31:06 +0100 Subject: [PATCH 53/70] #8365 NCM V3 Minor fix --- pandora_console/include/javascript/pandora_ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/javascript/pandora_ui.js b/pandora_console/include/javascript/pandora_ui.js index 80ddfd06f5..00ece1a178 100644 --- a/pandora_console/include/javascript/pandora_ui.js +++ b/pandora_console/include/javascript/pandora_ui.js @@ -514,7 +514,7 @@ function load_modal(settings) { if (settings.cleanup != undefined) { settings.cleanup(); } - $("#modal_overlay").removeClass("ui-widget-overlay"); + $("#modal_overlay").remove(); }, beforeClose: settings.beforeClose() }); From 817811ffac2ce997e93fdfc16f225bec7c7b2d1c Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 30 Nov 2023 10:13:18 +0100 Subject: [PATCH 54/70] fix error update manager pandora_enterprise#12447 --- pandora_console/include/functions_menu.php | 3 ++- .../update_manager_client/lib/UpdateManager/Client.php | 7 ------- .../resources/javascript/umc_offline.js | 1 - 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index 1df84f6025..3b4c092680 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -983,7 +983,8 @@ if (is_ajax()) {

'.$product_name.'

'.__('Version').' '.$pandora_version.$lts_name.' - '.(enterprise_installed() ? 'Enterprise' : 'Community').'

-

'.__('MR version').' MR'.$config['MR'].'

+

'.__('Current package').' '.$config['current_package'].'

+

'.__('MR version').' MR'.$config['MR'].'

Build'.$build_version.'

'; if (enterprise_installed() === true) { $dialog .= '

'.__('Support expires').''.$license_expiry_date.'

'; diff --git a/pandora_console/update_manager_client/lib/UpdateManager/Client.php b/pandora_console/update_manager_client/lib/UpdateManager/Client.php index a0ca625009..8abe5f2f83 100644 --- a/pandora_console/update_manager_client/lib/UpdateManager/Client.php +++ b/pandora_console/update_manager_client/lib/UpdateManager/Client.php @@ -1829,13 +1829,6 @@ class Client } } else { // Manually uploaded package. - if (is_numeric($package['version']) !== true) { - $this->lastError = 'Version does not match required format (numeric)'; - $this->notify(10, $this->lastError, false); - $this->unlock(); - return false; - } - $classic_open_packages = false; $nextUpdate = [ 'version' => $package['version'] ]; $file_path = $package['file_path']; diff --git a/pandora_console/update_manager_client/resources/javascript/umc_offline.js b/pandora_console/update_manager_client/resources/javascript/umc_offline.js index a32dfc1e5c..ad2432a306 100644 --- a/pandora_console/update_manager_client/resources/javascript/umc_offline.js +++ b/pandora_console/update_manager_client/resources/javascript/umc_offline.js @@ -487,7 +487,6 @@ function updateOfflineProgress(url, auth) { * Cancel update. */ function cancelUpdate(reason = "") { - console.error(reason); var taskStatusLogContainer = $("#result li"); taskStatusLogContainer.addClass("error"); taskStatusLogContainer.find("p").text(texts.rejectedUpdate + " " + reason); From 1e4c5563d3dfa37369c65a363e780ac2eda92d7a Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Thu, 30 Nov 2023 14:44:27 +0100 Subject: [PATCH 55/70] #12416 fixed encryption_passphrase in metaconsole --- pandora_console/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/index.php b/pandora_console/index.php index 4ca8f80a82..27f84d53fb 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1234,7 +1234,7 @@ if (has_metaconsole() === true [ 'dbhost' => $config['replication_dbhost'], 'dbuser' => $config['replication_dbuser'], - 'dbpass' => io_output_password($config['replication_dbpass']), + 'dbpass' => $config['replication_dbpass'], 'dbname' => $config['replication_dbname'], ] ); From ea474ecd89d639e5f97cd0ea06e9de2cfca631d8 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 4 Dec 2023 15:05:01 +0100 Subject: [PATCH 56/70] #12566 changes in events table --- pandora_console/include/functions_ui.php | 23 ++++++--------------- pandora_console/operation/events/events.php | 14 +++---------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 5c9a7e90fc..3f9146e7d9 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -7170,32 +7170,21 @@ function ui_print_comments($comment, $truncate_limit=255) } // Only show the last comment. If commment its too long,the comment will short with ... - // If $config['prominent_time'] is timestamp the date show Month, day, hour and minutes. + // Forced time commentary to use copact date for optimize space in table. // Else show comments hours ago if ($comment['action'] != 'Added comment') { $comment['comment'] = $comment['action']; } + $comment['comment'] = io_safe_output($comment['comment']); + $short_comment = substr($comment['comment'], 0, 20); - if ($config['prominent_time'] == 'timestamp') { - $comentario = ''.date($config['date_format'], $comment['utimestamp']).' ('.$comment['id_user'].'): '.$comment['comment'].''; + $comentario = ''.ui_print_timestamp($comment['utimestamp'], true, ['style' => 'font-size: 10px', 'prominent' => 'compact']).' ('.$comment['id_user'].'): '.$comment['comment'].''; - if (strlen($comentario) > '200px' && $truncate_limit >= 255) { - $comentario = ''.date($config['date_format'], $comment['utimestamp']).' ('.$comment['id_user'].'): '.$short_comment.'...'; - } - } else { - $rest_time = (time() - $comment['utimestamp']); - $time_last = (($rest_time / 60) / 60); - - $comentario = ''.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).'  Hours  ('.$comment['id_user'].'): '.$comment['comment'].''; - - if (strlen($comentario) > '200px' && $truncate_limit >= 255) { - $comentario = ''.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).'  Hours  ('.$comment['id_user'].'): '.$short_comment.'...'; - } + if (strlen($comentario) > '200px' && $truncate_limit >= 255) { + $comentario = ''.ui_print_timestamp($comment['utimestamp'], true, ['style' => 'font-size: 10px', 'prominent' => 'compact']).' ('.$comment['id_user'].'): '.$short_comment.'...'; } - $comentario = io_safe_output($comentario); - if (strlen($comentario) >= $truncate_limit) { $comentario = ui_print_truncate_text( $comentario, diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index be5f6047e3..e019d12ab1 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -899,7 +899,7 @@ if (is_ajax() === true) { true, [ 'title' => __('Unknown'), - 'class' => 'forced-title', + 'class' => 'forced-title main_menu_icon', ] ); $state = 0; @@ -1199,10 +1199,10 @@ if (is_ajax() === true) { } $tmp->custom_data = $custom_data_str; - if (strlen($tmp->custom_data) >= 20) { + if (strlen($tmp->custom_data) >= 50) { $tmp->custom_data = ui_print_truncate_text( $tmp->custom_data, - 20, + 50, false, true, false, @@ -2595,14 +2595,6 @@ try { } - foreach ($fields as $key => $field) { - if (is_array($field) === false) { - $fields[$key] = [ - 'text' => $field, - 'class' => 'mw100px', - ]; - } - } // Always add options column. $fields = array_merge( From 75720df6fa05b95b8b8e08812d5e64bfa9ec8afb Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 5 Dec 2023 13:23:37 +0100 Subject: [PATCH 57/70] #12176 fixed empty news board --- pandora_console/include/lib/TacticalView/elements/NewsBoard.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/include/lib/TacticalView/elements/NewsBoard.php b/pandora_console/include/lib/TacticalView/elements/NewsBoard.php index 3be2dd685f..a2a2b7faba 100644 --- a/pandora_console/include/lib/TacticalView/elements/NewsBoard.php +++ b/pandora_console/include/lib/TacticalView/elements/NewsBoard.php @@ -117,6 +117,8 @@ class NewsBoard extends Element $output .= ''; return $output; + } else { + return ''; } } From d034116dd31cbe9f3ac4ace193a145ecd4b71f90 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Mon, 11 Dec 2023 09:26:57 +0100 Subject: [PATCH 58/70] #11495 Fix report --- .../include/ajax/reporting.ajax.php | 2 +- pandora_console/include/functions_modules.php | 60 +++++++++++++------ 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/pandora_console/include/ajax/reporting.ajax.php b/pandora_console/include/ajax/reporting.ajax.php index 59469a16e3..5f83d79b88 100755 --- a/pandora_console/include/ajax/reporting.ajax.php +++ b/pandora_console/include/ajax/reporting.ajax.php @@ -251,7 +251,7 @@ if ($change_custom_fields_macros_report === true) { } if ($get_agents === true) { - $agents_id = str_replace('"', '', $agents_id); + $agents_id = str_replace('"', '"', $agents_id); try { $agents_id = json_decode($agents_id, true); diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index c759187e21..ea776d6fe3 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4794,7 +4794,6 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule $availability = 0; $type = ''; - if ((bool) is_metaconsole() === true) { if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { $server_id = []; @@ -4860,13 +4859,33 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule if ($events_time !== false && count($events_time) > 0) { $failed_event = []; $normal_event = []; - foreach ($events_time as $event) { - if ($event['event_type'] === 'going_up_critical') { + $events_time = array_reverse($events_time); + $mtrs_events = []; + foreach ($events_time as $key => $event) { + if ($event['event_type'] === 'going_up_critical' || $event['event_type'] === 'going_down_critical') { $failed_event[] = $event['utimestamp']; + $mtrs_events[]['failed_event'] = $event['utimestamp']; } - if ($event['event_type'] === 'going_down_normal') { + if ($event['event_type'] === 'going_up_normal' + || $event['event_type'] === 'going_down_normal' + || $event['event_type'] === 'going_up_warning' + || $event['event_type'] === 'going_down_warning' + ) { $normal_event[] = $event['utimestamp']; + $mtrs_events[]['normal_event'] = $event['utimestamp']; + } + } + + $process_mtrs_events = []; + + if (empty($mtrs_events) === false) { + $last_event_key = ''; + foreach ($mtrs_events as $key => $val) { + if (key($val) !== $last_event_key) { + $last_event_key = key($val); + $process_mtrs_events[] = $val; + } } } @@ -4876,16 +4895,19 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule } else if (empty($failed_event) === true) { $mtrs_array[] = 0; } else { - foreach ($normal_event as $key => $value) { - if (isset($failed_event[$key]) === false) { - $failed_event[$key] = end($failed_event); + $last_value = ''; + foreach ($process_mtrs_events as $key => $val) { + $current_value = $val[key($val)]; + if ($last_value !== '') { + $mtrs_array[] = ($current_value - $last_value); } - if (($failed_event[$key] - $normal_event[$key]) < 0) { - $mtrs_array[] = ($normal_event[$key] - $failed_event[$key]); - } else { - $mtrs_array[] = ($failed_event[$key] - $normal_event[$key]); - } + $last_value = $current_value; + } + + $last_mtrs_event = key(end($process_mtrs_events)); + if ($last_mtrs_event === 'failed_event') { + $mtrs_array[] = ($current_time - $last_value); } } @@ -4894,19 +4916,19 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule if (!empty($failed_event) === true) { if (count($failed_event) > 1) { for ($i = 1; $i <= array_key_last($failed_event); $i++) { - $mtbf_array[] = ($failed_event[($i - 1)] - $failed_event[$i]); + $mtbf_array[] = ($failed_event[$i] - ($failed_event[($i - 1)])); } } else { - $mtbf_array[] = ($current_time - $failed_event[0]); + $mtbf_array[] = 0; } } else { $mtbf_array[] = 0; } - $total_time_failed = array_sum($mtbf_array); + $total_time_failed = array_sum($mtrs_array); $total_time_ok = ($interval_time - $total_time_failed); if (count($events_time) === 1) { - if ((string) $first_utimestamp !== '0') { + if ((int) $first_utimestamp !== 0) { $availability = round((($total_time_ok / $interval_time) * 100), 2); } } else { @@ -4914,14 +4936,14 @@ function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule } if ($critical_events > 1) { - $mtbf = round(( $total_time_failed / $critical_events)); + $mtbf = round(array_sum($mtbf_array) / count($mtbf_array)); } else { $mtbf = false; } - if (count($mtrs_array) === 1 && (string) $first_utimestamp !== '0' && $type === 0) { + if (count($mtrs_array) === 1 && (int) $first_utimestamp !== 0) { $mtrs = round($total_time_failed / count($mtrs_array)); - } else if (count($mtrs_array) > 1 && (string) $first_utimestamp !== '0') { + } else if (count($mtrs_array) > 1 && (int) $first_utimestamp !== 0) { $mtrs = round((array_sum($mtrs_array) / count($mtrs_array))); } else { $mtrs = false; From 94256559f1de1a32ceef0de36473dee843a4bd4e Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Mon, 11 Dec 2023 16:46:19 +0100 Subject: [PATCH 59/70] #11495 Fix agent name in metaconsole module selector --- .../reporting/reporting_builder.item_editor.php | 2 +- pandora_console/include/functions_agents.php | 4 ++-- pandora_console/include/functions_modules.php | 12 +++++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index c9fa71860c..06652894ca 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -2335,7 +2335,7 @@ if (is_metaconsole() === true) { $modulegroup, $id_agents, !$selection_a_m, - false + true ); } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 2d6803ccd4..3f9bd48955 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -3664,7 +3664,7 @@ function select_modules_for_agent_group( $sql = "SELECT * FROM ( - SELECT DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.nombre + SELECT (tagente_modulo.id_agente_modulo), tagente_modulo.nombre, tagente.alias FROM tagente_modulo $sql_tags_inner INNER JOIN tagente @@ -3679,7 +3679,7 @@ function select_modules_for_agent_group( $filter_not_string_modules $sql_conditions_tags ) x - GROUP BY nombre + $selection_filter"; $modules = db_get_all_rows_sql($sql); diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index ea776d6fe3..2955cdd4f7 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -3774,9 +3774,15 @@ function get_modules_agents( $t['id_node'] = $tserver; if ($nodes[$tserver] !== null) { - $t['nombre'] = io_safe_output( - $nodes[$tserver]->server_name().' » '.$t['nombre'] - ); + if (isset($t['alias']) === true) { + $t['nombre'] = io_safe_output( + $nodes[$tserver]->server_name().' » '.$t['alias'].' » '.$t['nombre'] + ); + } else { + $t['nombre'] = io_safe_output( + $nodes[$tserver]->server_name().' » '.$t['nombre'] + ); + } } $carry[] = $t; From 1a9bdf97d17e5ab425e06bcf9747b43c2514e5d7 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 11 Dec 2023 17:01:40 +0100 Subject: [PATCH 60/70] #12566 changes in view events --- pandora_console/include/functions_events.php | 7 +++- pandora_console/include/functions_ui.php | 12 ++++--- pandora_console/include/styles/events.css | 21 ++++++++++++ pandora_console/operation/events/events.php | 34 +++++++++++++------- 4 files changed, 57 insertions(+), 17 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 013698b33d..2436558967 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -6420,7 +6420,12 @@ function event_print_graph( $color[] = '#82b92f'; } } else { - $interval_length = (int) ($period / $num_intervals); + if ($num_intervals > 0) { + $interval_length = (int) ($period / $num_intervals); + } else { + $interval_length = 0; + } + $intervals = []; $intervals[0] = $start_utimestamp; for ($i = 0; $i < $num_intervals; $i++) { diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 3f9146e7d9..3ea3e8a740 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -7179,11 +7179,7 @@ function ui_print_comments($comment, $truncate_limit=255) $comment['comment'] = io_safe_output($comment['comment']); $short_comment = substr($comment['comment'], 0, 20); - $comentario = ''.ui_print_timestamp($comment['utimestamp'], true, ['style' => 'font-size: 10px', 'prominent' => 'compact']).' ('.$comment['id_user'].'): '.$comment['comment'].''; - - if (strlen($comentario) > '200px' && $truncate_limit >= 255) { - $comentario = ''.ui_print_timestamp($comment['utimestamp'], true, ['style' => 'font-size: 10px', 'prominent' => 'compact']).' ('.$comment['id_user'].'): '.$short_comment.'...'; - } + $comentario = $comment['comment']; if (strlen($comentario) >= $truncate_limit) { $comentario = ui_print_truncate_text( @@ -7198,6 +7194,12 @@ function ui_print_comments($comment, $truncate_limit=255) ); } + $comentario = ''.ui_print_timestamp($comment['utimestamp'], true, ['style' => 'font-size: 10px; display: contents;', 'prominent' => 'compact']).' ('.$comment['id_user'].'): '.$comment['comment'].''; + + if (strlen($comentario) > '200px' && $truncate_limit >= 255) { + $comentario = ''.ui_print_timestamp($comment['utimestamp'], true, ['style' => 'font-size: 10px; display: contents;', 'prominent' => 'compact']).' ('.$comment['id_user'].'): '.$short_comment.'...'; + } + return $comentario; } diff --git a/pandora_console/include/styles/events.css b/pandora_console/include/styles/events.css index 1a66ba7174..24d64ce05d 100644 --- a/pandora_console/include/styles/events.css +++ b/pandora_console/include/styles/events.css @@ -108,6 +108,27 @@ td > input[id^="checkbox-multi"] { height: 2.5em; } +.info_table.events tr > td span:not(.invisible) { + display: block; + overflow: hidden; + text-overflow: ellipsis; + max-height: 6em; + line-height: 2em; +} + +th.column-estado { + padding: 0px 0px 0px 12px !important; + max-width: fit-content; +} + +.content-status { + margin: 0 auto; + max-width: fit-content; +} +table#table_events > tbody > tr > td.column-estado { + padding: 0px !important; + text-align: center; +} .sorting_desc { background: url(../../images/sort_down_green.png) no-repeat; background-position-x: left; diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index e019d12ab1..eaf3066e4d 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -906,7 +906,7 @@ if (is_ajax() === true) { break; } - $draw_state = '
'; + $draw_state = '
'; $draw_state .= ''; @@ -1232,15 +1232,18 @@ if (is_ajax() === true) { ); } - $data = array_values( - array_filter( - $data, - function ($item) { - return (bool) (array) $item; - } - ) - ); - $count = count($data); + if (isset($data) === true) { + $data = array_values( + array_filter( + $data, + function ($item) { + return (bool) (array) $item; + } + ) + ); + $count = count($data); + } + // RecordsTotal && recordsfiltered resultados totales. echo json_encode( [ @@ -2585,7 +2588,7 @@ try { if ($evento_id !== false) { $fields[$evento_id] = [ 'text' => 'evento', - 'class' => 'mw250px', + 'class' => 'mw180px', ]; } @@ -2594,6 +2597,15 @@ try { $fields[$comment_id] = ['text' => 'user_comment']; } + $estado = array_search('estado', $fields); + if ($estado !== false) { + $fields[$estado] = [ + 'text' => $fields[$estado], + 'class' => 'column-estado', + ]; + } + + // Always add options column. From 616a8d728b760ea0499fe1a0674d4b278b85dcc9 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 11 Dec 2023 17:56:48 +0100 Subject: [PATCH 61/70] #12416 fixed multiples encrypts --- pandora_console/include/functions_io.php | 3 +++ pandora_console/index.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_io.php b/pandora_console/include/functions_io.php index 6283fdbaed..6264a75138 100755 --- a/pandora_console/include/functions_io.php +++ b/pandora_console/include/functions_io.php @@ -581,6 +581,9 @@ function io_output_password($password, $wrappedBy='') $output = ($plaintext === ENTERPRISE_NOT_HOOK) ? $password : $plaintext; + // If password already decrypt return same password. + $output = (empty($plaintext) === true) ? $password : $plaintext; + return sprintf( '%s%s%s', $wrappedBy, diff --git a/pandora_console/index.php b/pandora_console/index.php index 27f84d53fb..4ca8f80a82 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1234,7 +1234,7 @@ if (has_metaconsole() === true [ 'dbhost' => $config['replication_dbhost'], 'dbuser' => $config['replication_dbuser'], - 'dbpass' => $config['replication_dbpass'], + 'dbpass' => io_output_password($config['replication_dbpass']), 'dbname' => $config['replication_dbname'], ] ); From 77fd03d58a58d216bfa320502fb583c13aabef16 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 12 Dec 2023 10:15:37 +0100 Subject: [PATCH 62/70] #11495 Fix agent name in module selection --- pandora_console/include/functions_agents.php | 2 +- pandora_console/include/functions_modules.php | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 3f9bd48955..aa122b292f 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -3643,7 +3643,7 @@ function select_modules_for_agent_group( if (!$selection && $agents != null) { $number_agents = count($id_agents); - $selection_filter = "HAVING COUNT(id_agente_modulo) = $number_agents"; + $selection_filter = "GROUP BY nombre HAVING COUNT(id_agente_modulo) = $number_agents"; } if (tags_has_user_acl_tags(false)) { diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 019f92d4e1..b5cf42d894 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -3801,7 +3801,7 @@ function get_modules_agents( $return = array_reduce( $modules[$tserver], - function ($carry, $item) use ($tserver, $nodes) { + function ($carry, $item) use ($tserver, $nodes, $selection) { $t = []; foreach ($item as $k => $v) { $t[$k] = $v; @@ -3809,7 +3809,7 @@ function get_modules_agents( $t['id_node'] = $tserver; if ($nodes[$tserver] !== null) { - if (isset($t['alias']) === true) { + if (isset($t['alias']) === true && (bool) $selection === true) { $t['nombre'] = io_safe_output( $nodes[$tserver]->server_name().' » '.$t['alias'].' » '.$t['nombre'] ); @@ -3851,9 +3851,23 @@ function get_modules_agents( $selection, false, $useName, - false, + true, $notStringModules ); + + $modules = array_reduce( + $modules, + function ($carry, $item) use ($id_agents, $selection) { + if (count($id_agents) > 1 && (bool) $selection === true) { + $carry[$item['id_agente_modulo']] = $item['alias'].' » '.$item['nombre']; + } else { + $carry[$item['id_agente_modulo']] = $item['nombre']; + } + + return $carry; + }, + [] + ); } return $modules; From a2f60a1d2240c4cb96b3c32635e96d2c1ba5f99e Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Tue, 12 Dec 2023 12:12:24 +0100 Subject: [PATCH 63/70] Updated MR changes --- pandora_console/extras/mr/67.sql | 4 ++-- pandora_console/pandoradb_data.sql | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index c5cc4e114e..2fc576d477 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -49,7 +49,7 @@ SET @script_test = 'enable\n expect:Password:\s* _ 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_set_firmware = 'copy tftp flash\n expect:\]\? _TFTP_SERVER_IP_\n expect:\]\? _SOURCE_FILE_NAME_\n expect:\]\? firmware.bin\n show flash\n reload\n expect:confirm y\n config terminal\n boot system firmware.bin\n'; SET @script_custom = ''; SET @script_os_version = @script_get_firmware; @@ -769,7 +769,7 @@ SET @script_test = 'enable\n expect:Password:\s* _ 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_set_firmware = 'copy tftp flash _TFTP_SERVER_IP_ firmware.bin.swi secondary\n boot system flash secondary\n copy tftp flash _TFTP_SERVER_IP_ firmware.bin primary\n boot system flash primary\n'; SET @script_custom = ''; SET @script_os_version = @script_get_firmware; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 9581276979..db70f4b0e0 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2556,12 +2556,12 @@ 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:\]\? firmware.bin show flash reload expect:confirm y config terminal boot system firmware.bin'), (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'), + (11,4,'copy tftp flash\n expect:\]\? _TFTP_SERVER_IP_\n expect:\]\? _SOURCE_FILE_NAME_\n expect:\]\? firmware.bin\n show flash\n reload\n expect:confirm y\n config terminal\n boot system firmware.bin\n'), (12,5,''), (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'), @@ -2596,7 +2596,7 @@ INSERT INTO `tncm_script` VALUES (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'), + (46,4,'copy tftp flash _TFTP_SERVER_IP_ firmware.bin.swi secondary\n boot system flash secondary\n copy tftp flash _TFTP_SERVER_IP_ firmware.bin primary\n boot system flash primary\n'), (47,5,''), (48,7,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), (49,0,'sleep:1 exit\n\r'), From 90c91f67fa65a8d2b697cc9bb5762238584abde3 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 12 Dec 2023 12:45:13 +0100 Subject: [PATCH 64/70] #12633 Fixed Acknowledged --- pandora_console/include/functions_events.php | 61 ++++++-------------- 1 file changed, 19 insertions(+), 42 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 747e5154ce..1a37bfbf95 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -5039,7 +5039,11 @@ function events_page_general($event) $data[1] = $user_owner; } - $table_general->cellclass[3][1] = 'general_owner'; + if (is_metaconsole() === true && $event['server_name'] !== '') { + $table_general->cellclass[4][1] = 'general_owner'; + } else { + $table_general->cellclass[3][1] = 'general_owner'; + } $table_general->data[] = $data; @@ -5100,38 +5104,7 @@ function events_page_general($event) $data = []; $data[0] = __('Acknowledged by'); - - if ($event['estado'] == 1 || $event['estado'] == 2) { - if (empty($event['id_usuario']) === true) { - $user_ack = __('Autovalidated'); - } else { - $user_ack = db_get_value( - 'fullname', - 'tusuario', - 'id_user', - $event['id_usuario'] - ); - - if (empty($user_ack) === true) { - $user_ack = $event['id_usuario']; - } - } - - $data[1] = $user_ack.' ( '; - if ($event['ack_utimestamp_raw'] !== false - && $event['ack_utimestamp_raw'] !== 'false' - && empty($event['ack_utimestamp_raw']) === false - ) { - $data[1] .= date( - $config['date_format'], - $event['ack_utimestamp_raw'] - ); - } - - $data[1] .= ' ) '; - } else { - $data[1] = ''.__('N/A').''; - } + $data[1] = events_page_general_acknowledged($event['id_evento']); $table_general->cellclass[7][1] = 'general_status'; @@ -5237,15 +5210,19 @@ function events_page_general_acknowledged($event_id) $Acknowledged = ''; $event = db_get_row('tevento', 'id_evento', $event_id); if ($event !== false && ($event['estado'] == 1 || $event['estado'] == 2)) { - $user_ack = db_get_value( - 'fullname', - 'tusuario', - 'id_user', - $config['id_user'] - ); + if (empty($event['id_usuario']) === true) { + $user_ack = __('Autovalidated'); + } else { + $user_ack = db_get_value( + 'fullname', + 'tusuario', + 'id_user', + $config['id_user'] + ); - if (empty($user_ack) === true) { - $user_ack = $config['id_user']; + if (empty($user_ack) === true) { + $user_ack = $config['id_user']; + } } $Acknowledged = $user_ack.' ( '; @@ -5260,7 +5237,7 @@ function events_page_general_acknowledged($event_id) $Acknowledged .= ' ) '; } else { - $Acknowledged = 'N/A'; + $Acknowledged = ''.__('N/A').''; } return $Acknowledged; From 9dbac217c18661b89b41e2fb6088601259b8b4fe Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 12 Dec 2023 14:07:18 +0100 Subject: [PATCH 65/70] #12633 Fixed Acknowledged 2 --- pandora_console/include/functions_events.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 1a37bfbf95..64beee38c1 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -5103,9 +5103,23 @@ function events_page_general($event) $table_general->cellclass[count($table_general->data)][1] = 'general_acknowleded'; $data = []; + + if (empty($event['server_id']) === false && (int) $event['server_id'] > 0 + && is_metaconsole() === true + ) { + $node_connect = new Node($event['server_id']); + $node_connect->connect(); + } + $data[0] = __('Acknowledged by'); $data[1] = events_page_general_acknowledged($event['id_evento']); + if (empty($event['server_id']) === false && (int) $event['server_id'] > 0 + && is_metaconsole() === true + ) { + $node_connect->disconnect(); + } + $table_general->cellclass[7][1] = 'general_status'; $table_general->data[] = $data; From 6e60d19193a5b43378939d4496abc7bbb00d2825 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 12 Dec 2023 15:46:42 +0100 Subject: [PATCH 66/70] #8365 ftp server ip --- .../godmode/setup/setup_general.php | 29 +++++++++++++++++++ pandora_console/include/functions_config.php | 4 +++ 2 files changed, 33 insertions(+) diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 56596af445..90b2264793 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -896,6 +896,35 @@ echo ''.__('Mail configuration').''; echo ''; + echo '
'; + echo ''.__('NCM Configuration').''; + + $table_ncm_config = new stdClass(); + $table_ncm_config->width = '100%'; + $table_ncm_config->class = 'databox filter-table-adv'; + $table_ncm_config->size = []; + $table_ncm_config->size[0] = '50%'; + $table_ncm_config->data = []; + + $table_ncm_config->data[0][] = html_print_label_input_block( + __('FTP server IP').ui_print_help_tip(__('This value will be used by TFTP_SERVER_IP macro in NCM scripts.'), true), + html_print_input_text( + 'tftp_server_ip', + $config['tftp_server_ip'], + '', + false, + 255, + true, + false, + false, + '', + 'w50p' + ) + ); + + html_print_table($table_ncm_config); + + echo '
'; html_print_action_buttons( html_print_submit_button( diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index e47e84adeb..0f55153922 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -431,6 +431,10 @@ function config_update_config() if (config_update_value('inventory_changes_blacklist', implode(',', $inventory_changes_blacklist), true) === false) { $error_update[] = __('Inventory changes blacklist'); } + + if (config_update_value('tftp_server_ip', (string) get_parameter('tftp_server_ip'), true) === false) { + $error_update[] = __('Ftp server ip'); + } break; case 'enterprise': From 7df7fdff7da53afc2235230b72768b4757a46c25 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 13 Dec 2023 10:32:29 +0100 Subject: [PATCH 67/70] fix msg error agent cluster pandora_enterprise#12511 --- .../godmode/agentes/modificar_agente.php | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 5ea31914c6..a7ee6bf4c0 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -958,12 +958,33 @@ if ($agents !== false) { ); if ($check_aw === true && is_management_allowed() === true) { - if ($agent['id_os'] != CLUSTER_OS_ID) { - $onClickActionDeleteAgent = 'if (!confirm(\' '.__('Are you sure?').'\')) return false;'; - } else { - $onClickActionDeleteAgent = 'if (!confirm(\' '.__('WARNING! - You are going to delete a cluster agent. Are you sure?').'\')) return false;'; + $clusters = agents_get_agent_belongs_cluster($agent['id_agente']); + $cluster_belongs = ''; + if (empty($clusters) === false) { + $clusters = array_reduce( + $clusters, + function ($carry, $item) { + $carry[] = $item['name']; + return $carry; + } + ); + $cluster_belongs = implode(', ', $clusters); } + $msg = ''; + if ($agent['id_os'] == CLUSTER_OS_ID) { + $msg .= __('You are going to delete a cluster agent'); + $msg .= '. '; + } else if (empty($cluster_belongs) === false) { + $msg .= __('This agent belongs to the clusters'); + $msg .= ': '; + $msg .= $cluster_belongs; + $msg .= '. '; + } + + $msg .= __('Are you sure?'); + $onClickActionDeleteAgent = 'if (!confirm(\' '.$msg.'\')) return false;'; + $agentActionButtons[] = html_print_menu_button( [ 'href' => ui_get_full_url( From fed0d92805f0dc73e064aac9b84468bb9d77d3b3 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 13 Dec 2023 19:53:14 +0100 Subject: [PATCH 68/70] #12566 fixed colums module_custom_id and event_custom_id length_ --- pandora_console/include/styles/events.css | 8 ++++ pandora_console/operation/events/events.php | 41 ++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/styles/events.css b/pandora_console/include/styles/events.css index 24d64ce05d..78286c79f9 100644 --- a/pandora_console/include/styles/events.css +++ b/pandora_console/include/styles/events.css @@ -116,6 +116,14 @@ td > input[id^="checkbox-multi"] { line-height: 2em; } +.info_table.events tr > td span:not(.invisible) { + display: block; + overflow: hidden; + text-overflow: ellipsis; + max-height: 6em; + line-height: 1.5em; +} + th.column-estado { padding: 0px 0px 0px 12px !important; max-width: fit-content; diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index eaf3066e4d..66a33e6a0e 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -547,6 +547,45 @@ if (is_ajax() === true) { ); } + if (empty($tmp->tags) === false) { + $tmp->tags = ui_print_truncate_text( + $tmp->tags, + 30, + false, + true, + false, + '…', + true, + true, + ); + } + + if (empty($tmp->event_custom_id) === false) { + $tmp->event_custom_id = ui_print_truncate_text( + $tmp->event_custom_id, + 30, + false, + true, + false, + '…', + true, + true, + ); + } + + if (empty($tmp->module_custom_id) === false) { + $tmp->module_custom_id = ui_print_truncate_text( + $tmp->module_custom_id, + 30, + false, + true, + false, + '…', + true, + true, + ); + } + if (empty($tmp->comments) === false) { $tmp->comments = ui_print_comments($tmp->comments, 20); } @@ -2614,7 +2653,7 @@ try { [ [ 'text' => 'options', - 'class' => 'table_action_buttons mw120px', + 'class' => 'table_action_buttons mw100px', ], [ 'text' => 'm', From dffdbff8b152c42f7eee7e09adbc33ab0b3a19d1 Mon Sep 17 00:00:00 2001 From: artica Date: Thu, 14 Dec 2023 01:00:28 +0100 Subject: [PATCH 69/70] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.redhat_bin.el8.spec | 2 +- pandora_agents/unix/pandora_agent.redhat_bin.el9.spec | 2 +- pandora_agents/unix/pandora_agent.redhat_bin.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 28 files changed, 28 insertions(+), 28 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index f8b810d817..aa4a2d744c 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.774-231213 +Version: 7.0NG.774-231214 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index fe934f5bb2..5230283cd9 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.774-231213" +pandora_version="7.0NG.774-231214" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 263b12b006..eea0bef2e7 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1039,7 +1039,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.774'; -use constant AGENT_BUILD => '231213'; +use constant AGENT_BUILD => '231214'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index c8b79b5432..77dd456483 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.774 -%define release 231213 +%define release 231214 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec b/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec index e15c66a2b0..d6170ca2e8 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.774 -%define release 231213 +%define release 231214 %define debug_package %{nil} Summary: Pandora FMS Linux agent, binary version diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec b/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec index c8b9c5bab9..81de81c240 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.774 -%define release 231213 +%define release 231214 %define debug_package %{nil} Summary: Pandora FMS Linux agent, binary version diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.spec b/pandora_agents/unix/pandora_agent.redhat_bin.spec index 54311de34a..7e3809eec3 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.774 -%define release 231213 +%define release 231214 Summary: Pandora FMS Linux agent, binary version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index bfeb6b46be..6babe4a929 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.774 -%define release 231213 +%define release 231214 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index ccd8e1bbe9..6635b0c2e4 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.774" -PI_BUILD="231213" +PI_BUILD="231214" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index af055f92d2..2849d5842a 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{231213} +{231214} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 0c717e94de..d5c47e9441 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.774 Build 231213") +#define PANDORA_VERSION ("7.0NG.774 Build 231214") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index d0c4b12420..a7398b0f13 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Pandora FMS" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.774(Build 231213))" + VALUE "ProductVersion", "(7.0NG.774(Build 231214))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 3db8b82868..03471ff471 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.774-231213 +Version: 7.0NG.774-231214 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index ed5bacf153..92a964b48a 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.774-231213" +pandora_version="7.0NG.774-231214" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index a06a174ade..9ad1aa52da 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC231213'; +$build_version = 'PC231214'; $pandora_version = 'v7.0NG.774'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 91de00f8a8..1864d06ed2 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 3d44ddc426..08a0661437 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -7,7 +7,7 @@ %define debug_package %{nil} %define name pandorafms_server %define version 7.0NG.774 -%define release 231213 +%define release 231214 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 0bad40c2b6..cee1e6c579 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_server %define version 7.0NG.774 -%define release 231213 +%define release 231214 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 8dcdf85db0..aed560fe90 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.774" -PI_BUILD="231213" +PI_BUILD="231214" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 0b74326632..c08803df7c 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -38,7 +38,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.774 Build 231213"; +my $version = "7.0NG.774 Build 231214"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index afcf8b9199..02a9532ce0 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.774 Build 231213"; +my $version = "7.0NG.774 Build 231214"; # save program name for logging my $progname = basename($0); From f78c7495e5c3958b1f20b988e9647adc969f1cf5 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 14 Dec 2023 13:18:53 +0100 Subject: [PATCH 70/70] fixed modal close click button execute twice function close pandora_enterprise#12447 --- pandora_console/include/javascript/pandora_ui.js | 1 - 1 file changed, 1 deletion(-) diff --git a/pandora_console/include/javascript/pandora_ui.js b/pandora_console/include/javascript/pandora_ui.js index 45ca47e92b..0ab678893d 100644 --- a/pandora_console/include/javascript/pandora_ui.js +++ b/pandora_console/include/javascript/pandora_ui.js @@ -583,7 +583,6 @@ function confirmDialog(settings, idDialog = uniqId()) { $(this).dialog("close"); $(this).remove(); } - if (typeof settings.onDeny == "function") settings.onDeny(); } }, {