From 251bf60d5eeaf5b0a08e85fda4b1698d6686f801 Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Tue, 26 Dec 2023 15:47:42 -0600 Subject: [PATCH 1/4] Add warning time to CLI create --- pandora_server/util/pandora_manage.pl | 61 ++++++++++++++------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 678bcdabfb..976654a610 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -145,12 +145,12 @@ sub help_screen{ help_screen_line('--agent_update_custom_fields', ' ', "Update an agent custom field. The fields can be \n\t the following: Serial number, Department ... and types can be 0 text and 1 combo "); print "\nMODULES:\n\n" unless $param ne ''; - help_screen_line('--create_data_module', " [ \n\t \n\t \n\t \n\t \n\t ]", 'Add data server module to agent'); - help_screen_line('--create_web_module', " [ \n\t \n\t \n\t \n\t \n\t \n\t ].\n\t The valid data types are web_data, web_proc, web_content_data or web_content_string", 'Add web server module to agent'); - help_screen_line('--create_network_module', " \n\t [ \n\t \n\t \n\t \n\t \n\t ]", 'Add not snmp network module to agent'); + help_screen_line('--create_data_module', " [ \n\t \n\t \n\t \n\t \n\t ]", 'Add data server module to agent'); + help_screen_line('--create_web_module', " [ \n\t \n\t \n\t \n\t \n\t \n\t ].\n\t The valid data types are web_data, web_proc, web_content_data or web_content_string", 'Add web server module to agent'); + help_screen_line('--create_network_module', " \n\t [ \n\t \n\t \n\t \n\t \n\t ]", 'Add not snmp network module to agent'); help_screen_line('--create_snmp_module', " \n\t [ \n\t \n\t \n\t \n\t \n\t ] - \n\t \n\t ]", 'Add snmp network module to agent'); - help_screen_line('--create_plugin_module', " \n\t [ \n\t \n\t \n\t \n\t \n\t \n\t ]", 'Add plug-in module to agent'); + \n\t \n\t ]", 'Add snmp network module to agent'); + help_screen_line('--create_plugin_module', " \n\t [ \n\t \n\t \n\t \n\t \n\t \n\t ]", 'Add plug-in module to agent'); help_screen_line('--get_module_group', '[]', 'Dysplay all module groups'); help_screen_line('--create_module_group', ''); help_screen_line('--module_group_synch', " []", 'Synchronize metaconsole module groups'); @@ -1655,21 +1655,21 @@ sub cli_create_data_module($) { $min,$max,$post_process, $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $definition_file, $configuration_data, $warning_str, $critical_str, $enable_unknown_events, $ff_threshold, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $ff_timeout, - $warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions, $use_alias, $ignore_unknown); + $warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions, $use_alias, $ignore_unknown, $warning_time); if ($in_policy == 0) { ($module_name, $module_type, $agent_name, $description, $module_group, $min,$max,$post_process, $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $definition_file, $warning_str, $critical_str, $enable_unknown_events, $ff_threshold, - $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $ff_timeout, - $warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions, $use_alias, $ignore_unknown) = @ARGV[2..32]; + $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $ff_timeout,$warning_inverse, $critical_inverse, + $critical_instructions, $warning_instructions, $unknown_instructions, $use_alias, $ignore_unknown, $warning_time) = @ARGV[2..33]; } else { ($policy_name, $module_name, $module_type, $description, $module_group, $min,$max,$post_process, $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $configuration_data, $warning_str, $critical_str, $enable_unknown_events, $ff_threshold, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $ff_timeout, - $warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions, $ignore_unknown) = @ARGV[2..32]; + $warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions, $ignore_unknown, $warning_time) = @ARGV[2..33]; } my $module_name_def; @@ -1887,6 +1887,7 @@ sub cli_create_data_module($) { $parameters{'warning_instructions'} = $warning_instructions unless !defined ($warning_instructions); $parameters{'unknown_instructions'} = $unknown_instructions unless !defined ($unknown_instructions); $parameters{'ignore_unknown'} = $ignore_unknown unless !defined ($ignore_unknown); + $parameters{'warning_time'} = $warning_time unless !defined ($warning_time); if ($in_policy == 0) { if (defined $use_alias and $use_alias eq 'use_alias') { @@ -1918,7 +1919,7 @@ sub cli_create_web_module($) { $critical_max, $history_data, $retries, $requests, $agent_browser_id, $auth_server, $auth_realm, $definition_file, $proxy_url, $proxy_auth_login, $proxy_auth_password, $configuration_data, $warning_str, $critical_str, $enable_unknown_events, $ff_threshold, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $ff_timeout, - $warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions, $use_alias, $ignore_unknown); + $warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions, $use_alias, $ignore_unknown, $warning_time); if ($in_policy == 0) { ($module_name, $module_type, $agent_name, $description, $module_group, @@ -1926,7 +1927,7 @@ sub cli_create_web_module($) { $critical_max, $history_data, $retries, $requests, $agent_browser_id, $auth_server, $auth_realm, $definition_file, $proxy_url, $proxy_auth_login, $proxy_auth_password, $warning_str, $critical_str, $enable_unknown_events, $ff_threshold, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $ff_timeout, - $warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions, $use_alias, $ignore_unknown) = @ARGV[2..40]; + $warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions, $use_alias, $ignore_unknown, $warning_time) = @ARGV[2..41]; } else { ($policy_name, $module_name, $module_type, $description, $module_group, @@ -1934,7 +1935,7 @@ sub cli_create_web_module($) { $critical_max, $history_data, $retries, $requests, $agent_browser_id, $auth_server, $auth_realm, $configuration_data, $proxy_url, $proxy_auth_login, $proxy_auth_password, $warning_str, $critical_str, $enable_unknown_events, $ff_threshold, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $ff_timeout, - $warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions, $ignore_unknown) = @ARGV[2..39]; + $warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions, $ignore_unknown, $warning_time) = @ARGV[2..40]; } my $module_name_def; @@ -2163,7 +2164,7 @@ sub cli_create_web_module($) { $parameters{'ip_target'} = $auth_server unless !defined ($auth_server); $parameters{'snmp_community'} = $auth_realm unless !defined ($auth_realm); $parameters{'ignore_unknown'} = $ignore_unknown unless !defined ($ignore_unknown); - + $parameters{'warning_time'} = $warning_time unless !defined ($warning_time); if ($in_policy == 0) { @@ -2365,7 +2366,7 @@ sub cli_create_network_module($) { $module_group, $min, $max, $post_process, $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, $retries, $critical_instructions, - $warning_instructions, $unknown_instructions, $warning_inverse, $critical_inverse, $use_alias, $ignore_unknown); + $warning_instructions, $unknown_instructions, $warning_inverse, $critical_inverse, $use_alias, $ignore_unknown, $warning_time); if ($in_policy == 0) { ($module_name, $module_type, $agent_name, $module_address, $module_port, $description, @@ -2373,7 +2374,7 @@ sub cli_create_network_module($) { $critical_max, $history_data, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, $retries,$critical_instructions, $warning_instructions, $unknown_instructions, - $warning_inverse, $critical_inverse, $use_alias, $ignore_unknown) = @ARGV[2..34]; + $warning_inverse, $critical_inverse, $use_alias, $ignore_unknown, $warning_time) = @ARGV[2..35]; } else { ($policy_name, $module_name, $module_type, $module_port, $description, @@ -2381,7 +2382,7 @@ sub cli_create_network_module($) { $critical_max, $history_data, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, $retries, $critical_instructions, $warning_instructions, $unknown_instructions, - $warning_inverse, $critical_inverse, $ignore_unknown) = @ARGV[2..34]; + $warning_inverse, $critical_inverse, $ignore_unknown, $warning_time) = @ARGV[2..35]; } my $module_name_def; @@ -2518,7 +2519,7 @@ sub cli_create_network_module($) { $parameters{'critical_inverse'} = $critical_inverse unless !defined ($critical_inverse); $parameters{'warning_inverse'} = $warning_inverse unless !defined ($warning_inverse); $parameters{'ignore_unknown'} = $ignore_unknown unless !defined ($ignore_unknown); - + $parameters{'warning_time'} = $warning_time unless !defined ($warning_time); if ($in_policy == 0) { if (defined $use_alias and $use_alias eq 'use_alias') { @@ -2550,7 +2551,7 @@ sub cli_create_snmp_module($) { $warning_max, $critical_min, $critical_max, $history_data, $snmp3_priv_method, $snmp3_priv_pass, $snmp3_sec_level, $snmp3_auth_method, $snmp3_auth_user, $snmp3_auth_pass, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, $retries, - $critical_instructions, $warning_instructions, $unknown_instructions, $warning_inverse, $critical_inverse, $use_alias, $ignore_unknown); + $critical_instructions, $warning_instructions, $unknown_instructions, $warning_inverse, $critical_inverse, $use_alias, $ignore_unknown, $warning_time); if ($in_policy == 0) { ($module_name, $module_type, $agent_name, $module_address, $module_port, $version, $community, @@ -2558,7 +2559,7 @@ sub cli_create_snmp_module($) { $warning_max, $critical_min, $critical_max, $history_data, $snmp3_priv_method, $snmp3_priv_pass, $snmp3_sec_level, $snmp3_auth_method, $snmp3_auth_user, $snmp3_auth_pass, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, $retries, - $critical_instructions, $warning_instructions, $unknown_instructions, $warning_inverse, $critical_inverse, $use_alias, $ignore_unknown) = @ARGV[2..43]; + $critical_instructions, $warning_instructions, $unknown_instructions, $warning_inverse, $critical_inverse, $use_alias, $ignore_unknown, $warning_time) = @ARGV[2..44]; } else { ($policy_name, $module_name, $module_type, $module_port, $version, $community, @@ -2566,7 +2567,7 @@ sub cli_create_snmp_module($) { $warning_max, $critical_min, $critical_max, $history_data, $snmp3_priv_method, $snmp3_priv_pass, $snmp3_sec_level, $snmp3_auth_method, $snmp3_auth_user, $snmp3_auth_pass, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, $retries, - $critical_instructions, $warning_instructions, $unknown_instructions, $warning_inverse, $critical_inverse, $ignore_unknown) = @ARGV[2..41]; + $critical_instructions, $warning_instructions, $unknown_instructions, $warning_inverse, $critical_inverse, $ignore_unknown, $warning_time) = @ARGV[2..42]; } my $module_name_def; @@ -2708,7 +2709,8 @@ sub cli_create_snmp_module($) { $parameters{'critical_inverse'} = $critical_inverse unless !defined ($critical_inverse); $parameters{'warning_inverse'} = $warning_inverse unless !defined ($warning_inverse); $parameters{'ignore_unknown'} = $ignore_unknown unless !defined ($ignore_unknown); - + $parameters{'warning_time'} = $warning_time unless !defined ($warning_time); + if ($in_policy == 0) { if (defined $use_alias and $use_alias eq 'use_alias') { foreach my $id (@id_agents) { @@ -2736,7 +2738,7 @@ sub cli_create_plugin_module($) { $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, - $critical_instructions, $warning_instructions, $unknown_instructions, $warning_inverse, $critical_inverse, $use_alias, $ignore_unknown); + $critical_instructions, $warning_instructions, $unknown_instructions, $warning_inverse, $critical_inverse, $use_alias, $ignore_unknown, $warning_time); if ($in_policy == 0) { ($module_name, $module_type, $agent_name, $module_address, $module_port, $plugin_name, @@ -2744,7 +2746,7 @@ sub cli_create_plugin_module($) { $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, - $critical_instructions, $warning_instructions, $unknown_instructions, $warning_inverse, $critical_inverse, $use_alias, $ignore_unknown) = @ARGV[2..37]; + $critical_instructions, $warning_instructions, $unknown_instructions, $warning_inverse, $critical_inverse, $use_alias, $ignore_unknown, $warning_time) = @ARGV[2..38]; } else { ($policy_name, $module_name, $module_type, $module_port, $plugin_name, @@ -2752,7 +2754,7 @@ sub cli_create_plugin_module($) { $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, - $critical_instructions, $warning_instructions, $unknown_instructions, $warning_inverse, $critical_inverse, $ignore_unknown) = @ARGV[2..35]; + $critical_instructions, $warning_instructions, $unknown_instructions, $warning_inverse, $critical_inverse, $ignore_unknown, $warning_time) = @ARGV[2..36]; } my $module_name_def; @@ -2909,7 +2911,8 @@ sub cli_create_plugin_module($) { $parameters{'critical_inverse'} = $critical_inverse unless !defined ($critical_inverse); $parameters{'warning_inverse'} = $warning_inverse unless !defined ($warning_inverse); $parameters{'ignore_unknown'} = $ignore_unknown unless !defined ($ignore_unknown); - + $parameters{'warning_time'} = $warning_time unless !defined ($warning_time); + if ($in_policy == 0) { if (defined $use_alias and $use_alias eq 'use_alias') { foreach my $id (@id_agents) { @@ -7816,7 +7819,7 @@ sub pandora_manage_main ($$$) { cli_delete_agent(); } elsif ($param eq '--create_data_module') { - param_check($ltotal, 31, 24); + param_check($ltotal, 32, 25); cli_create_data_module(0); } elsif ($param eq '--create_web_module') { @@ -7845,7 +7848,7 @@ sub pandora_manage_main ($$$) { cli_create_snmp_module(0); } elsif ($param eq '--create_plugin_module') { - param_check($ltotal, 37, 20); + param_check($ltotal, 38, 21); cli_create_plugin_module(0); } elsif ($param eq '--delete_module') { @@ -8033,7 +8036,7 @@ sub pandora_manage_main ($$$) { cli_create_policy(); } elsif ($param eq '--create_policy_data_module') { - param_check($ltotal, 30, 21); + param_check($ltotal, 31, 22); cli_create_data_module(1); } elsif ($param eq '--create_policy_web_module') { @@ -8049,7 +8052,7 @@ sub pandora_manage_main ($$$) { cli_create_snmp_module(1); } elsif ($param eq '--create_policy_plugin_module') { - param_check($ltotal, 35, 19); + param_check($ltotal, 36, 20); cli_create_plugin_module(1); } elsif ($param eq '--create_alert_template') { From 0c13fe6902934bc12f66a724aad3000509e4b143 Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Wed, 27 Dec 2023 11:09:44 -0600 Subject: [PATCH 2/4] Add warning_time to create API --- pandora_console/include/functions_api.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 7417a48125..f75f20bca8 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -3677,6 +3677,7 @@ function api_set_create_network_module($id, $thrash1, $other, $thrash3) 'warning_inverse' => $other['data'][29], 'ff_type' => $other['data'][30], 'ignore_unknown' => $other['data'][32], + 'warning_time' => $other['data'][33], ]; if (! $values['descripcion']) { @@ -3956,6 +3957,7 @@ function api_set_create_plugin_module($id, $thrash1, $other, $thrash3) 'warning_inverse' => $other['data'][34], 'ff_type' => $other['data'][35], 'ignore_unknown' => $other['data'][37], + 'warning_time' => $other['data'][38], ]; $plugin = db_get_row('tplugin', 'id', $values['id_plugin']); @@ -4245,6 +4247,7 @@ function api_set_create_data_module($id, $thrash1, $other, $thrash3) 'warning_inverse' => $other['data'][25], 'ff_type' => $other['data'][26], 'ignore_unknown' => $other['data'][27], + 'warning_time' => $other['data'][28], ]; if (! $values['descripcion']) { @@ -4909,6 +4912,7 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3) 'min_ff_event_critical' => $other['data'][33], 'ff_type' => $other['data'][34], 'ignore_unknown' => $other['data'][36], + 'warning_time' => $other['data'][37], ]; } else { $values = [ @@ -4942,6 +4946,7 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3) 'min_ff_event_critical' => $other['data'][27], 'ff_type' => $other['data'][28], 'ignore_unknown' => $other['data'][29], + 'warning_time' => $other['data'][30], ]; } From 6d1f2331d5504cb7d773f9d9396ddb1b37dad284 Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Wed, 27 Dec 2023 12:37:04 -0600 Subject: [PATCH 3/4] Add warning_time to update API --- pandora_console/include/functions_api.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index f75f20bca8..b2b706da87 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -3843,6 +3843,7 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3) 'policy_linked', 'ff_type', 'ignore_unknown', + 'warning_time', ]; $values = []; @@ -4120,6 +4121,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3) 'policy_linked', 'ff_type', 'ignore_unknown', + 'warning_time', ]; $values = []; @@ -4771,6 +4773,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3) 'policy_linked', 'ff_type', 'ignore_unknown', + 'warning_time', ]; $values = []; @@ -5116,6 +5119,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) 'policy_linked', 'ff_type', 'ignore_unknown', + 'warning_time', ]; } else { $snmp_module_fields = [ @@ -5149,6 +5153,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) 'policy_linked', 'ff_type', 'ignore_unknown', + 'warning_time', ]; } @@ -7997,6 +8002,7 @@ function api_set_update_data_module_policy($id, $thrash1, $other, $thrash3) 'disabled_types_event', 'module_macros', 'ignore_unknown', + 'warning_time', ]; $cont = 0; @@ -8239,6 +8245,7 @@ function api_set_update_network_module_policy($id, $thrash1, $other, $thrash3) 'disabled_types_event', 'module_macros', 'ignore_unknown', + 'warning_time', ]; $cont = 0; @@ -8483,6 +8490,7 @@ function api_set_update_plugin_module_policy($id, $thrash1, $other, $thrash3) 'macros', 'module_macros', 'ignore_unknown', + 'warning_time', ]; $cont = 0; @@ -8966,6 +8974,7 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) 'plugin_user', 'plugin_pass', 'ignore_unknown', + 'warning_time', ]; } else { $fields_snmp_module = [ @@ -8991,6 +9000,7 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) 'custom_id', 'description', 'ignore_unknown', + 'warning_time', ]; } From f430d3ce9f646f797348426320d126e855abf414 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 30 Jan 2024 14:53:48 +0100 Subject: [PATCH 4/4] #12797 fix select2 --- pandora_console/include/class/ExtensionsDiscovery.class.php | 1 + pandora_console/include/javascript/extensions_discovery.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/class/ExtensionsDiscovery.class.php b/pandora_console/include/class/ExtensionsDiscovery.class.php index 84528c5bb1..b9b5d0ebf2 100644 --- a/pandora_console/include/class/ExtensionsDiscovery.class.php +++ b/pandora_console/include/class/ExtensionsDiscovery.class.php @@ -452,6 +452,7 @@ class ExtensionsDiscovery extends Wizard */ public function run() { + ui_require_javascript_file('select2.min'); ui_require_javascript_file('extensions_discovery'); $_iniFile = $this->loadIni(); if ($_iniFile === false) { diff --git a/pandora_console/include/javascript/extensions_discovery.js b/pandora_console/include/javascript/extensions_discovery.js index 15b8bfa60b..6dbef136c8 100644 --- a/pandora_console/include/javascript/extensions_discovery.js +++ b/pandora_console/include/javascript/extensions_discovery.js @@ -4,7 +4,7 @@ $(document).ready(() => { $("#_credentials_").select2({ closeOnSelect: true }); - + var interval; if (interval === "0") { setTimeout(() => { $("#mode_interval")