From 7d8a5b029ec5cc4609560569841551bf7b1aa32a Mon Sep 17 00:00:00 2001 From: Calvo Date: Mon, 29 Nov 2021 14:45:19 +0100 Subject: [PATCH 1/3] Changed radio buttons to select on prediction modules --- .../agentes/module_manager_editor_prediction.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index 7c319fa531..70ad75bb01 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -38,7 +38,7 @@ if ($row !== false && is_array($row)) { switch ($prediction_module) { case MODULE_PREDICTION_SERVICE: - $is_service = true; + $selected = 'service_selected'; $custom_integer_2 = 0; break; @@ -61,9 +61,9 @@ if ($row !== false && is_array($row)) { if (isset($first_op[1]) && $first_op[1] == 'avg') { - $is_synthetic_avg = true; + $selected = 'synthetic_selected'; } else { - $is_synthetic = true; + $selected = 'synthetic_avg_selected'; } $custom_integer_1 = 0; @@ -97,7 +97,7 @@ $data[0] = __('Source module'); $data[0] .= ui_print_help_icon('prediction_source_module', true); $data[1] = ''; // Services and Synthetic are an Enterprise feature. -$module_service_synthetic_selector = enterprise_hook('get_module_service_synthetic_selector', [$is_service, $is_synthetic, $is_synthetic_avg]); +$module_service_synthetic_selector = enterprise_hook('get_module_service_synthetic_selector', [$selected]); if ($module_service_synthetic_selector !== ENTERPRISE_NOT_HOOK) { $data[1] = $module_service_synthetic_selector; @@ -214,10 +214,7 @@ unset($table_advanced->data[3]); enterprise_hook( 'setup_services_synth', [ - $is_service, - $is_synthetic, - $is_synthetic_avg, - $is_netflow, + $type, $ops, ] ); From a38503491aae3eaf6e659b10e0ee22908d949b94 Mon Sep 17 00:00:00 2001 From: Calvo Date: Wed, 1 Dec 2021 11:34:11 +0100 Subject: [PATCH 2/3] Wip: trending prediction modules --- .../godmode/agentes/configurar_agente.php | 6 +++--- .../module_manager_editor_prediction.php | 21 ++++++++++++++----- pandora_console/include/constants.php | 3 +++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index f73e4d5b5c..6108730a5c 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -1788,7 +1788,7 @@ if ($update_module) { "Fail to try update module '".io_safe_output($name)."' for agent ".io_safe_output($agent['alias']) ); } else { - if ($prediction_module == 3) { + if ($prediction_module == MODULE_PREDICTION_SYNTHETIC) { enterprise_hook( 'modules_create_synthetic_operations', [ @@ -1931,7 +1931,7 @@ if ($create_module) { } } - if ($prediction_module == 3 && $serialize_ops == '') { + if ($prediction_module == MODULE_PREDICTION_SYNTHETIC && $serialize_ops == '') { $id_agent_module = false; } else { $id_agent_module = modules_create_agent_module( @@ -1972,7 +1972,7 @@ if ($create_module) { "Fail to try added module '".io_safe_output($name)."' for agent ".io_safe_output($agent['alias']) ); } else { - if ($prediction_module == 3) { + if ($prediction_module == MODULE_PREDICTION_SYNTHETIC) { enterprise_hook( 'modules_create_synthetic_operations', [ diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index 70ad75bb01..f84ca2b096 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -61,20 +61,29 @@ if ($row !== false && is_array($row)) { if (isset($first_op[1]) && $first_op[1] == 'avg') { - $selected = 'synthetic_selected'; - } else { $selected = 'synthetic_avg_selected'; + } else { + $selected = 'synthetic_selected'; } $custom_integer_1 = 0; $custom_integer_2 = 0; break; + case MODULE_PREDICTION_TRENDING: + $selected = 'module_selected'; + case MODULE_PREDICTION_MODULE: + $selected = 'trending_selected'; + $prediction_module = $custom_integer_1; + break; + default: + $prediction_module = $custom_integer_1; break; } } else { + $selected = 'module_selected'; $custom_integer_1 = 0; } @@ -135,7 +144,8 @@ $params['use_hidden_input_idagent'] = true; $params['hidden_input_idagent_id'] = 'hidden-id_agente_module_prediction'; $data[1] .= ui_print_agent_autocomplete_input($params); -$data[1] .= html_print_label(__('Module'), 'prediction_module', true); +$data[1] .= '
'; +$data[1] .= html_print_label(__('Module'), 'prediction_module', true).'
'; if ($id_agente) { $sql = 'SELECT id_agente_modulo, nombre FROM tagente_modulo @@ -156,6 +166,7 @@ if ($id_agente) { $data[1] .= ''; } +$data[1] .= '
'; $data[1] .= html_print_label(__('Period'), 'custom_integer_2', true).'
'; $periods[0] = __('Weekly'); @@ -187,7 +198,6 @@ if ($synthetic_module_form !== ENTERPRISE_NOT_HOOK) { $data[0] = ''; $data[1] = $synthetic_module_form; - $table_simple->colspan['synthetic_module'][1] = 3; push_table_simple($data, 'synthetic_module'); } @@ -214,7 +224,8 @@ unset($table_advanced->data[3]); enterprise_hook( 'setup_services_synth', [ - $type, + $selected, + $is_netflow, $ops, ] ); diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 164c6f3983..07d14e816d 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -368,12 +368,15 @@ define('MODULE_WUX', 8); define('MODULE_WIZARD', 9); // Type of Modules of Prediction. +define('MODULE_PREDICTION_MODULE', 1); define('MODULE_PREDICTION_SERVICE', 2); define('MODULE_PREDICTION_SYNTHETIC', 3); define('MODULE_PREDICTION_NETFLOW', 4); define('MODULE_PREDICTION_CLUSTER', 5); define('MODULE_PREDICTION_CLUSTER_AA', 6); define('MODULE_PREDICTION_CLUSTER_AP', 7); +define('MODULE_PREDICTION_TRENDING', 8); + // Forced agent OS ID for cluster agents. define('CLUSTER_OS_ID', 100); From 66c40876799db8654ffd46158c488b6c26803b86 Mon Sep 17 00:00:00 2001 From: Calvo Date: Thu, 2 Dec 2021 14:12:19 +0100 Subject: [PATCH 3/3] Added module interval control and percentage checkbox --- .../module_manager_editor_prediction.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index f84ca2b096..2abe885541 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -14,6 +14,7 @@ enterprise_include_once('include/functions_policies.php'); enterprise_include_once('godmode/agentes/module_manager_editor_prediction.php'); require_once 'include/functions_agents.php'; +ui_require_jquery_file('validate'); $disabledBecauseInPolicy = false; $disabledTextBecauseInPolicy = ''; @@ -71,12 +72,15 @@ if ($row !== false && is_array($row)) { break; case MODULE_PREDICTION_TRENDING: - $selected = 'module_selected'; - case MODULE_PREDICTION_MODULE: $selected = 'trending_selected'; $prediction_module = $custom_integer_1; break; + case MODULE_PREDICTION_MODULE: + $selected = 'module_selected'; + $prediction_module = $custom_integer_1; + break; + default: $prediction_module = $custom_integer_1; @@ -201,6 +205,17 @@ if ($synthetic_module_form !== ENTERPRISE_NOT_HOOK) { push_table_simple($data, 'synthetic_module'); } +$trending_module_form = enterprise_hook('get_trending_module_form', [$custom_string_1]); +if ($trending_module_form !== ENTERPRISE_NOT_HOOK) { + $data = []; + $data[0] = ''; + $data[1] .= $trending_module_form; + + push_table_simple($data, 'trending_module'); +} + + + // Netflow modules are an Enterprise feature. $netflow_module_form = enterprise_hook('get_netflow_module_form', [$custom_integer_1]); if ($netflow_module_form !== ENTERPRISE_NOT_HOOK) {