From ae526d5df05bfc21e2227f2f1f4d89c046d3c20b Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 23 May 2023 16:54:40 +0200 Subject: [PATCH 01/11] #10598 New wizard welcome --- pandora_console/general/header.php | 56 +- pandora_console/general/register.php | 18 +- .../godmode/agentes/modificar_agente.php | 10 +- pandora_console/godmode/menu.php | 16 + .../godmode/wizards/mini_diagnosis.php | 132 ++ .../godmode/wizards/task_to_perform.php | 1203 +++++++++++++++++ pandora_console/images/circle_title.svg | 19 + .../include/ajax/welcome_window.php | 10 +- .../include/class/WelcomeWindow.class.php | 695 ++++++---- pandora_console/include/functions_alerts.php | 10 +- pandora_console/include/functions_api.php | 20 +- pandora_console/include/functions_html.php | 41 + pandora_console/include/functions_servers.php | 21 + pandora_console/include/functions_ui.php | 26 + .../include/styles/mini_diagnosis.css | 83 ++ .../new_installation_welcome_window.css | 10 + 16 files changed, 2082 insertions(+), 288 deletions(-) create mode 100644 pandora_console/godmode/wizards/mini_diagnosis.php create mode 100644 pandora_console/godmode/wizards/task_to_perform.php create mode 100644 pandora_console/images/circle_title.svg create mode 100644 pandora_console/include/styles/mini_diagnosis.css diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index b0cbc0cec5..af868f0c5c 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -34,6 +34,22 @@ echo sprintf('
', $menuTypeClass); $notifications_numbers['notifications'], $notifications_numbers['last_id'] ).'
'; + $header_welcome = ''; + if (check_acl($config['id_user'], $group, 'AW')) { + $header_welcome .= '
'; + $header_welcome .= html_print_image( + 'images/computer@groups.svg', + true, + [ + 'class' => 'main_menu_icon invert_filter', + 'title' => __('Welcome dialog'), + 'id' => 'Welcome-dialog', + 'alt' => __('Welcome dialog'), + 'style' => 'cursor: pointer;', + ] + ); + $header_welcome .= '
'; + } // ======= Servers List =============================================== if ((bool) check_acl($config['id_user'], 0, 'AW') !== false) { @@ -461,7 +477,7 @@ echo sprintf('
', $menuTypeClass); } else { echo '
'.$config['custom_title_header'].''.$config['custom_subtitle_header'].'
'.$header_searchbar.'
-
'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $servers_list, $header_feedback, $header_support, $header_docu, $header_user, $header_logout.'
'; +
'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $header_welcome, $servers_list, $header_feedback, $header_support, $header_docu, $header_user, $header_logout.'
'; } ?>
@@ -904,6 +920,44 @@ echo sprintf('
', $menuTypeClass); $("#agent_access").css("display",""); }); + $("#welcome-icon-header").click(function () { + if (!$('#welcome_modal_window').length){ + $(document.body).append('
'); + $(document.body).append( $('').attr('href', 'include/styles/new_installation_welcome_window.css') ); + } + // Clean DOM. + load_modal({ + target: $('#welcome_modal_window'), + url: '', + modal: { + title: "", + cancel: '', + ok: '' + }, + onshow: { + page: 'include/ajax/welcome_window', + method: 'loadWelcomeWindow', + }, + oncancel: { + page: 'include/ajax/welcome_window', + title: "", + method: 'cancelWelcome', + confirm: function (fn) { + confirmDialog({ + title: '', + message: '', + ok: '', + cancel: '', + onAccept: function() { + // Continue execution. + fn(); + } + }) + } + } + }); + }); + // Feedback. $("#feedback-header").click(function () { diff --git a/pandora_console/general/register.php b/pandora_console/general/register.php index ed646f52f3..905a8c9eb6 100644 --- a/pandora_console/general/register.php +++ b/pandora_console/general/register.php @@ -100,21 +100,23 @@ if ($initial && users_is_admin()) { ); } -$welcome = !$initial; -try { - $welcome_window = new WelcomeWindow($welcome); - if ($welcome_window !== null) { - $welcome_window->run(); +if (check_acl($config['id_user'], 0, 'AW')) { + $welcome = !$initial; + try { + $welcome_window = new WelcomeWindow($welcome); + if ($welcome_window !== null) { + $welcome_window->run(); + } + } catch (Exception $e) { + $welcome = false; } -} catch (Exception $e) { - $welcome = false; } try { if (isset($_SESSION['showed_tips_window']) === false) { $tips_window = new TipsWindow(); if ($tips_window !== null) { - $tips_window->run(); + $tips_window->run(); } } } catch (Exception $e) { diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 0b27809299..4a87ca3a4c 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -1071,16 +1071,20 @@ if ((bool) check_acl($config['id_user'], 0, 'AW') === true) { function () { $(".actions", this).css ("visibility", "hidden"); }); - + $("#ag_group").click ( function () { $(this).css ("width", "auto"); $(this).css ("min-width", "100px"); }); - + $("#ag_group").blur (function () { $(this).css ("width", "100px"); }); - + + var show_deploy_agent = ""; + if (show_deploy_agent !== '0'){ + $('#button-modal_deploy_agent').click(); + } }); diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index f6e4aac358..0a8ef6e254 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -168,6 +168,22 @@ if ($access_console_node === true) { } $sub = []; + if ((bool) check_acl($config['id_user'], 0, 'AW') === true) { + $sub['wizard']['text'] = __('Configuration wizard'); + $sub['wizard']['id'] = 'conf_wizard'; + $sub['wizard']['type'] = 'direct'; + $sub['wizard']['subtype'] = 'nolink'; + $sub2 = []; + if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { + $sub2['godmode/wizards/mini_diagnosis']['text'] = __('Mini-diagnosis'); + $sub2['godmode/wizards/mini_diagnosis']['id'] = 'mini_diagnosis'; + } + + $sub2['godmode/wizards/task_to_perform']['text'] = __('Tasks to perform'); + $sub2['godmode/wizards/task_to_perform']['id'] = 'task_to_perform'; + $sub['wizard']['sub2'] = $sub2; + } + if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { $sub['templates']['text'] = __('Templates'); $sub['templates']['id'] = 'Templates'; diff --git a/pandora_console/godmode/wizards/mini_diagnosis.php b/pandora_console/godmode/wizards/mini_diagnosis.php new file mode 100644 index 0000000000..cfa58d9f74 --- /dev/null +++ b/pandora_console/godmode/wizards/mini_diagnosis.php @@ -0,0 +1,132 @@ + '', + 'label' => __('Configuration'), + ], + [ + 'link' => '', + 'label' => __('Configuration wizard'), + ], + ] +); + +if (empty($config['pandora_uid']) === 'ONLINE') { + $status_um = true; +} + +require_once 'include/functions_servers.php'; +if (check_all_servers_up() === true) { + $status_su = true; +} + +if (empty($config['welcome_mail_configured']) === false) { + $status_cm = true; +} + +if (enterprise_installed()) { + $license_valid = true; + enterprise_include_once('include/functions_license.php'); + $license = enterprise_hook('license_get_info'); + $days_to_expiry = ((strtotime($license['expiry_date']) - time()) / (60 * 60 * 24)); + if ($license === ENTERPRISE_NOT_HOOK || $days_to_expiry <= 30) { + $license_valid = false; + } + + if ($license_valid === true) { + $status_lv = true; + } +} + + +ui_require_css_file('mini_diagnosis'); +$table = new stdClass(); +$table->width = '60%'; +$table->class = 'filter-table-adv databox'; +$table->size = []; +$table->data = []; +$table->size[0] = '30%'; +$table->size[1] = '30%'; +$table->data[0][0] = html_print_wizard_diagnosis(__('Verification update manager register'), 'update_manager', __('Verification update manager register'), $status_um, true); +$table->data[0][1] = html_print_wizard_diagnosis(__('Please ensure mail configuration matches your needs'), 'configure_email', __('Please ensure mail configuration matches your needs'), $status_cm, true); +$table->data[1][0] = html_print_wizard_diagnosis(__('All servers up'), 'servers_up', __('All servers up'), $status_su, true); +$table->data[1][1] = html_print_wizard_diagnosis(__('Valid license verification and expiration greater than 30 days'), 'license_valid', __('Valid license verification and expiration greater than 30 days'), $status_lv, true); +html_print_table($table); +?> + \ No newline at end of file diff --git a/pandora_console/godmode/wizards/task_to_perform.php b/pandora_console/godmode/wizards/task_to_perform.php new file mode 100644 index 0000000000..6a1db32448 --- /dev/null +++ b/pandora_console/godmode/wizards/task_to_perform.php @@ -0,0 +1,1203 @@ + + + + + + '', + 'label' => __('Configuration'), + ], + [ + 'link' => '', + 'label' => __('Configuration wizard'), + ], + ] +); + +$status_webserver = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_WEB], 'status')['status']; +$status_check_web = false; +if ($status_webserver === '1') { + $status_check_web = true; +} + +$status_newtwork = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_NETWORK], 'status')['status']; +$status_pluggin = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_PLUGIN], 'status')['status']; +$status_check_connectivity = false; +if ($status_newtwork === '1' && $status_pluggin === '1') { + $status_check_connectivity = true; +} + +ui_require_css_file('mini_diagnosis'); +$table = new stdClass(); +$table->width = '60%'; +$table->class = 'filter-table-adv databox'; +$table->size = []; +$table->data = []; +$table->size[0] = '30%'; +$table->size[1] = '30%'; +$table->data[0][0] = html_print_wizard_diagnosis(__('Wizard install agent'), 'wizard_install', __('Wizard install agent'), false, true); +$table->data[0][1] = html_print_wizard_diagnosis(__('Create check web'), 'configure_email', __('Create check web'), $status_check_web, true); +$table->data[1][0] = html_print_wizard_diagnosis(__('Create basic connectivity'), 'servers_up', __('Create basic connectivity'), $status_check_connectivity, true); +$table->data[1][1] = html_print_wizard_diagnosis(__('Create basic net'), 'license_valid', __('Create basic net'), true, true); +$table->data[2][0] = html_print_wizard_diagnosis(__('Create Alert Mail'), 'license_valid', __('Create Alert Mail'), true, true); +html_print_table($table); +?> + + + + + + 9], 'status')['status']; + if ($status_webserver === '1') { + $name = array_keys(servers_get_names())[0]; + $id_group = get_parameter('id_group', 4); + + $array_other['data'] = [ + 'Goliat', + '', + 2, + $id_group, + 0, + 30, + 30, + 9, + $name, + 0, + 0, + 0, + __('Agent goliat created on welcome'), + ]; + + $id_agent = api_set_new_agent(0, '', $array_other, '', true); + if ($id_agent > 0) { + $module_name = get_parameter('module_name', 'goliat_module'); + $text_to_search = get_parameter('text_to_search', ''); + $url_goliat = get_parameter('url_goliat', 'https://pandorafms.com/en/'); + $module_latency = create_module_latency_goliat($id_agent, $module_name, $id_group, $url_goliat, $text_to_search); + $module_status = create_module_status_goliat($id_agent, $module_name, $id_group, $url_goliat, $text_to_search); + if ($module_latency > 0 && $module_status > 0) { + ui_print_success_message(__('Your check has been created, click here to view the data. Please note that it may take a few seconds to see data if your server is busy')); + } + } else { + ui_print_error_message(__('The Name is not valid for the modules.')); + } + } else { + ui_print_error_message(__('Web server is not enabled.')); + } +} + + +/** + * Create_module_latency_goliat and return module id. + * + * @param mixed $id_agent Id agent. + * @param mixed $module_name Module name. + * @param mixed $id_group Id group. + * @param mixed $url_search Url to search. + * @param mixed $string_search Text to search. + * + * @return interger Module id. + */ +function create_module_latency_goliat($id_agent, $module_name, $id_group, $url_search, $string_search='') +{ + if ($string_search !== '') { + $str_search = 'check_string '.$string_search.''; + } + + include_once 'include/functions_modules.php'; + + $array_values = [ + 'id_tipo_modulo' => '30', + 'descripcion' => '', + 'max' => '0', + 'min' => '0', + 'snmp_oid' => '', + 'snmp_community' => 'public', + 'id_module_group' => $id_group, + 'module_interval' => '300', + 'module_ff_interval' => '0', + 'ip_target' => '', + 'tcp_port' => '0', + 'tcp_rcv' => '', + 'tcp_send' => '', + 'id_export' => '0', + 'plugin_user' => '', + 'plugin_pass' => '0', + 'plugin_parameter' => 'task_begin +get '.$url_search.' +resource 1 +'.$str_search.' +task_end', + 'id_plugin' => '0', + 'post_process' => '0', + 'prediction_module' => '0', + 'max_timeout' => '0', + 'max_retries' => '0', + 'disabled' => '', + 'id_modulo' => '7', + 'custom_id' => '', + 'history_data' => '1', + 'dynamic_interval' => '0', + 'dynamic_max' => '0', + 'dynamic_min' => '0', + 'dynamic_two_tailed' => '0', + 'parent_module_id' => '0', + 'min_warning' => '0', + 'max_warning' => '0', + 'str_warning' => '', + 'min_critical' => '0', + 'max_critical' => '0', + 'str_critical' => '', + 'custom_string_1' => '', + 'custom_string_2' => '', + 'custom_string_3' => '', + 'custom_integer_1' => '0', + 'custom_integer_2' => '0', + 'min_ff_event' => '0', + 'min_ff_event_normal' => '0', + 'min_ff_event_warning' => '0', + 'min_ff_event_critical' => '0', + 'ff_type' => '0', + 'each_ff' => '0', + 'ff_timeout' => '0', + 'unit' => '', + 'macros' => '', + 'quiet' => '0', + 'cps' => '0', + 'critical_instructions' => '', + 'warning_instructions' => '', + 'unknown_instructions' => '', + 'critical_inverse' => '0', + 'warning_inverse' => '0', + 'percentage_critical' => '0', + 'percentage_warning' => '0', + 'cron_interval' => '* * * * *', + 'id_category' => '0', + 'disabled_types_event' => '{\"going_unknown\":0}', + 'module_macros' => 'W10=', + 'warning_time' => '0', + ]; + return modules_create_agent_module($id_agent, $module_name.'_latency', $array_values); +} + + +/** + * Create_module_status_goliat and return module id. + * + * @param mixed $id_agent Id agent. + * @param mixed $module_name Module name. + * @param mixed $id_group Id group. + * @param mixed $url_search Url to search. + * @param mixed $string_search Text to search. + * + * @return interger Module id. + */ +function create_module_status_goliat($id_agent, $module_name, $id_group, $url_search, $string_search='') +{ + if ($string_search !== '') { + $str_search = 'check_string '.$string_search.' '; + } + + include_once 'include/functions_modules.php'; + + $array_values = [ + 'id_tipo_modulo' => '31', + 'descripcion' => '', + 'max' => '0', + 'min' => '0', + 'snmp_oid' => '', + 'snmp_community' => 'public', + 'id_module_group' => $id_group, + 'module_interval' => '300', + 'module_ff_interval' => '0', + 'ip_target' => '', + 'tcp_port' => '0', + 'tcp_rcv' => '', + 'tcp_send' => '', + 'id_export' => '0', + 'plugin_user' => '', + 'plugin_pass' => '0', + 'plugin_parameter' => 'task_begin +get '.$url_search.' +resource 1 +'.$str_search.' +task_end', + 'id_plugin' => '0', + 'post_process' => '0', + 'prediction_module' => '0', + 'max_timeout' => '0', + 'max_retries' => '0', + 'disabled' => '', + 'id_modulo' => '7', + 'custom_id' => '', + 'history_data' => '1', + 'dynamic_interval' => '0', + 'dynamic_max' => '0', + 'dynamic_min' => '0', + 'dynamic_two_tailed' => '0', + 'parent_module_id' => '0', + 'min_warning' => '0', + 'max_warning' => '0', + 'str_warning' => '', + 'min_critical' => '0', + 'max_critical' => '0', + 'str_critical' => '', + 'custom_string_1' => '', + 'custom_string_2' => '', + 'custom_string_3' => '', + 'custom_integer_1' => '0', + 'custom_integer_2' => '0', + 'min_ff_event' => '0', + 'min_ff_event_normal' => '0', + 'min_ff_event_warning' => '0', + 'min_ff_event_critical' => '0', + 'ff_type' => '0', + 'each_ff' => '0', + 'ff_timeout' => '0', + 'unit' => '', + 'macros' => '', + 'quiet' => '0', + 'cps' => '0', + 'critical_instructions' => '', + 'warning_instructions' => '', + 'unknown_instructions' => '', + 'critical_inverse' => '0', + 'warning_inverse' => '0', + 'percentage_critical' => '0', + 'percentage_warning' => '0', + 'cron_interval' => '* * * * *', + 'id_category' => '0', + 'disabled_types_event' => '{\"going_unknown\":0}', + 'module_macros' => 'W10=', + 'warning_time' => '0', + ]; + return modules_create_agent_module($id_agent, $module_name.'_status', $array_values); +} + + +if ($create_connectivity_dialog) { + ?> + + 1], 'status')['status']; + $status_pluggin = db_get_row_filter('tserver', ['server_type' => 4], 'status')['status']; + if ($status_newtwork === '1' && $status_pluggin === '1') { + $name = array_keys(servers_get_names())[0]; + $id_group = get_parameter('id_group', 4); + $agent_name = get_parameter('agent_name', __('Agent check connectivity')); + + $array_other['data'] = [ + $agent_name, + '', + 2, + $id_group, + 0, + 30, + 30, + 9, + $name, + 0, + 0, + 0, + __('Basic connectivity'), + ]; + + $id_agent = api_set_new_agent(0, '', $array_other, '', true); + if ($id_agent > 0) { + $ip_target = get_parameter('ip_target', '127.0.0.1'); + $basic_network = create_module_basic_network($id_agent, $id_group, $ip_target); + $latency_network = create_module_latency_network($id_agent, $id_group, $ip_target); + $packet_lost = create_module_packet_lost($id_agent, $id_group, $ip_target); + if ($basic_network > 0 && $latency_network > 0 && $packet_lost > 0) { + ui_print_success_message(__('Your check has been created, click here to view the data. Please note that it may take a few seconds to see data if your server is busy')); + } + } else { + ui_print_error_message(__('The Name is not valid for the modules.')); + } + } else { + ui_print_error_message(__('Web server is not enabled.')); + } +} + + +/** + * Create module basic network and return module id. + * + * @param mixed $id_agent Id agent. + * @param mixed $id_group Id group. + * @param mixed $ip_target Ip target. + * + * @return interger Module id. + */ +function create_module_basic_network($id_agent, $id_group, $ip_target) +{ + include_once 'include/functions_modules.php'; + + $array_values = [ + 'id_tipo_modulo' => '6', + 'descripcion' => 'Basic network check (ping)', + 'max' => '0', + 'min' => '0', + 'snmp_oid' => '', + 'snmp_community' => 'public', + 'id_module_group' => $id_group, + 'module_interval' => '300', + 'module_ff_interval' => '0', + 'ip_target' => $ip_target, + 'tcp_port' => '0', + 'tcp_rcv' => '', + 'tcp_send' => '', + 'id_export' => '0', + 'plugin_user' => '', + 'plugin_pass' => '0', + 'plugin_parameter' => '', + 'id_plugin' => '0', + 'post_process' => '0', + 'prediction_module' => '0', + 'max_timeout' => '0', + 'max_retries' => '0', + 'disabled' => '', + 'id_modulo' => '2', + 'custom_id' => '', + 'history_data' => '1', + 'dynamic_interval' => '0', + 'dynamic_max' => '0', + 'dynamic_min' => '0', + 'dynamic_two_tailed' => '0', + 'parent_module_id' => '0', + 'min_warning' => '0', + 'max_warning' => '0', + 'str_warning' => '', + 'min_critical' => '0', + 'max_critical' => '0', + 'str_critical' => '', + 'custom_string_1' => '', + 'custom_string_2' => '', + 'custom_string_3' => '', + 'custom_integer_1' => '0', + 'custom_integer_2' => '0', + 'min_ff_event' => '0', + 'min_ff_event_normal' => '0', + 'min_ff_event_warning' => '0', + 'min_ff_event_critical' => '0', + 'ff_type' => '0', + 'each_ff' => '0', + 'ff_timeout' => '0', + 'unit' => '', + 'macros' => '', + 'quiet' => '0', + 'cps' => '0', + 'critical_instructions' => '', + 'warning_instructions' => '', + 'unknown_instructions' => '', + 'critical_inverse' => '0', + 'warning_inverse' => '0', + 'percentage_critical' => '0', + 'percentage_warning' => '0', + 'cron_interval' => '* * * * *', + 'id_category' => '0', + 'disabled_types_event' => '{\"going_unknown\":0}', + 'module_macros' => 'W10=', + 'warning_time' => '0', + ]; + return modules_create_agent_module($id_agent, 'Basic_Network_Check', $array_values); +} + + +/** + * Create module latency network and return module id. + * + * @param mixed $id_agent Id agent. + * @param mixed $id_group Id group. + * @param mixed $ip_target Ip target. + * + * @return interger Module id. + */ +function create_module_latency_network($id_agent, $id_group, $ip_target) +{ + include_once 'include/functions_modules.php'; + + $array_values = [ + 'id_tipo_modulo' => '7', + 'descripcion' => 'Basic network connectivity check to measure network latency in miliseconds', + 'max' => '0', + 'min' => '0', + 'snmp_oid' => '', + 'snmp_community' => 'public', + 'id_module_group' => $id_group, + 'module_interval' => '300', + 'module_ff_interval' => '0', + 'ip_target' => $ip_target, + 'tcp_port' => '0', + 'tcp_rcv' => '', + 'tcp_send' => '', + 'id_export' => '0', + 'plugin_user' => '', + 'plugin_pass' => '0', + 'plugin_parameter' => '', + 'id_plugin' => '0', + 'post_process' => '0', + 'prediction_module' => '0', + 'max_timeout' => '0', + 'max_retries' => '0', + 'disabled' => '', + 'id_modulo' => '2', + 'custom_id' => '', + 'history_data' => '1', + 'dynamic_interval' => '0', + 'dynamic_max' => '0', + 'dynamic_min' => '0', + 'dynamic_two_tailed' => '1', + 'parent_module_id' => '0', + 'min_warning' => '0', + 'max_warning' => '0', + 'str_warning' => '', + 'min_critical' => '0', + 'max_critical' => '0', + 'str_critical' => '', + 'custom_string_1' => '', + 'custom_string_2' => '', + 'custom_string_3' => '', + 'custom_integer_1' => '0', + 'custom_integer_2' => '0', + 'min_ff_event' => '0', + 'min_ff_event_normal' => '0', + 'min_ff_event_warning' => '0', + 'min_ff_event_critical' => '0', + 'ff_type' => '0', + 'each_ff' => '0', + 'ff_timeout' => '0', + 'unit' => '', + 'macros' => '', + 'quiet' => '0', + 'cps' => '0', + 'critical_instructions' => '', + 'warning_instructions' => '', + 'unknown_instructions' => '', + 'critical_inverse' => '0', + 'warning_inverse' => '0', + 'percentage_critical' => '0', + 'percentage_warning' => '0', + 'cron_interval' => '* * * * *', + 'id_category' => '0', + 'disabled_types_event' => '{\"going_unknown\":0}', + 'module_macros' => 'W10=', + 'warning_time' => '0', + ]; + return modules_create_agent_module($id_agent, 'Basic_Network_Latency', $array_values); +} + + +/** + * Create module packet lost and return module id. + * + * @param mixed $id_agent Id agent. + * @param mixed $id_group Id group. + * @param mixed $ip_target Ip target. + * + * @return interger Module id. + */ +function create_module_packet_lost($id_agent, $id_group, $ip_target) +{ + include_once 'include/functions_modules.php'; + + $array_values = [ + 'id_tipo_modulo' => '1', + 'descripcion' => 'Basic network connectivity check to measure packet loss in %', + 'max' => '0', + 'min' => '0', + 'snmp_oid' => '', + 'snmp_community' => 'public', + 'id_module_group' => $id_group, + 'module_interval' => '300', + 'module_ff_interval' => '0', + 'ip_target' => '', + 'tcp_port' => '0', + 'tcp_rcv' => '', + 'tcp_send' => '', + 'id_export' => '0', + 'plugin_user' => '', + 'plugin_pass' => '0', + 'plugin_parameter' => '', + 'id_plugin' => '9', + 'post_process' => '0', + 'prediction_module' => '0', + 'max_timeout' => '0', + 'max_retries' => '0', + 'disabled' => '', + 'id_modulo' => '4', + 'custom_id' => '', + 'history_data' => '1', + 'dynamic_interval' => '0', + 'dynamic_max' => '0', + 'dynamic_min' => '0', + 'dynamic_two_tailed' => '1', + 'parent_module_id' => '0', + 'min_warning' => '0', + 'max_warning' => '0', + 'str_warning' => '', + 'min_critical' => '0', + 'max_critical' => '0', + 'str_critical' => '', + 'custom_string_1' => '', + 'custom_string_2' => '', + 'custom_string_3' => '', + 'custom_integer_1' => '0', + 'custom_integer_2' => '0', + 'min_ff_event' => '0', + 'min_ff_event_normal' => '0', + 'min_ff_event_warning' => '0', + 'min_ff_event_critical' => '0', + 'ff_type' => '0', + 'each_ff' => '0', + 'ff_timeout' => '0', + 'unit' => '', + 'macros' => '{"1":{"macro":"_field1_","desc":"Test time","help":"","value":"8","hide":""},"2":{"macro":"_field2_","desc":"Target IP","help":"","value":"'.$ip_target.'","hide":""}}', + 'quiet' => '0', + 'cps' => '0', + 'critical_instructions' => '', + 'warning_instructions' => '', + 'unknown_instructions' => '', + 'critical_inverse' => '0', + 'warning_inverse' => '0', + 'percentage_critical' => '0', + 'percentage_warning' => '0', + 'cron_interval' => '* * * * *', + 'id_category' => '0', + 'disabled_types_event' => '{\"going_unknown\":0}', + 'module_macros' => 'W10=', + 'warning_time' => '0', + ]; + return modules_create_agent_module($id_agent, 'Basic_Network_Packetloss', $array_values); +} + + +if ($create_net_scan_dialog) { + ?> + + 0) { + $id_recon_server = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_DISCOVERY], 'id_server')['id_server']; + ui_print_success_message(__('Basic net created and scan in progress. Click here to view the data. Please note that it may take a few seconds to see data if your server is busy')); + } else { + ui_print_error_message(__('Basic net already exists. Click here to view the data')); + } +} + + +/** + * Create module packet lost and return module id. + * + * @param string $ip_target Ip and red mask. + * + * @return interger Module id. + */ +function create_net_scan($ip_target) +{ + global $config; + include_once 'HostDevices.class.php'; + $HostDevices = new HostDevices(1); + $id_recon_server = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_DISCOVERY], 'id_server')['id_server']; + + $_POST = [ + 'page' => '1', + 'interval_manual_defined' => '1', + 'interval_select' => '-1', + 'interval_text' => '0', + 'interval' => '0', + 'interval_units' => '1', + 'taskname' => __('Basic network'), + 'id_recon_server' => $id_recon_server, + 'network' => $ip_target, + 'id_group' => '8', + 'comment' => __('Created on welcome'), + ]; + $task_created = $HostDevices->parseNetScan(); + if ($task_created === true) { + $HostDevicesFinal = new HostDevices(2); + $_POST = [ + 'task' => $HostDevices->task['id_rt'], + 'page' => '2', + 'recon_ports' => '', + 'auto_monitor' => 'on', + 'id_network_profile' => ['0' => '2'], + 'review_results' => 'on', + 'review_limited' => '0', + 'snmp_enabled' => 'on', + 'snmp_version' => '1', + 'snmp_skip_non_enabled_ifs' => 'on', + 'community' => '', + 'snmp_context' => '', + 'snmp_auth_user' => '', + 'snmp_security_level' => 'authNoPriv', + 'snmp_auth_method' => 'MD5', + 'snmp_auth_pass' => '', + 'snmp_privacy_method' => 'AES', + 'snmp_privacy_pass' => '', + 'os_detect' => 'on', + 'resolve_names' => 'on', + 'parent_detection' => 'on', + 'parent_recursion' => 'on', + 'vlan_enabled' => 'on', + ]; + + $task_final_created = $HostDevicesFinal->parseNetScan(); + if ($task_final_created === true) { + $net_scan_id = $HostDevices->task['id_rt']; + unset($HostDevices, $HostDevicesFinal); + return $net_scan_id; + } + } else { + return 0; + } +} + + +if ($create_alert_mail_dialog) { + ?> + + 'Email to '.$config['id_user']], 'id')['id']; + if (!$id_action) { + $al_action = alerts_get_alert_action($id); + $id_action = alerts_clone_alert_action(1, $al_action['id_group'], 'Email to '.$config['id_user']); + } + + $id_alert_template = get_parameter('id_condition', 0); + $id_agent_module = get_parameter('id_agent_module', 0); + + $exist = db_get_value_sql( + sprintf( + 'SELECT COUNT(id) + FROM talert_template_modules + WHERE id_agent_module = %d + AND id_alert_template = %d + AND id_policy_alerts = 0 + ', + $id_agent_module, + $id_alert_template + ) + ); + + if ($exist > 0) { + ui_print_error_message(__('Alert already exists. Click here to view the data')); + } else { + $id = alerts_create_alert_agent_module($id_agent_module, $id_alert_template); + if ($id !== false) { + $values = []; + $values['fires_min'] = (int) get_parameter('fires_min'); + $values['fires_max'] = (int) get_parameter('fires_max'); + $values['module_action_threshold'] = (int) 300; + + $alert_created = alerts_add_alert_agent_module_action($id, $id_action, $values); + } + } + + if ($alert_created === true) { + ui_print_success_message(__('Congratulations, you have already created a simple alert. You can see it. Pandora FMS alerts are very flexible, you can do many more things with them, we recommend you to read the documentation for more information. You can create advanced alerts from here.')); + } +} \ No newline at end of file diff --git a/pandora_console/images/circle_title.svg b/pandora_console/images/circle_title.svg new file mode 100644 index 0000000000..23c906e4e5 --- /dev/null +++ b/pandora_console/images/circle_title.svg @@ -0,0 +1,19 @@ + + + EB094270-FB38-4A58-BE94-D40EA44EA568 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/include/ajax/welcome_window.php b/pandora_console/include/ajax/welcome_window.php index 75f0e69dbf..c077a81fc8 100644 --- a/pandora_console/include/ajax/welcome_window.php +++ b/pandora_console/include/ajax/welcome_window.php @@ -35,6 +35,13 @@ if (is_ajax() === false) { } $ajaxPage = 'include/ajax/welcome_window'; +// Ajax controller. +$method = get_parameter('method', ''); + +if ($method === 'loadWelcomeWindow') { + unset($config['welcome_state']); +} + // Control call flow. try { @@ -44,9 +51,6 @@ try { exit; } -// Ajax controller. -$method = get_parameter('method', ''); - if (method_exists($welcome_actions, $method) === true) { if ($welcome_actions->ajaxMethod($method) === true) { $welcome_actions->{$method}(); diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index d1f14c2217..339d72afd8 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -336,54 +336,7 @@ class WelcomeWindow extends Wizard public function loadWelcomeWindow() { global $config; - - $btn_configure_mail_class = 'pending'; - $btn_create_agent_class = 'pending'; - $btn_create_module_class = ''; - $btn_create_alert_class = ''; - $btn_create_discovery_class = 'pending'; - - $li_configure_mail_class = 'row_green'; - $li_create_agent_class = 'row_green'; - $li_create_module_class = 'row_grey'; - $li_create_alert_class = 'row_grey'; - $li_create_discovery_class = 'row_green'; - - if (empty($config['welcome_mail_configured']) === false) { - $btn_configure_mail_class = ' completed'; - } - - if (empty($config['welcome_id_agent']) === false) { - $btn_create_agent_class = ' completed'; - $btn_create_module_class = ' pending'; - $li_create_module_class = 'row_green'; - } - - if (empty($config['welcome_module']) === false) { - $btn_create_module_class = ' completed'; - $btn_create_alert_class = ' pending'; - $li_create_module_class = 'row_green'; - } - - if (empty($config['welcome_alert']) === false) { - $btn_create_alert_class = ' completed'; - $li_create_alert_class = 'row_green'; - } - - if (empty($config['welcome_task']) === false) { - $btn_create_discovery_class = ' completed'; - } - - if ((int) $config['welcome_state'] === WELCOME_FINISHED) { - // Nothing left to do. - $btn_configure_mail_class = ' completed'; - $btn_create_agent_class = ' completed'; - $btn_create_module_class = ' completed'; - $btn_create_alert_class = ' completed'; - $btn_create_discovery_class = ' completed'; - $li_create_module_class = 'row_green'; - $li_create_alert_class = 'row_green'; - } + $flag_task = false; $form = [ 'action' => '#', @@ -413,187 +366,389 @@ class WelcomeWindow extends Wizard ], ], ], - [ + ]; + + if (check_acl($config['id_user'], 0, 'PM')) { + $flag_um = false; + $flag_cm = false; + $flag_su = false; + $flag_lv = false; + + $btn_update_manager_class = ' pending'; + $btn_configure_mail_class = ' pending'; + $btn_servers_up_class = ' pending'; + $btn_license_valid_class = ' pending'; + + $li_update_manager_class = 'row_grey'; + $li_configure_mail_class = 'row_grey'; + $li_servers_up_class = 'row_grey'; + $li_license_valid_class = 'row_grey'; + + if ($config['pandora_uid'] === 'ONLINE') { + $btn_update_manager_class = ' completed'; + $li_update_manager_class = 'row_green'; + $flag_um = true; + } + + if (empty($config['welcome_mail_configured']) === false) { + $btn_configure_mail_class = ' completed'; + $flag_cm = true; + } + + include_once 'include/functions_servers.php'; + if (check_all_servers_up() === true) { + $btn_servers_up_class = ' completed'; + $li_servers_up_class = 'row_green'; + $flag_su = true; + } + + if (enterprise_installed()) { + $license_valid = true; + enterprise_include_once('include/functions_license.php'); + $license = enterprise_hook('license_get_info'); + $days_to_expiry = ((strtotime($license['expiry_date']) - time()) / (60 * 60 * 24)); + if ($license === ENTERPRISE_NOT_HOOK || $days_to_expiry <= 30) { + $license_valid = false; + } + + if ($license_valid === true) { + $btn_license_valid_class = ' completed'; + $li_license_valid_class = 'row_green'; + $flag_lv = true; + } + } + + $inputs[] = [ 'wrapper' => 'div', - 'block_id' => 'div_configure_mail', - 'class' => 'hole flex-row flex-items-center w98p '.$li_configure_mail_class, + 'block_id' => 'div_diagnosis', + 'class' => 'flex-row flex-items-center w98p ', 'direct' => 1, 'block_content' => [ [ - 'label' => __('Please ensure mail configuration matches your needs'), + 'label' => __('Mini-diagnosis'), 'arguments' => [ 'class' => 'first_lbl', - 'name' => 'lbl_create_agent', - 'id' => 'lbl_create_agent', - ], - ], - [ - 'arguments' => [ - 'label' => '', - 'type' => 'button', - 'attributes' => [ - 'class' => (empty($btn_configure_mail_class) === false) ? $btn_configure_mail_class : 'invisible_important', - 'mode' => 'onlyIcon', - ], - 'name' => 'btn_email_conf', - 'id' => 'btn_email_conf', + 'name' => 'lbl_diagnosis', + 'id' => 'lbl_diagnosis', ], ], ], - ], - [ - 'label' => 'Learn to monitor', - 'class' => 'extra', - 'arguments' => [ - 'class' => 'class="lbl_learn"', - 'name' => 'lbl_learn', - 'id' => 'lbl_learn', - ], - ], - [ - 'wrapper' => 'div', - 'block_id' => 'div_create_agent', - 'class' => 'learn_content_indented flex-row flex-items-center w98p '.$li_create_agent_class, - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('Create an agent'), - 'arguments' => [ - 'class' => 'first_lbl', - 'name' => 'lbl_create_agent', - 'id' => 'lbl_create_agent', - ], - ], - [ - 'arguments' => [ - 'label' => '', - 'type' => 'button', - 'attributes' => [ - 'class' => (empty($btn_create_agent_class) === false) ? $btn_create_agent_class : 'invisible_important', - 'mode' => 'onlyIcon', + ]; + + if ($flag_um === false || $flag_cm === false || $flag_su === false || $flag_lv === false) { + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_update_manager', + 'class' => 'hole flex-row flex-items-center w98p '.$li_update_manager_class, + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Verification update manager register'), + 'arguments' => [ + 'class' => 'first_lbl', + 'name' => 'lbl_update_manager', + 'id' => 'lbl_update_manager', ], - 'name' => 'btn_create_agent', - 'id' => 'btn_create_agent', ], - ], - ], - ], - [ - 'wrapper' => 'div', - 'block_id' => 'div_monitor_actions', - 'class' => 'learn_content_indented flex-row flex-items-center w98p '.$li_create_module_class, - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('Create a module to check if an agent is online'), - 'arguments' => [ - 'class' => 'second_lbl', - 'name' => 'lbl_check_agent', - 'id' => 'lbl_check_agent', - ], - ], - [ - 'arguments' => [ - 'label' => '', - 'type' => 'button', - 'attributes' => [ - 'class' => (empty($btn_create_module_class) === false) ? $btn_create_module_class : 'invisible_important', - 'mode' => 'onlyIcon', + [ + 'arguments' => [ + 'label' => '', + 'type' => 'button', + 'attributes' => [ + 'class' => (empty($btn_update_manager_class) === false) ? $btn_update_manager_class : 'invisible_important', + 'mode' => 'onlyIcon', + ], + 'name' => 'btn_update_manager_conf', + 'id' => 'btn_update_manager_conf', ], - 'name' => 'btn_create_module', - 'id' => 'btn_create_module', ], ], - ], - ], - [ - 'wrapper' => 'div', - 'block_id' => 'div_monitor_actions', - 'class' => 'hole learn_content_indented flex-row flex-items-center w98p '.$li_create_alert_class, - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('Be warned if something is wrong, create an alert on the module'), - 'arguments' => [ - 'class' => 'second_lbl', - 'name' => 'lbl_create_alert', - 'id' => 'lbl_create_alert', - ], - ], - [ - 'arguments' => [ - 'label' => '', - 'type' => 'button', - 'attributes' => [ - 'class' => (empty($btn_create_alert_class) === false) ? $btn_create_alert_class : 'invisible_important', - 'mode' => 'onlyIcon', + ]; + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_configure_mail', + 'class' => 'hole flex-row flex-items-center w98p '.$li_configure_mail_class, + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Please ensure mail configuration matches your needs'), + 'arguments' => [ + 'class' => 'first_lbl', + 'name' => 'lbl_create_agent', + 'id' => 'lbl_create_agent', ], - 'name' => 'btn_create_alert', - 'id' => 'btn_create_alert', ], - ], - ], - ], - [ - 'wrapper' => 'div', - 'block_id' => 'div_discover', - 'class' => 'hole flex-row flex-items-center w98p '.$li_create_discovery_class, - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('Discover hosts and devices in your network'), - 'arguments' => [ - 'class' => 'first_lbl', - 'name' => 'lbl_discover_devices', - 'id' => 'lbl_discover_devices', - ], - ], - [ - 'arguments' => [ - 'label' => '', - 'type' => 'button', - 'attributes' => [ - 'class' => (empty($btn_create_discovery_class) === false) ? $btn_create_discovery_class : 'invisible_important', - 'mode' => 'onlyIcon', + [ + 'arguments' => [ + 'label' => '', + 'type' => 'button', + 'attributes' => [ + 'class' => (empty($btn_configure_mail_class) === false) ? $btn_configure_mail_class : 'invisible_important', + 'mode' => 'onlyIcon', + ], + 'name' => 'btn_email_conf', + 'id' => 'btn_email_conf', ], - 'name' => 'btn_discover_devices', - 'id' => 'btn_discover_devices', ], ], + ]; + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_servers_up', + 'class' => 'hole flex-row flex-items-center w98p '.$li_servers_up_class, + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('All servers up'), + 'arguments' => [ + 'class' => 'first_lbl', + 'name' => 'lbl_servers_up', + 'id' => 'lbl_servers_up', + ], + ], + [ + 'arguments' => [ + 'label' => '', + 'type' => 'button', + 'attributes' => [ + 'class' => (empty($btn_servers_up_class) === false) ? $btn_servers_up_class : 'invisible_important', + 'mode' => 'onlyIcon', + ], + 'name' => 'btn_servers_up_conf', + 'id' => 'btn_servers_up_conf', + ], + ], + ], + ]; + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_license_valid', + 'class' => 'hole flex-row flex-items-center w98p '.$li_license_valid_class, + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Valid license verification and expiration greater than 30 days'), + 'arguments' => [ + 'class' => 'first_lbl', + 'name' => 'lbl_license_valid', + 'id' => 'lbl_license_valid', + ], + ], + [ + 'arguments' => [ + 'label' => '', + 'type' => 'button', + 'attributes' => [ + 'class' => (empty($btn_license_valid_class) === false) ? $btn_license_valid_class : 'invisible_important', + 'mode' => 'onlyIcon', + ], + 'name' => 'btn_license_valid_conf', + 'id' => 'btn_license_valid_conf', + ], + ], + ], + ]; + } else { + $key = db_get_value_sql('SELECT `value` FROM tupdate_settings WHERE `key` = "customer_key"'); + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_all_correct', + 'class' => 'hole flex-row flex-items-center w98p', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('It seems that your Pandora FMS is working correctly and registered with ID:
#'.$key.'.
For more information use the self-diagnosis tool.'), + 'arguments' => [ + 'class' => 'first_lbl w98p', + 'name' => 'lbl_all_correct', + 'id' => 'lbl_all_correct', + ], + ], + ], + ]; + } + + if ($flag_um === false || $flag_cm === false || $flag_su === false || $flag_lv === false) { + $flag_task = true; + } + } + + // Task to do. + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_task_todo', + 'class' => 'flex-row flex-items-center w98p', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Task to perform'), + 'arguments' => [ + 'class' => 'first_lbl', + 'name' => 'lbl_task_todo', + 'id' => 'lbl_task_todo', + ], ], ], ]; - if (enterprise_installed() === true) { - $inputs[] = [ - 'wrapper' => 'div', - 'block_id' => 'div_not_working', - 'class' => 'hole flex-row flex-items-center w98p', - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('If something is not working as expected, look for this icon and report!'), - 'arguments' => [ - 'class' => 'first_lbl', - 'name' => 'lbl_not_working', - 'id' => 'lbl_not_working', - ], - ], - [ - 'label' => html_print_image( - 'images/feedback-header.png', - true, - [ - 'onclick' => '$(\'#feedback-header\').click()', - 'style' => 'cursor: pointer;', - ] - ), - + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_wizard_agent', + 'class' => 'hole flex-row flex-items-center w98p row_grey', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Wizard install agent'), + 'arguments' => [ + 'class' => 'first_lbl row_grey', + 'name' => 'lbl_wizard_agent', + 'id' => 'lbl_wizard_agent', ], ], - ]; + [ + 'arguments' => [ + 'label' => '', + 'type' => 'button', + 'attributes' => [ + 'class' => 'completed', + 'mode' => 'onlyIcon', + ], + 'name' => 'btn_wizard_agent_conf', + 'id' => 'btn_wizard_agent_conf', + ], + ], + ], + ]; + + $status_webserver = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_WEB], 'status')['status']; + $check_web_color = 'row_grey'; + if ($status_webserver === '1') { + $check_web_color = 'row_green'; } + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_check_web', + 'class' => 'hole flex-row flex-items-center w98p '.$check_web_color, + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Create check web'), + 'arguments' => [ + 'class' => 'first_lbl row_grey', + 'name' => 'lbl_check_web', + 'id' => 'lbl_check_web', + ], + ], + [ + 'arguments' => [ + 'label' => '', + 'type' => 'button', + 'attributes' => [ + 'class' => 'completed', + 'mode' => 'onlyIcon', + ], + 'name' => 'btn_check_web_conf', + 'id' => 'btn_check_web_conf', + ], + ], + ], + ]; + + $status_newtwork = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_NETWORK], 'status')['status']; + $status_pluggin = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_PLUGIN], 'status')['status']; + $check_connectivity = 'row_grey'; + if ($status_newtwork === '1' && $status_pluggin === '1') { + $check_connectivity = 'row_green'; + } + + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_check_connectivity', + 'class' => 'hole flex-row flex-items-center w98p '.$check_connectivity, + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Create basic connectivity'), + 'arguments' => [ + 'class' => 'first_lbl row_grey', + 'name' => 'lbl_check_connectivity', + 'id' => 'lbl_check_connectivity', + ], + ], + [ + 'arguments' => [ + 'label' => '', + 'type' => 'button', + 'attributes' => [ + 'class' => 'completed', + 'mode' => 'onlyIcon', + ], + 'name' => 'btn_check_connectivity_conf', + 'id' => 'btn_check_connectivity_conf', + ], + ], + ], + ]; + + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_check_net', + 'class' => 'hole flex-row flex-items-center w98p row_green', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Create basic net'), + 'arguments' => [ + 'class' => 'first_lbl row_grey', + 'name' => 'lbl_check_net', + 'id' => 'lbl_check_net', + ], + ], + [ + 'arguments' => [ + 'label' => '', + 'type' => 'button', + 'attributes' => [ + 'class' => 'completed', + 'mode' => 'onlyIcon', + ], + 'name' => 'btn_check_net_conf', + 'id' => 'btn_check_net_conf', + ], + ], + ], + ]; + + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_check_mail_alert', + 'class' => 'hole flex-row flex-items-center w98p row_green', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Create Alert Mail'), + 'arguments' => [ + 'class' => 'first_lbl row_grey', + 'name' => 'lbl_check_mail_alert', + 'id' => 'lbl_check_mail_alert', + ], + ], + [ + 'arguments' => [ + 'label' => '', + 'type' => 'button', + 'attributes' => [ + 'class' => 'completed', + 'mode' => 'onlyIcon', + ], + 'name' => 'btn_check_mail_alert_conf', + 'id' => 'btn_check_mail_alert_conf', + ], + ], + ], + ]; + $output = $this->printForm( [ 'form' => $form, @@ -602,7 +757,7 @@ class WelcomeWindow extends Wizard true ); - $output .= $this->loadJS(); + $output .= $this->loadJS($flag_task); echo $output; // Ajax methods does not continue. @@ -830,82 +985,96 @@ class WelcomeWindow extends Wizard * * @return string HTML code for javascript functionality. */ - public function loadJS() + public function loadJS($flag_task=false) { ob_start(); ?> 'string', - 'data' => $id_agente, - ] - ); + if ($return === false) { + returnData( + 'string', + [ + 'type' => 'string', + 'data' => $id_agente, + ] + ); + } else { + return $id_agente; + } } catch (\Exception $e) { returnError($e->getMessage()); return; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index b4536bcf5f..5f9e9ba01d 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -6977,3 +6977,44 @@ function html_print_code_picker( echo $output; } } + + +function html_print_wizard_diagnosis( + $title, + $id_button, + $description='', + $status=true, + $return=false, +) { + $button = ''; + if ($status === true) { + $status = 'Connected'; + $img = '/images/configuration@svg.svg'; + } else { + $status = 'Disconnected'; + $img = '/images/change-active.svg'; + } + + $button = html_print_image( + $img, + true, + [ + 'class' => 'main_menu_icon invert_filter float-right mrgn_right_10px', + 'id' => $id_button, + ] + ); + + $output = '
+ '.__($status).$button.' +
'.html_print_image('/images/circle_title.svg', true, ['class' => 'invert_filter']).''.$title.'
+
+ '.$description.' +
+
'; + + if ($return === true) { + return $output; + } else { + echo $output; + } +} \ No newline at end of file diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index 7ba3c50303..3c2fbfc698 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -1317,3 +1317,24 @@ function servers_get_master() return $result; } + + +/** + * Return true if all servers are up. + * + * @return boolean + */ +function check_all_servers_up() +{ + $status = true; + + $servers = servers_get_info(); + + foreach ($servers as $server) { + if ($server['status'] !== '1') { + return false; + } + } + + return $status; +} diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 8f70d9aec6..a3fb8dbce5 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3078,6 +3078,32 @@ function ui_print_module_status( } +/** + * Returns html code to print a shape for a module. + * + * @param integer $color Hex color. + * @param boolean $return True or false. + * @param string $class Custom class or use defined. + * @param string $div_content Content. + * + * @return string HTML code for shape. + */ +function ui_print_diagnosis_status( + $color, + $return=false, + $class='status_rounded_rectangles', + $div_content='' +) { + $output = '
'.$div_content.'
'; + + if ($return === false) { + echo $output; + } + + return $output; +} + + /** * Get the shape of an image by assigning it a CSS class. Prints an image with CSS representing a status. * diff --git a/pandora_console/include/styles/mini_diagnosis.css b/pandora_console/include/styles/mini_diagnosis.css new file mode 100644 index 0000000000..7bae821ff8 --- /dev/null +++ b/pandora_console/include/styles/mini_diagnosis.css @@ -0,0 +1,83 @@ +.rectangle { + background-color: #ffffff; + border: 2px solid #e5e9ed; + border-radius: 6px; + max-width: 475px; + width: 475px; + height: 161px; + display: contents; + justify-content: flex-start; +} + +.rectangle:hover { + background-color: #f3f5f7; +} + +.rectangle_Connected { + border-left: 4px solid #82b92e; +} + +.rectangle_Disconnected { + border-left: 4px solid #8a96a6; +} + +.status { + font-weight: bold; + margin-top: -10px; + margin-left: 20px; +} + +.Connected { + color: #82b92e; + font-family: Lato; + font-size: 15px; + line-height: 24px; +} + +.Disconnected { + color: #8a96a6; + font-family: Lato; + font-size: 15px; + line-height: 24px; +} + +.title { + margin-top: 20px; + margin-left: 20px; +} + +.title > img { + margin-top: 5px; +} + +.title > span { + color: #14524f; + font-family: Lato; + font-size: 18px; + line-height: 24px; + text-align: left; + margin-left: 10px; + margin-right: 10px; + display: inline-block; + margin-left: 20px; + margin-top: -20px; +} + +.description { + margin-top: 20px; + margin-left: 10px; + color: #454545; + font-family: Lato; + font-size: 15px; + line-height: 24px; + width: 430px; + text-align: left; +} + +.button { + text-align: right; +} + +span > img:hover { + cursor: pointer; +} diff --git a/pandora_console/include/styles/new_installation_welcome_window.css b/pandora_console/include/styles/new_installation_welcome_window.css index 90f96a5445..0dbdcd5203 100644 --- a/pandora_console/include/styles/new_installation_welcome_window.css +++ b/pandora_console/include/styles/new_installation_welcome_window.css @@ -86,3 +86,13 @@ #welcome_form li.extra { padding-bottom: 2.5em; } + +#li-div_diagnosis, +#li-div_task_todo { + border-left: unset !important; +} + +#div_diagnosis > label, +#div_task_todo > label { + font-weight: bold; +} From 9829d9281ccdf1e059bfbb14bd878869bf43ebc6 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 23 May 2023 17:00:00 +0200 Subject: [PATCH 02/11] #10598 new wizard welcome --- .../godmode/wizards/task_to_perform.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/wizards/task_to_perform.php b/pandora_console/godmode/wizards/task_to_perform.php index 6a1db32448..c821758bb8 100644 --- a/pandora_console/godmode/wizards/task_to_perform.php +++ b/pandora_console/godmode/wizards/task_to_perform.php @@ -317,9 +317,9 @@ $table->size[0] = '30%'; $table->size[1] = '30%'; $table->data[0][0] = html_print_wizard_diagnosis(__('Wizard install agent'), 'wizard_install', __('Wizard install agent'), false, true); $table->data[0][1] = html_print_wizard_diagnosis(__('Create check web'), 'configure_email', __('Create check web'), $status_check_web, true); -$table->data[1][0] = html_print_wizard_diagnosis(__('Create basic connectivity'), 'servers_up', __('Create basic connectivity'), $status_check_connectivity, true); -$table->data[1][1] = html_print_wizard_diagnosis(__('Create basic net'), 'license_valid', __('Create basic net'), true, true); -$table->data[2][0] = html_print_wizard_diagnosis(__('Create Alert Mail'), 'license_valid', __('Create Alert Mail'), true, true); +$table->data[1][0] = html_print_wizard_diagnosis(__('Create basic connectivity'), 'basic_connectivity', __('Create basic connectivity'), $status_check_connectivity, true); +$table->data[1][1] = html_print_wizard_diagnosis(__('Create basic net'), 'basic_net', __('Create basic net'), true, true); +$table->data[2][0] = html_print_wizard_diagnosis(__('Create Alert Mail'), 'alert_mail', __('Create Alert Mail'), true, true); html_print_table($table); ?> @@ -329,22 +329,22 @@ html_print_table($table); 'deployAgent()' ); - document.getElementById("button-btn_check_web_conf").setAttribute( + document.getElementById("configure_email").setAttribute( 'onclick', 'openCreateModulesDialog()' ); - document.getElementById("button-btn_check_connectivity_conf").setAttribute( + document.getElementById("basic_connectivity").setAttribute( 'onclick', 'openCreateConnectivityDialog()' ); - document.getElementById("button-btn_check_net_conf").setAttribute( + document.getElementById("basic_net").setAttribute( 'onclick', 'openCreateBasicNetDialog()' ); - document.getElementById("button-btn_check_mail_alert_conf").setAttribute( + document.getElementById("alert_mail").setAttribute( 'onclick', 'openCreateAlertMailDialog()' ); From 99b274d36293da126343d42c4090f1b9cf853fb7 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 24 May 2023 08:41:46 +0200 Subject: [PATCH 03/11] #10598 new wizard welcome --- pandora_console/godmode/wizards/mini_diagnosis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/wizards/mini_diagnosis.php b/pandora_console/godmode/wizards/mini_diagnosis.php index cfa58d9f74..022b46c203 100644 --- a/pandora_console/godmode/wizards/mini_diagnosis.php +++ b/pandora_console/godmode/wizards/mini_diagnosis.php @@ -54,7 +54,7 @@ ui_print_standard_header( ] ); -if (empty($config['pandora_uid']) === 'ONLINE') { +if ($config['pandora_uid'] === 'ONLINE') { $status_um = true; } From ebdc735bd42a1bdac7ce3fb1d09157b0a80da575 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 2 Jun 2023 13:32:47 +0200 Subject: [PATCH 04/11] #10598 V2 wizard welcome --- pandora_console/general/header.php | 2 +- pandora_console/godmode/menu.php | 63 +- .../godmode/wizards/task_to_perform.php | 1203 ----------------- .../include/ajax/task_to_perform.php | 181 +++ .../include/class/WelcomeWindow.class.php | 744 +++++++--- pandora_console/include/functions_menu.php | 2 + .../include/functions_welcome_wizard.php | 537 ++++++++ .../new_installation_welcome_window.css | 18 +- pandora_console/include/styles/pandora.css | 4 - .../include/styles/select2.min.css | 2 +- 10 files changed, 1329 insertions(+), 1427 deletions(-) delete mode 100644 pandora_console/godmode/wizards/task_to_perform.php create mode 100644 pandora_console/include/ajax/task_to_perform.php create mode 100644 pandora_console/include/functions_welcome_wizard.php diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index af868f0c5c..78a9551128 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -38,7 +38,7 @@ echo sprintf('
', $menuTypeClass); if (check_acl($config['id_user'], $group, 'AW')) { $header_welcome .= '
'; $header_welcome .= html_print_image( - 'images/computer@groups.svg', + 'images/wizard@svg.svg', true, [ 'class' => 'main_menu_icon invert_filter', diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 0a8ef6e254..60ec438097 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -172,16 +172,7 @@ if ($access_console_node === true) { $sub['wizard']['text'] = __('Configuration wizard'); $sub['wizard']['id'] = 'conf_wizard'; $sub['wizard']['type'] = 'direct'; - $sub['wizard']['subtype'] = 'nolink'; - $sub2 = []; - if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { - $sub2['godmode/wizards/mini_diagnosis']['text'] = __('Mini-diagnosis'); - $sub2['godmode/wizards/mini_diagnosis']['id'] = 'mini_diagnosis'; - } - - $sub2['godmode/wizards/task_to_perform']['text'] = __('Tasks to perform'); - $sub2['godmode/wizards/task_to_perform']['id'] = 'task_to_perform'; - $sub['wizard']['sub2'] = $sub2; + $sub['wizard']['subtype'] = 'nolink_no_arrow'; } if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { @@ -629,3 +620,55 @@ if ((bool) $config['pure'] === false) { } echo '
'; +// Need to be here because the translate string. +if (check_acl($config['id_user'], $group, 'AW')) { + ?> + + + - - - - - '', - 'label' => __('Configuration'), - ], - [ - 'link' => '', - 'label' => __('Configuration wizard'), - ], - ] -); - -$status_webserver = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_WEB], 'status')['status']; -$status_check_web = false; -if ($status_webserver === '1') { - $status_check_web = true; -} - -$status_newtwork = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_NETWORK], 'status')['status']; -$status_pluggin = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_PLUGIN], 'status')['status']; -$status_check_connectivity = false; -if ($status_newtwork === '1' && $status_pluggin === '1') { - $status_check_connectivity = true; -} - -ui_require_css_file('mini_diagnosis'); -$table = new stdClass(); -$table->width = '60%'; -$table->class = 'filter-table-adv databox'; -$table->size = []; -$table->data = []; -$table->size[0] = '30%'; -$table->size[1] = '30%'; -$table->data[0][0] = html_print_wizard_diagnosis(__('Wizard install agent'), 'wizard_install', __('Wizard install agent'), false, true); -$table->data[0][1] = html_print_wizard_diagnosis(__('Create check web'), 'configure_email', __('Create check web'), $status_check_web, true); -$table->data[1][0] = html_print_wizard_diagnosis(__('Create basic connectivity'), 'basic_connectivity', __('Create basic connectivity'), $status_check_connectivity, true); -$table->data[1][1] = html_print_wizard_diagnosis(__('Create basic net'), 'basic_net', __('Create basic net'), true, true); -$table->data[2][0] = html_print_wizard_diagnosis(__('Create Alert Mail'), 'alert_mail', __('Create Alert Mail'), true, true); -html_print_table($table); -?> - - - - - - 9], 'status')['status']; - if ($status_webserver === '1') { - $name = array_keys(servers_get_names())[0]; - $id_group = get_parameter('id_group', 4); - - $array_other['data'] = [ - 'Goliat', - '', - 2, - $id_group, - 0, - 30, - 30, - 9, - $name, - 0, - 0, - 0, - __('Agent goliat created on welcome'), - ]; - - $id_agent = api_set_new_agent(0, '', $array_other, '', true); - if ($id_agent > 0) { - $module_name = get_parameter('module_name', 'goliat_module'); - $text_to_search = get_parameter('text_to_search', ''); - $url_goliat = get_parameter('url_goliat', 'https://pandorafms.com/en/'); - $module_latency = create_module_latency_goliat($id_agent, $module_name, $id_group, $url_goliat, $text_to_search); - $module_status = create_module_status_goliat($id_agent, $module_name, $id_group, $url_goliat, $text_to_search); - if ($module_latency > 0 && $module_status > 0) { - ui_print_success_message(__('Your check has been created, click here to view the data. Please note that it may take a few seconds to see data if your server is busy')); - } - } else { - ui_print_error_message(__('The Name is not valid for the modules.')); - } - } else { - ui_print_error_message(__('Web server is not enabled.')); - } -} - - -/** - * Create_module_latency_goliat and return module id. - * - * @param mixed $id_agent Id agent. - * @param mixed $module_name Module name. - * @param mixed $id_group Id group. - * @param mixed $url_search Url to search. - * @param mixed $string_search Text to search. - * - * @return interger Module id. - */ -function create_module_latency_goliat($id_agent, $module_name, $id_group, $url_search, $string_search='') -{ - if ($string_search !== '') { - $str_search = 'check_string '.$string_search.''; - } - - include_once 'include/functions_modules.php'; - - $array_values = [ - 'id_tipo_modulo' => '30', - 'descripcion' => '', - 'max' => '0', - 'min' => '0', - 'snmp_oid' => '', - 'snmp_community' => 'public', - 'id_module_group' => $id_group, - 'module_interval' => '300', - 'module_ff_interval' => '0', - 'ip_target' => '', - 'tcp_port' => '0', - 'tcp_rcv' => '', - 'tcp_send' => '', - 'id_export' => '0', - 'plugin_user' => '', - 'plugin_pass' => '0', - 'plugin_parameter' => 'task_begin -get '.$url_search.' -resource 1 -'.$str_search.' -task_end', - 'id_plugin' => '0', - 'post_process' => '0', - 'prediction_module' => '0', - 'max_timeout' => '0', - 'max_retries' => '0', - 'disabled' => '', - 'id_modulo' => '7', - 'custom_id' => '', - 'history_data' => '1', - 'dynamic_interval' => '0', - 'dynamic_max' => '0', - 'dynamic_min' => '0', - 'dynamic_two_tailed' => '0', - 'parent_module_id' => '0', - 'min_warning' => '0', - 'max_warning' => '0', - 'str_warning' => '', - 'min_critical' => '0', - 'max_critical' => '0', - 'str_critical' => '', - 'custom_string_1' => '', - 'custom_string_2' => '', - 'custom_string_3' => '', - 'custom_integer_1' => '0', - 'custom_integer_2' => '0', - 'min_ff_event' => '0', - 'min_ff_event_normal' => '0', - 'min_ff_event_warning' => '0', - 'min_ff_event_critical' => '0', - 'ff_type' => '0', - 'each_ff' => '0', - 'ff_timeout' => '0', - 'unit' => '', - 'macros' => '', - 'quiet' => '0', - 'cps' => '0', - 'critical_instructions' => '', - 'warning_instructions' => '', - 'unknown_instructions' => '', - 'critical_inverse' => '0', - 'warning_inverse' => '0', - 'percentage_critical' => '0', - 'percentage_warning' => '0', - 'cron_interval' => '* * * * *', - 'id_category' => '0', - 'disabled_types_event' => '{\"going_unknown\":0}', - 'module_macros' => 'W10=', - 'warning_time' => '0', - ]; - return modules_create_agent_module($id_agent, $module_name.'_latency', $array_values); -} - - -/** - * Create_module_status_goliat and return module id. - * - * @param mixed $id_agent Id agent. - * @param mixed $module_name Module name. - * @param mixed $id_group Id group. - * @param mixed $url_search Url to search. - * @param mixed $string_search Text to search. - * - * @return interger Module id. - */ -function create_module_status_goliat($id_agent, $module_name, $id_group, $url_search, $string_search='') -{ - if ($string_search !== '') { - $str_search = 'check_string '.$string_search.' '; - } - - include_once 'include/functions_modules.php'; - - $array_values = [ - 'id_tipo_modulo' => '31', - 'descripcion' => '', - 'max' => '0', - 'min' => '0', - 'snmp_oid' => '', - 'snmp_community' => 'public', - 'id_module_group' => $id_group, - 'module_interval' => '300', - 'module_ff_interval' => '0', - 'ip_target' => '', - 'tcp_port' => '0', - 'tcp_rcv' => '', - 'tcp_send' => '', - 'id_export' => '0', - 'plugin_user' => '', - 'plugin_pass' => '0', - 'plugin_parameter' => 'task_begin -get '.$url_search.' -resource 1 -'.$str_search.' -task_end', - 'id_plugin' => '0', - 'post_process' => '0', - 'prediction_module' => '0', - 'max_timeout' => '0', - 'max_retries' => '0', - 'disabled' => '', - 'id_modulo' => '7', - 'custom_id' => '', - 'history_data' => '1', - 'dynamic_interval' => '0', - 'dynamic_max' => '0', - 'dynamic_min' => '0', - 'dynamic_two_tailed' => '0', - 'parent_module_id' => '0', - 'min_warning' => '0', - 'max_warning' => '0', - 'str_warning' => '', - 'min_critical' => '0', - 'max_critical' => '0', - 'str_critical' => '', - 'custom_string_1' => '', - 'custom_string_2' => '', - 'custom_string_3' => '', - 'custom_integer_1' => '0', - 'custom_integer_2' => '0', - 'min_ff_event' => '0', - 'min_ff_event_normal' => '0', - 'min_ff_event_warning' => '0', - 'min_ff_event_critical' => '0', - 'ff_type' => '0', - 'each_ff' => '0', - 'ff_timeout' => '0', - 'unit' => '', - 'macros' => '', - 'quiet' => '0', - 'cps' => '0', - 'critical_instructions' => '', - 'warning_instructions' => '', - 'unknown_instructions' => '', - 'critical_inverse' => '0', - 'warning_inverse' => '0', - 'percentage_critical' => '0', - 'percentage_warning' => '0', - 'cron_interval' => '* * * * *', - 'id_category' => '0', - 'disabled_types_event' => '{\"going_unknown\":0}', - 'module_macros' => 'W10=', - 'warning_time' => '0', - ]; - return modules_create_agent_module($id_agent, $module_name.'_status', $array_values); -} - - -if ($create_connectivity_dialog) { - ?> - - 1], 'status')['status']; - $status_pluggin = db_get_row_filter('tserver', ['server_type' => 4], 'status')['status']; - if ($status_newtwork === '1' && $status_pluggin === '1') { - $name = array_keys(servers_get_names())[0]; - $id_group = get_parameter('id_group', 4); - $agent_name = get_parameter('agent_name', __('Agent check connectivity')); - - $array_other['data'] = [ - $agent_name, - '', - 2, - $id_group, - 0, - 30, - 30, - 9, - $name, - 0, - 0, - 0, - __('Basic connectivity'), - ]; - - $id_agent = api_set_new_agent(0, '', $array_other, '', true); - if ($id_agent > 0) { - $ip_target = get_parameter('ip_target', '127.0.0.1'); - $basic_network = create_module_basic_network($id_agent, $id_group, $ip_target); - $latency_network = create_module_latency_network($id_agent, $id_group, $ip_target); - $packet_lost = create_module_packet_lost($id_agent, $id_group, $ip_target); - if ($basic_network > 0 && $latency_network > 0 && $packet_lost > 0) { - ui_print_success_message(__('Your check has been created, click here to view the data. Please note that it may take a few seconds to see data if your server is busy')); - } - } else { - ui_print_error_message(__('The Name is not valid for the modules.')); - } - } else { - ui_print_error_message(__('Web server is not enabled.')); - } -} - - -/** - * Create module basic network and return module id. - * - * @param mixed $id_agent Id agent. - * @param mixed $id_group Id group. - * @param mixed $ip_target Ip target. - * - * @return interger Module id. - */ -function create_module_basic_network($id_agent, $id_group, $ip_target) -{ - include_once 'include/functions_modules.php'; - - $array_values = [ - 'id_tipo_modulo' => '6', - 'descripcion' => 'Basic network check (ping)', - 'max' => '0', - 'min' => '0', - 'snmp_oid' => '', - 'snmp_community' => 'public', - 'id_module_group' => $id_group, - 'module_interval' => '300', - 'module_ff_interval' => '0', - 'ip_target' => $ip_target, - 'tcp_port' => '0', - 'tcp_rcv' => '', - 'tcp_send' => '', - 'id_export' => '0', - 'plugin_user' => '', - 'plugin_pass' => '0', - 'plugin_parameter' => '', - 'id_plugin' => '0', - 'post_process' => '0', - 'prediction_module' => '0', - 'max_timeout' => '0', - 'max_retries' => '0', - 'disabled' => '', - 'id_modulo' => '2', - 'custom_id' => '', - 'history_data' => '1', - 'dynamic_interval' => '0', - 'dynamic_max' => '0', - 'dynamic_min' => '0', - 'dynamic_two_tailed' => '0', - 'parent_module_id' => '0', - 'min_warning' => '0', - 'max_warning' => '0', - 'str_warning' => '', - 'min_critical' => '0', - 'max_critical' => '0', - 'str_critical' => '', - 'custom_string_1' => '', - 'custom_string_2' => '', - 'custom_string_3' => '', - 'custom_integer_1' => '0', - 'custom_integer_2' => '0', - 'min_ff_event' => '0', - 'min_ff_event_normal' => '0', - 'min_ff_event_warning' => '0', - 'min_ff_event_critical' => '0', - 'ff_type' => '0', - 'each_ff' => '0', - 'ff_timeout' => '0', - 'unit' => '', - 'macros' => '', - 'quiet' => '0', - 'cps' => '0', - 'critical_instructions' => '', - 'warning_instructions' => '', - 'unknown_instructions' => '', - 'critical_inverse' => '0', - 'warning_inverse' => '0', - 'percentage_critical' => '0', - 'percentage_warning' => '0', - 'cron_interval' => '* * * * *', - 'id_category' => '0', - 'disabled_types_event' => '{\"going_unknown\":0}', - 'module_macros' => 'W10=', - 'warning_time' => '0', - ]; - return modules_create_agent_module($id_agent, 'Basic_Network_Check', $array_values); -} - - -/** - * Create module latency network and return module id. - * - * @param mixed $id_agent Id agent. - * @param mixed $id_group Id group. - * @param mixed $ip_target Ip target. - * - * @return interger Module id. - */ -function create_module_latency_network($id_agent, $id_group, $ip_target) -{ - include_once 'include/functions_modules.php'; - - $array_values = [ - 'id_tipo_modulo' => '7', - 'descripcion' => 'Basic network connectivity check to measure network latency in miliseconds', - 'max' => '0', - 'min' => '0', - 'snmp_oid' => '', - 'snmp_community' => 'public', - 'id_module_group' => $id_group, - 'module_interval' => '300', - 'module_ff_interval' => '0', - 'ip_target' => $ip_target, - 'tcp_port' => '0', - 'tcp_rcv' => '', - 'tcp_send' => '', - 'id_export' => '0', - 'plugin_user' => '', - 'plugin_pass' => '0', - 'plugin_parameter' => '', - 'id_plugin' => '0', - 'post_process' => '0', - 'prediction_module' => '0', - 'max_timeout' => '0', - 'max_retries' => '0', - 'disabled' => '', - 'id_modulo' => '2', - 'custom_id' => '', - 'history_data' => '1', - 'dynamic_interval' => '0', - 'dynamic_max' => '0', - 'dynamic_min' => '0', - 'dynamic_two_tailed' => '1', - 'parent_module_id' => '0', - 'min_warning' => '0', - 'max_warning' => '0', - 'str_warning' => '', - 'min_critical' => '0', - 'max_critical' => '0', - 'str_critical' => '', - 'custom_string_1' => '', - 'custom_string_2' => '', - 'custom_string_3' => '', - 'custom_integer_1' => '0', - 'custom_integer_2' => '0', - 'min_ff_event' => '0', - 'min_ff_event_normal' => '0', - 'min_ff_event_warning' => '0', - 'min_ff_event_critical' => '0', - 'ff_type' => '0', - 'each_ff' => '0', - 'ff_timeout' => '0', - 'unit' => '', - 'macros' => '', - 'quiet' => '0', - 'cps' => '0', - 'critical_instructions' => '', - 'warning_instructions' => '', - 'unknown_instructions' => '', - 'critical_inverse' => '0', - 'warning_inverse' => '0', - 'percentage_critical' => '0', - 'percentage_warning' => '0', - 'cron_interval' => '* * * * *', - 'id_category' => '0', - 'disabled_types_event' => '{\"going_unknown\":0}', - 'module_macros' => 'W10=', - 'warning_time' => '0', - ]; - return modules_create_agent_module($id_agent, 'Basic_Network_Latency', $array_values); -} - - -/** - * Create module packet lost and return module id. - * - * @param mixed $id_agent Id agent. - * @param mixed $id_group Id group. - * @param mixed $ip_target Ip target. - * - * @return interger Module id. - */ -function create_module_packet_lost($id_agent, $id_group, $ip_target) -{ - include_once 'include/functions_modules.php'; - - $array_values = [ - 'id_tipo_modulo' => '1', - 'descripcion' => 'Basic network connectivity check to measure packet loss in %', - 'max' => '0', - 'min' => '0', - 'snmp_oid' => '', - 'snmp_community' => 'public', - 'id_module_group' => $id_group, - 'module_interval' => '300', - 'module_ff_interval' => '0', - 'ip_target' => '', - 'tcp_port' => '0', - 'tcp_rcv' => '', - 'tcp_send' => '', - 'id_export' => '0', - 'plugin_user' => '', - 'plugin_pass' => '0', - 'plugin_parameter' => '', - 'id_plugin' => '9', - 'post_process' => '0', - 'prediction_module' => '0', - 'max_timeout' => '0', - 'max_retries' => '0', - 'disabled' => '', - 'id_modulo' => '4', - 'custom_id' => '', - 'history_data' => '1', - 'dynamic_interval' => '0', - 'dynamic_max' => '0', - 'dynamic_min' => '0', - 'dynamic_two_tailed' => '1', - 'parent_module_id' => '0', - 'min_warning' => '0', - 'max_warning' => '0', - 'str_warning' => '', - 'min_critical' => '0', - 'max_critical' => '0', - 'str_critical' => '', - 'custom_string_1' => '', - 'custom_string_2' => '', - 'custom_string_3' => '', - 'custom_integer_1' => '0', - 'custom_integer_2' => '0', - 'min_ff_event' => '0', - 'min_ff_event_normal' => '0', - 'min_ff_event_warning' => '0', - 'min_ff_event_critical' => '0', - 'ff_type' => '0', - 'each_ff' => '0', - 'ff_timeout' => '0', - 'unit' => '', - 'macros' => '{"1":{"macro":"_field1_","desc":"Test time","help":"","value":"8","hide":""},"2":{"macro":"_field2_","desc":"Target IP","help":"","value":"'.$ip_target.'","hide":""}}', - 'quiet' => '0', - 'cps' => '0', - 'critical_instructions' => '', - 'warning_instructions' => '', - 'unknown_instructions' => '', - 'critical_inverse' => '0', - 'warning_inverse' => '0', - 'percentage_critical' => '0', - 'percentage_warning' => '0', - 'cron_interval' => '* * * * *', - 'id_category' => '0', - 'disabled_types_event' => '{\"going_unknown\":0}', - 'module_macros' => 'W10=', - 'warning_time' => '0', - ]; - return modules_create_agent_module($id_agent, 'Basic_Network_Packetloss', $array_values); -} - - -if ($create_net_scan_dialog) { - ?> - - 0) { - $id_recon_server = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_DISCOVERY], 'id_server')['id_server']; - ui_print_success_message(__('Basic net created and scan in progress. Click here to view the data. Please note that it may take a few seconds to see data if your server is busy')); - } else { - ui_print_error_message(__('Basic net already exists. Click here to view the data')); - } -} - - -/** - * Create module packet lost and return module id. - * - * @param string $ip_target Ip and red mask. - * - * @return interger Module id. - */ -function create_net_scan($ip_target) -{ - global $config; - include_once 'HostDevices.class.php'; - $HostDevices = new HostDevices(1); - $id_recon_server = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_DISCOVERY], 'id_server')['id_server']; - - $_POST = [ - 'page' => '1', - 'interval_manual_defined' => '1', - 'interval_select' => '-1', - 'interval_text' => '0', - 'interval' => '0', - 'interval_units' => '1', - 'taskname' => __('Basic network'), - 'id_recon_server' => $id_recon_server, - 'network' => $ip_target, - 'id_group' => '8', - 'comment' => __('Created on welcome'), - ]; - $task_created = $HostDevices->parseNetScan(); - if ($task_created === true) { - $HostDevicesFinal = new HostDevices(2); - $_POST = [ - 'task' => $HostDevices->task['id_rt'], - 'page' => '2', - 'recon_ports' => '', - 'auto_monitor' => 'on', - 'id_network_profile' => ['0' => '2'], - 'review_results' => 'on', - 'review_limited' => '0', - 'snmp_enabled' => 'on', - 'snmp_version' => '1', - 'snmp_skip_non_enabled_ifs' => 'on', - 'community' => '', - 'snmp_context' => '', - 'snmp_auth_user' => '', - 'snmp_security_level' => 'authNoPriv', - 'snmp_auth_method' => 'MD5', - 'snmp_auth_pass' => '', - 'snmp_privacy_method' => 'AES', - 'snmp_privacy_pass' => '', - 'os_detect' => 'on', - 'resolve_names' => 'on', - 'parent_detection' => 'on', - 'parent_recursion' => 'on', - 'vlan_enabled' => 'on', - ]; - - $task_final_created = $HostDevicesFinal->parseNetScan(); - if ($task_final_created === true) { - $net_scan_id = $HostDevices->task['id_rt']; - unset($HostDevices, $HostDevicesFinal); - return $net_scan_id; - } - } else { - return 0; - } -} - - -if ($create_alert_mail_dialog) { - ?> - - 'Email to '.$config['id_user']], 'id')['id']; - if (!$id_action) { - $al_action = alerts_get_alert_action($id); - $id_action = alerts_clone_alert_action(1, $al_action['id_group'], 'Email to '.$config['id_user']); - } - - $id_alert_template = get_parameter('id_condition', 0); - $id_agent_module = get_parameter('id_agent_module', 0); - - $exist = db_get_value_sql( - sprintf( - 'SELECT COUNT(id) - FROM talert_template_modules - WHERE id_agent_module = %d - AND id_alert_template = %d - AND id_policy_alerts = 0 - ', - $id_agent_module, - $id_alert_template - ) - ); - - if ($exist > 0) { - ui_print_error_message(__('Alert already exists. Click here to view the data')); - } else { - $id = alerts_create_alert_agent_module($id_agent_module, $id_alert_template); - if ($id !== false) { - $values = []; - $values['fires_min'] = (int) get_parameter('fires_min'); - $values['fires_max'] = (int) get_parameter('fires_max'); - $values['module_action_threshold'] = (int) 300; - - $alert_created = alerts_add_alert_agent_module_action($id, $id_action, $values); - } - } - - if ($alert_created === true) { - ui_print_success_message(__('Congratulations, you have already created a simple alert. You can see it. Pandora FMS alerts are very flexible, you can do many more things with them, we recommend you to read the documentation for more information. You can create advanced alerts from here.')); - } -} \ No newline at end of file diff --git a/pandora_console/include/ajax/task_to_perform.php b/pandora_console/include/ajax/task_to_perform.php new file mode 100644 index 0000000000..c889c37f8d --- /dev/null +++ b/pandora_console/include/ajax/task_to_perform.php @@ -0,0 +1,181 @@ + SERVER_TYPE_WEB], 'status')['status']; + if ($status_webserver === '1') { + $name = array_keys(servers_get_names())[0]; + $id_group = get_parameter('id_group', 4); + + $array_other['data'] = [ + 'Web monitoring', + '', + 2, + $id_group, + 0, + 30, + 30, + 9, + $name, + 0, + 0, + 0, + __('Agent Web monitoring created on welcome'), + ]; + + $id_agent = api_set_new_agent(0, '', $array_other, '', true); + if ($id_agent > 0) { + $module_name = get_parameter('module_name', 'Web_monitoring_module'); + $text_to_search = get_parameter('text_to_search', ''); + $url_goliat = get_parameter('url_goliat', 'https://pandorafms.com/en/'); + $module_latency = create_module_latency_goliat($id_agent, $module_name, $id_group, $url_goliat, $text_to_search); + $module_status = create_module_status_goliat($id_agent, $module_name, $id_group, $url_goliat, $text_to_search); + if ($module_latency > 0 && $module_status > 0) { + ui_print_success_message(__('Your check has been created, click here to view the data. Please note that it may take a few seconds to see data if your server is busy')); + } + } else { + ui_print_error_message(__('The Name is not valid for the modules.')); + } + } else { + ui_print_error_message(__('Web server is not enabled.')); + } +} + +if ($check_connectivity) { + include_once '../functions_api.php'; + include_once '../functions_servers.php'; + + $status_newtwork = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_NETWORK], 'status')['status']; + $status_pluggin = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_PLUGIN], 'status')['status']; + if ($status_newtwork === '1' && $status_pluggin === '1') { + $name = array_keys(servers_get_names())[0]; + $id_group = get_parameter('id_group', 4); + $agent_name = get_parameter('agent_name', __('Agent check connectivity')); + + $array_other['data'] = [ + $agent_name, + '', + 2, + $id_group, + 0, + 30, + 30, + 9, + $name, + 0, + 0, + 0, + __('Basic connectivity'), + ]; + + $id_agent = api_set_new_agent(0, '', $array_other, '', true); + if ($id_agent > 0) { + $ip_target = get_parameter('ip_target', '127.0.0.1'); + $basic_network = create_module_basic_network($id_agent, $id_group, $ip_target); + $latency_network = create_module_latency_network($id_agent, $id_group, $ip_target); + $packet_lost = create_module_packet_lost($id_agent, $id_group, $ip_target); + if ($basic_network > 0 && $latency_network > 0 && $packet_lost > 0) { + ui_print_success_message(__('Your check has been created, click here to view the data. Please note that it may take a few seconds to see data if your server is busy')); + } + } else { + ui_print_error_message(__('The Name is not valid for the modules.')); + } + } else { + ui_print_error_message(__('Web server is not enabled.')); + } +} + +if ($create_net_scan) { + $ip_target = get_parameter('ip_target', '192.168.10.0/24'); + $id_net_scan = create_net_scan($ip_target); + if ($id_net_scan > 0) { + $id_recon_server = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_DISCOVERY], 'id_server')['id_server']; + ui_print_success_message(__('Basic net created and scan in progress. Click here to view the data. Please note that it may take a few seconds to see data if your server is busy')); + } else { + ui_print_error_message(__('Basic net already exists. Click here to view the data')); + } +} + +if ($create_mail_alert) { + include_once '../functions_alerts.php'; + $id_action = db_get_row_filter('talert_actions', ['name' => 'Email to '.$config['id_user']], 'id')['id']; + if (!$id_action) { + $al_action = alerts_get_alert_action($id); + $id_action = alerts_clone_alert_action(1, $al_action['id_group'], 'Email to '.$config['id_user']); + } + + $id_alert_template = get_parameter('id_condition', 0); + $id_agent_module = get_parameter('id_agent_module', 0); + + $exist = db_get_value_sql( + sprintf( + 'SELECT COUNT(id) + FROM talert_template_modules + WHERE id_agent_module = %d + AND id_alert_template = %d + AND id_policy_alerts = 0 + ', + $id_agent_module, + $id_alert_template + ) + ); + + if ($exist > 0) { + ui_print_error_message(__('Alert already exists. Click here to view the data')); + } else { + $id = alerts_create_alert_agent_module($id_agent_module, $id_alert_template); + if ($id !== false) { + $values = []; + $values['fires_min'] = (int) get_parameter('fires_min'); + $values['fires_max'] = (int) get_parameter('fires_max'); + $values['module_action_threshold'] = (int) 300; + + $alert_created = alerts_add_alert_agent_module_action($id, $id_action, $values); + } + } + + if ($alert_created === true) { + ui_print_success_message(__('Congratulations, you have already created a simple alert. You can see it. Pandora FMS alerts are very flexible, you can do many more things with them, we recommend you to read the documentation for more information. You can create advanced alerts from here.')); + } +} diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index 339d72afd8..be86c7deb6 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -374,34 +374,37 @@ class WelcomeWindow extends Wizard $flag_su = false; $flag_lv = false; - $btn_update_manager_class = ' pending'; - $btn_configure_mail_class = ' pending'; - $btn_servers_up_class = ' pending'; - $btn_license_valid_class = ' pending'; + $btn_update_manager_class = ' fail'; + $btn_configure_mail_class = ' fail'; + $btn_servers_up_class = ' fail'; + $btn_license_valid_class = ' fail'; $li_update_manager_class = 'row_grey'; $li_configure_mail_class = 'row_grey'; $li_servers_up_class = 'row_grey'; $li_license_valid_class = 'row_grey'; - if ($config['pandora_uid'] === 'ONLINE') { - $btn_update_manager_class = ' completed'; + include_once 'include/functions_update_manager.php'; + if (update_manager_verify_registration()) { + $btn_update_manager_class = ''; $li_update_manager_class = 'row_green'; $flag_um = true; } if (empty($config['welcome_mail_configured']) === false) { - $btn_configure_mail_class = ' completed'; + $btn_configure_mail_class = ''; + $li_configure_mail_class = 'row_green'; $flag_cm = true; } include_once 'include/functions_servers.php'; if (check_all_servers_up() === true) { - $btn_servers_up_class = ' completed'; + $btn_servers_up_class = ''; $li_servers_up_class = 'row_green'; $flag_su = true; } + $show_license = true; if (enterprise_installed()) { $license_valid = true; enterprise_include_once('include/functions_license.php'); @@ -412,10 +415,12 @@ class WelcomeWindow extends Wizard } if ($license_valid === true) { - $btn_license_valid_class = ' completed'; + $btn_license_valid_class = ''; $li_license_valid_class = 'row_green'; $flag_lv = true; } + } else { + $show_license = false; } $inputs[] = [ @@ -425,7 +430,7 @@ class WelcomeWindow extends Wizard 'direct' => 1, 'block_content' => [ [ - 'label' => __('Mini-diagnosis'), + 'label' => __('Post-installation status diagnostic'), 'arguments' => [ 'class' => 'first_lbl', 'name' => 'lbl_diagnosis', @@ -443,7 +448,7 @@ class WelcomeWindow extends Wizard 'direct' => 1, 'block_content' => [ [ - 'label' => __('Verification update manager register'), + 'label' => __('Warp Update registration'), 'arguments' => [ 'class' => 'first_lbl', 'name' => 'lbl_update_manager', @@ -471,7 +476,7 @@ class WelcomeWindow extends Wizard 'direct' => 1, 'block_content' => [ [ - 'label' => __('Please ensure mail configuration matches your needs'), + 'label' => __('Default mail to send alerts'), 'arguments' => [ 'class' => 'first_lbl', 'name' => 'lbl_create_agent', @@ -499,7 +504,7 @@ class WelcomeWindow extends Wizard 'direct' => 1, 'block_content' => [ [ - 'label' => __('All servers up'), + 'label' => __('All servers running'), 'arguments' => [ 'class' => 'first_lbl', 'name' => 'lbl_servers_up', @@ -520,36 +525,37 @@ class WelcomeWindow extends Wizard ], ], ]; - $inputs[] = [ - 'wrapper' => 'div', - 'block_id' => 'div_license_valid', - 'class' => 'hole flex-row flex-items-center w98p '.$li_license_valid_class, - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('Valid license verification and expiration greater than 30 days'), - 'arguments' => [ - 'class' => 'first_lbl', - 'name' => 'lbl_license_valid', - 'id' => 'lbl_license_valid', - ], - ], - [ - 'arguments' => [ - 'label' => '', - 'type' => 'button', - 'attributes' => [ - 'class' => (empty($btn_license_valid_class) === false) ? $btn_license_valid_class : 'invisible_important', - 'mode' => 'onlyIcon', + if ($show_license) { + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_license_valid', + 'class' => 'hole flex-row flex-items-center w98p '.$li_license_valid_class, + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Enterprise licence valid'), + 'arguments' => [ + 'class' => 'first_lbl', + 'name' => 'lbl_license_valid', + 'id' => 'lbl_license_valid', + ], + ], + [ + 'arguments' => [ + 'label' => '', + 'type' => 'button', + 'attributes' => [ + 'class' => (empty($btn_license_valid_class) === false) ? $btn_license_valid_class : 'invisible_important', + 'mode' => 'onlyIcon', + ], + 'name' => 'btn_license_valid_conf', + 'id' => 'btn_license_valid_conf', ], - 'name' => 'btn_license_valid_conf', - 'id' => 'btn_license_valid_conf', ], ], - ], - ]; + ]; + } } else { - $key = db_get_value_sql('SELECT `value` FROM tupdate_settings WHERE `key` = "customer_key"'); $inputs[] = [ 'wrapper' => 'div', 'block_id' => 'div_all_correct', @@ -557,7 +563,7 @@ class WelcomeWindow extends Wizard 'direct' => 1, 'block_content' => [ [ - 'label' => __('It seems that your Pandora FMS is working correctly and registered with ID:
#'.$key.'.
For more information use the self-diagnosis tool.'), + 'label' => __('It seems that your Pandora FMS is working correctly and registered with ID:
#'.$config['pandora_uid'].'.
For more information use the self-diagnosis tool.'), 'arguments' => [ 'class' => 'first_lbl w98p', 'name' => 'lbl_all_correct', @@ -591,159 +597,39 @@ class WelcomeWindow extends Wizard ], ]; + $fields['wizard_agent'] = __('Agent installation wizard'); + $fields['check_web'] = __('Create WEB monitoring'); + $fields['check_connectivity'] = __('Create network monitoring'); + $fields['check_net'] = __('Discover my network'); + $fields['check_mail_alert'] = __('Create email alert'); + $inputs[] = [ 'wrapper' => 'div', 'block_id' => 'div_wizard_agent', - 'class' => 'hole flex-row flex-items-center w98p row_grey', + 'class' => 'flex space-between w98p', 'direct' => 1, 'block_content' => [ [ - 'label' => __('Wizard install agent'), 'arguments' => [ - 'class' => 'first_lbl row_grey', - 'name' => 'lbl_wizard_agent', - 'id' => 'lbl_wizard_agent', + 'type' => 'select', + 'fields' => $fields, + 'name' => 'task_to_perform', + 'selected' => '', + 'return' => true, + 'nothing' => \__('Please select one'), + 'nothing_value' => '', ], ], [ 'arguments' => [ - 'label' => '', + 'label' => __('Let`s do it!'), 'type' => 'button', 'attributes' => [ - 'class' => 'completed', - 'mode' => 'onlyIcon', + 'class' => 'secondary', + 'icon' => 'next', ], - 'name' => 'btn_wizard_agent_conf', - 'id' => 'btn_wizard_agent_conf', - ], - ], - ], - ]; - - $status_webserver = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_WEB], 'status')['status']; - $check_web_color = 'row_grey'; - if ($status_webserver === '1') { - $check_web_color = 'row_green'; - } - - $inputs[] = [ - 'wrapper' => 'div', - 'block_id' => 'div_check_web', - 'class' => 'hole flex-row flex-items-center w98p '.$check_web_color, - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('Create check web'), - 'arguments' => [ - 'class' => 'first_lbl row_grey', - 'name' => 'lbl_check_web', - 'id' => 'lbl_check_web', - ], - ], - [ - 'arguments' => [ - 'label' => '', - 'type' => 'button', - 'attributes' => [ - 'class' => 'completed', - 'mode' => 'onlyIcon', - ], - 'name' => 'btn_check_web_conf', - 'id' => 'btn_check_web_conf', - ], - ], - ], - ]; - - $status_newtwork = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_NETWORK], 'status')['status']; - $status_pluggin = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_PLUGIN], 'status')['status']; - $check_connectivity = 'row_grey'; - if ($status_newtwork === '1' && $status_pluggin === '1') { - $check_connectivity = 'row_green'; - } - - $inputs[] = [ - 'wrapper' => 'div', - 'block_id' => 'div_check_connectivity', - 'class' => 'hole flex-row flex-items-center w98p '.$check_connectivity, - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('Create basic connectivity'), - 'arguments' => [ - 'class' => 'first_lbl row_grey', - 'name' => 'lbl_check_connectivity', - 'id' => 'lbl_check_connectivity', - ], - ], - [ - 'arguments' => [ - 'label' => '', - 'type' => 'button', - 'attributes' => [ - 'class' => 'completed', - 'mode' => 'onlyIcon', - ], - 'name' => 'btn_check_connectivity_conf', - 'id' => 'btn_check_connectivity_conf', - ], - ], - ], - ]; - - $inputs[] = [ - 'wrapper' => 'div', - 'block_id' => 'div_check_net', - 'class' => 'hole flex-row flex-items-center w98p row_green', - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('Create basic net'), - 'arguments' => [ - 'class' => 'first_lbl row_grey', - 'name' => 'lbl_check_net', - 'id' => 'lbl_check_net', - ], - ], - [ - 'arguments' => [ - 'label' => '', - 'type' => 'button', - 'attributes' => [ - 'class' => 'completed', - 'mode' => 'onlyIcon', - ], - 'name' => 'btn_check_net_conf', - 'id' => 'btn_check_net_conf', - ], - ], - ], - ]; - - $inputs[] = [ - 'wrapper' => 'div', - 'block_id' => 'div_check_mail_alert', - 'class' => 'hole flex-row flex-items-center w98p row_green', - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('Create Alert Mail'), - 'arguments' => [ - 'class' => 'first_lbl row_grey', - 'name' => 'lbl_check_mail_alert', - 'id' => 'lbl_check_mail_alert', - ], - ], - [ - 'arguments' => [ - 'label' => '', - 'type' => 'button', - 'attributes' => [ - 'class' => 'completed', - 'mode' => 'onlyIcon', - ], - 'name' => 'btn_check_mail_alert_conf', - 'id' => 'btn_check_mail_alert_conf', + 'name' => 'go_wizard', + 'id' => 'go_wizard', ], ], ], @@ -759,7 +645,233 @@ class WelcomeWindow extends Wizard $output .= $this->loadJS($flag_task); echo $output; + ?> + + + + + // Task to do buttons. - document.getElementById("button-btn_wizard_agent_conf").setAttribute( - 'onclick', - 'deployAgent()' - ); + $('#button-go_wizard').click(function(){ + if ($('#task_to_perform :selected').val() === '') { + alert(""); + } else { + switch($('#task_to_perform :selected').val()) { + case 'wizard_agent': + deployAgent(); + break; + case 'check_mail_alert': + openCreateAlertMailDialog(); + break; + case 'check_connectivity': + openCreateConnectivityDialog(); + break; + case 'check_web': + openCreateModulesDialog(); + break; + case 'check_net': + openCreateBasicNetDialog(); + break; + }; + } + }); - document.getElementById("button-btn_check_web_conf").setAttribute( - 'onclick', - 'openCreateModulesDialog()' - ); + // Task to do buttons. + $('#button-go_wizard').click(function(){ + if ($('#task_to_perform :selected').val() === '') { + alert(""); + } else { + switch($('#task_to_perform :selected').val()) { + case 'wizard_agent': + deployAgent(); + break; + case 'check_mail_alert': + openCreateAlertMailDialog(); + break; + case 'check_connectivity': + openCreateConnectivityDialog(); + break; + case 'check_web': + openCreateModulesDialog(); + break; + case 'check_net': + openCreateBasicNetDialog(); + break; + }; + } + }); - document.getElementById("button-btn_check_connectivity_conf").setAttribute( - 'onclick', - 'openCreateConnectivityDialog()' - ); + // Task to do buttons. + $('#button-go_wizard').click(function(){ + if ($('#task_to_perform :selected').val() === '') { + alert(""); + } else { + switch($('#task_to_perform :selected').val()) { + case 'wizard_agent': + deployAgent(); + break; + case 'check_mail_alert': + openCreateAlertMailDialog(); + break; + case 'check_connectivity': + openCreateConnectivityDialog(); + break; + case 'check_web': + openCreateModulesDialog(); + break; + case 'check_net': + openCreateBasicNetDialog(); + break; + }; + } + }); - document.getElementById("button-btn_check_net_conf").setAttribute( - 'onclick', - 'openCreateBasicNetDialog()' - ); - - document.getElementById("button-btn_check_mail_alert_conf").setAttribute( - 'onclick', - 'openCreateAlertMailDialog()' - ); + // Task to do buttons. + $('#button-go_wizard').click(function(){ + if ($('#task_to_perform :selected').val() === '') { + alert(""); + } else { + switch($('#task_to_perform :selected').val()) { + case 'wizard_agent': + deployAgent(); + break; + case 'check_mail_alert': + openCreateAlertMailDialog(); + break; + case 'check_connectivity': + openCreateConnectivityDialog(); + break; + case 'check_web': + openCreateModulesDialog(); + break; + case 'check_net': + openCreateBasicNetDialog(); + break; + }; + } + }); function configureUpdateManager() { window.location = ''; @@ -1052,29 +1238,173 @@ class WelcomeWindow extends Wizard window.location = ''; } + // Task to do actions. function deployAgent() { window.location = ''; } function openCreateModulesDialog() { - window.location = ''; + $('#dialog_goliat').dialog({ + title: '', + resizable: true, + draggable: true, + modal: true, + close: false, + height: 375, + width: 480, + overlay: { + opacity: 0.5, + background: "black" + } + }) + .show(); } function openCreateConnectivityDialog() { - window.location = ''; + $('#dialog_connectivity').dialog({ + title: '', + resizable: true, + draggable: true, + modal: true, + close: false, + height: 350, + width: 480, + overlay: { + opacity: 0.5, + background: "black" + } + }) + .show(); } function openCreateBasicNetDialog() { - window.location = ''; + $('#dialog_basic_net').dialog({ + title: '', + resizable: true, + draggable: true, + modal: true, + close: false, + height: 200, + width: 480, + overlay: { + opacity: 0.5, + background: "black" + } + }) + .show(); } function openCreateAlertMailDialog() { - window.location = ''; + $('#dialog_alert_mail').dialog({ + title: '', + resizable: true, + draggable: true, + modal: true, + close: false, + height: 350, + width: 480, + overlay: { + opacity: 0.5, + background: "black" + } + }) + .show(); } - function cierre_dialog(){ - this.dialog("close"); - } + $('#button-create_goliat').click(function(){ + $.ajax({ + async: false, + type: "POST", + url: "include/ajax/task_to_perform.php", + data: { + check_web: 1, + id_group: $('#id_group :selected').val(), + module_name: $('#text-module_name').val(), + text_to_search: $('#text-text_to_search').val(), + url_goliat: $('#text-url_goliat').val(), + }, + success: function(data) { + if (data !== 0) { + data = data.replace(/(\r\n|\n|\r)/gm, ""); + console.log(data); + $('body').append(data); + // Close dialog + $('.ui-dialog-titlebar-close').trigger('click'); + return false; + } + } + }); + }); + + $('#button-create_conectivity').click(function(){ + $.ajax({ + async: false, + type: "POST", + url: "include/ajax/task_to_perform.php", + data: { + check_connectivity: 1, + id_group: $('#id_group :selected').val(), + ip_target: $('#text-ip_target').val(), + agent_name: $('#text-agent_name').val(), + }, + success: function(data) { + if (data !== 0) { + data = data.replace(/(\r\n|\n|\r)/gm, ""); + console.log(data); + $('body').append(data); + // Close dialog + $('.ui-dialog-titlebar-close').trigger('click'); + return false; + } + } + }); + }); + + $('#button-basic_net').click(function(){ + $.ajax({ + async: false, + type: "POST", + url: "include/ajax/task_to_perform.php", + data: { + create_net_scan: 1, + ip_target: $('#text-ip_target').val(), + }, + success: function(data) { + if (data !== 0) { + data = data.replace(/(\r\n|\n|\r)/gm, ""); + console.log(data); + $('body').append(data); + // Close dialog + $('.ui-dialog-titlebar-close').trigger('click'); + return false; + } + } + }); + }); + + $('#button-alert_mail').click(function(){ + $.ajax({ + async: false, + type: "POST", + url: "include/ajax/task_to_perform.php", + data: { + create_mail_alert: 1, + id_condition: $('#text-ip_target').val(), + id_agent_module: $('#text-ip_target').val(), + }, + success: function(data) { + if (data !== 0) { + data = data.replace(/(\r\n|\n|\r)/gm, ""); + console.log(data); + $('body').append(data); + // Close dialog + $('.ui-dialog-titlebar-close').trigger('click'); + return false; + } + } + }); + }); + '.$sub['text'].'
'; + } else if (isset($sub['subtype']) && $sub['subtype'] == 'nolink_no_arrow') { + $submenu_output .= ''; } else if (isset($sub['subtype']) && $sub['subtype'] == 'new_blank') { $submenu_output .= '
'.$sub['text'].'
'; } else { diff --git a/pandora_console/include/functions_welcome_wizard.php b/pandora_console/include/functions_welcome_wizard.php new file mode 100644 index 0000000000..6993f16224 --- /dev/null +++ b/pandora_console/include/functions_welcome_wizard.php @@ -0,0 +1,537 @@ + '30', + 'descripcion' => '', + 'max' => '0', + 'min' => '0', + 'snmp_oid' => '', + 'snmp_community' => 'public', + 'id_module_group' => $id_group, + 'module_interval' => '300', + 'module_ff_interval' => '0', + 'ip_target' => '', + 'tcp_port' => '0', + 'tcp_rcv' => '', + 'tcp_send' => '', + 'id_export' => '0', + 'plugin_user' => '', + 'plugin_pass' => '0', + 'plugin_parameter' => 'task_begin +get '.$url_search.' +resource 1 +'.$str_search.' +task_end', + 'id_plugin' => '0', + 'post_process' => '0', + 'prediction_module' => '0', + 'max_timeout' => '0', + 'max_retries' => '0', + 'disabled' => '', + 'id_modulo' => '7', + 'custom_id' => '', + 'history_data' => '1', + 'dynamic_interval' => '0', + 'dynamic_max' => '0', + 'dynamic_min' => '0', + 'dynamic_two_tailed' => '0', + 'parent_module_id' => '0', + 'min_warning' => '0', + 'max_warning' => '0', + 'str_warning' => '', + 'min_critical' => '0', + 'max_critical' => '0', + 'str_critical' => '', + 'custom_string_1' => '', + 'custom_string_2' => '', + 'custom_string_3' => '', + 'custom_integer_1' => '0', + 'custom_integer_2' => '0', + 'min_ff_event' => '0', + 'min_ff_event_normal' => '0', + 'min_ff_event_warning' => '0', + 'min_ff_event_critical' => '0', + 'ff_type' => '0', + 'each_ff' => '0', + 'ff_timeout' => '0', + 'unit' => '', + 'macros' => '', + 'quiet' => '0', + 'cps' => '0', + 'critical_instructions' => '', + 'warning_instructions' => '', + 'unknown_instructions' => '', + 'critical_inverse' => '0', + 'warning_inverse' => '0', + 'percentage_critical' => '0', + 'percentage_warning' => '0', + 'cron_interval' => '* * * * *', + 'id_category' => '0', + 'disabled_types_event' => '{\"going_unknown\":0}', + 'module_macros' => 'W10=', + 'warning_time' => '0', + ]; + return modules_create_agent_module($id_agent, $module_name.'_latency', $array_values); +} + + +/** + * Create_module_status_goliat and return module id. + * + * @param mixed $id_agent Id agent. + * @param mixed $module_name Module name. + * @param mixed $id_group Id group. + * @param mixed $url_search Url to search. + * @param mixed $string_search Text to search. + * + * @return interger Module id. + */ +function create_module_status_goliat($id_agent, $module_name, $id_group, $url_search, $string_search='') +{ + if ($string_search !== '') { + $str_search = 'check_string '.$string_search.' '; + } + + include_once 'include/functions_modules.php'; + + $array_values = [ + 'id_tipo_modulo' => '31', + 'descripcion' => '', + 'max' => '0', + 'min' => '0', + 'snmp_oid' => '', + 'snmp_community' => 'public', + 'id_module_group' => $id_group, + 'module_interval' => '300', + 'module_ff_interval' => '0', + 'ip_target' => '', + 'tcp_port' => '0', + 'tcp_rcv' => '', + 'tcp_send' => '', + 'id_export' => '0', + 'plugin_user' => '', + 'plugin_pass' => '0', + 'plugin_parameter' => 'task_begin +get '.$url_search.' +resource 1 +'.$str_search.' +task_end', + 'id_plugin' => '0', + 'post_process' => '0', + 'prediction_module' => '0', + 'max_timeout' => '0', + 'max_retries' => '0', + 'disabled' => '', + 'id_modulo' => '7', + 'custom_id' => '', + 'history_data' => '1', + 'dynamic_interval' => '0', + 'dynamic_max' => '0', + 'dynamic_min' => '0', + 'dynamic_two_tailed' => '0', + 'parent_module_id' => '0', + 'min_warning' => '0', + 'max_warning' => '0', + 'str_warning' => '', + 'min_critical' => '0', + 'max_critical' => '0', + 'str_critical' => '', + 'custom_string_1' => '', + 'custom_string_2' => '', + 'custom_string_3' => '', + 'custom_integer_1' => '0', + 'custom_integer_2' => '0', + 'min_ff_event' => '0', + 'min_ff_event_normal' => '0', + 'min_ff_event_warning' => '0', + 'min_ff_event_critical' => '0', + 'ff_type' => '0', + 'each_ff' => '0', + 'ff_timeout' => '0', + 'unit' => '', + 'macros' => '', + 'quiet' => '0', + 'cps' => '0', + 'critical_instructions' => '', + 'warning_instructions' => '', + 'unknown_instructions' => '', + 'critical_inverse' => '0', + 'warning_inverse' => '0', + 'percentage_critical' => '0', + 'percentage_warning' => '0', + 'cron_interval' => '* * * * *', + 'id_category' => '0', + 'disabled_types_event' => '{\"going_unknown\":0}', + 'module_macros' => 'W10=', + 'warning_time' => '0', + ]; + return modules_create_agent_module($id_agent, $module_name.'_status', $array_values); +} + + +/** + * Create module basic network and return module id. + * + * @param mixed $id_agent Id agent. + * @param mixed $id_group Id group. + * @param mixed $ip_target Ip target. + * + * @return interger Module id. + */ +function create_module_basic_network($id_agent, $id_group, $ip_target) +{ + include_once 'include/functions_modules.php'; + + $array_values = [ + 'id_tipo_modulo' => '6', + 'descripcion' => 'Basic network check (ping)', + 'max' => '0', + 'min' => '0', + 'snmp_oid' => '', + 'snmp_community' => 'public', + 'id_module_group' => $id_group, + 'module_interval' => '300', + 'module_ff_interval' => '0', + 'ip_target' => $ip_target, + 'tcp_port' => '0', + 'tcp_rcv' => '', + 'tcp_send' => '', + 'id_export' => '0', + 'plugin_user' => '', + 'plugin_pass' => '0', + 'plugin_parameter' => '', + 'id_plugin' => '0', + 'post_process' => '0', + 'prediction_module' => '0', + 'max_timeout' => '0', + 'max_retries' => '0', + 'disabled' => '', + 'id_modulo' => '2', + 'custom_id' => '', + 'history_data' => '1', + 'dynamic_interval' => '0', + 'dynamic_max' => '0', + 'dynamic_min' => '0', + 'dynamic_two_tailed' => '0', + 'parent_module_id' => '0', + 'min_warning' => '0', + 'max_warning' => '0', + 'str_warning' => '', + 'min_critical' => '0', + 'max_critical' => '0', + 'str_critical' => '', + 'custom_string_1' => '', + 'custom_string_2' => '', + 'custom_string_3' => '', + 'custom_integer_1' => '0', + 'custom_integer_2' => '0', + 'min_ff_event' => '0', + 'min_ff_event_normal' => '0', + 'min_ff_event_warning' => '0', + 'min_ff_event_critical' => '0', + 'ff_type' => '0', + 'each_ff' => '0', + 'ff_timeout' => '0', + 'unit' => '', + 'macros' => '', + 'quiet' => '0', + 'cps' => '0', + 'critical_instructions' => '', + 'warning_instructions' => '', + 'unknown_instructions' => '', + 'critical_inverse' => '0', + 'warning_inverse' => '0', + 'percentage_critical' => '0', + 'percentage_warning' => '0', + 'cron_interval' => '* * * * *', + 'id_category' => '0', + 'disabled_types_event' => '{\"going_unknown\":0}', + 'module_macros' => 'W10=', + 'warning_time' => '0', + ]; + return modules_create_agent_module($id_agent, 'Basic_Network_Check', $array_values); +} + + +/** + * Create module latency network and return module id. + * + * @param mixed $id_agent Id agent. + * @param mixed $id_group Id group. + * @param mixed $ip_target Ip target. + * + * @return interger Module id. + */ +function create_module_latency_network($id_agent, $id_group, $ip_target) +{ + include_once 'include/functions_modules.php'; + + $array_values = [ + 'id_tipo_modulo' => '7', + 'descripcion' => 'Basic network connectivity check to measure network latency in miliseconds', + 'max' => '0', + 'min' => '0', + 'snmp_oid' => '', + 'snmp_community' => 'public', + 'id_module_group' => $id_group, + 'module_interval' => '300', + 'module_ff_interval' => '0', + 'ip_target' => $ip_target, + 'tcp_port' => '0', + 'tcp_rcv' => '', + 'tcp_send' => '', + 'id_export' => '0', + 'plugin_user' => '', + 'plugin_pass' => '0', + 'plugin_parameter' => '', + 'id_plugin' => '0', + 'post_process' => '0', + 'prediction_module' => '0', + 'max_timeout' => '0', + 'max_retries' => '0', + 'disabled' => '', + 'id_modulo' => '2', + 'custom_id' => '', + 'history_data' => '1', + 'dynamic_interval' => '0', + 'dynamic_max' => '0', + 'dynamic_min' => '0', + 'dynamic_two_tailed' => '1', + 'parent_module_id' => '0', + 'min_warning' => '0', + 'max_warning' => '0', + 'str_warning' => '', + 'min_critical' => '0', + 'max_critical' => '0', + 'str_critical' => '', + 'custom_string_1' => '', + 'custom_string_2' => '', + 'custom_string_3' => '', + 'custom_integer_1' => '0', + 'custom_integer_2' => '0', + 'min_ff_event' => '0', + 'min_ff_event_normal' => '0', + 'min_ff_event_warning' => '0', + 'min_ff_event_critical' => '0', + 'ff_type' => '0', + 'each_ff' => '0', + 'ff_timeout' => '0', + 'unit' => '', + 'macros' => '', + 'quiet' => '0', + 'cps' => '0', + 'critical_instructions' => '', + 'warning_instructions' => '', + 'unknown_instructions' => '', + 'critical_inverse' => '0', + 'warning_inverse' => '0', + 'percentage_critical' => '0', + 'percentage_warning' => '0', + 'cron_interval' => '* * * * *', + 'id_category' => '0', + 'disabled_types_event' => '{\"going_unknown\":0}', + 'module_macros' => 'W10=', + 'warning_time' => '0', + ]; + return modules_create_agent_module($id_agent, 'Basic_Network_Latency', $array_values); +} + + +/** + * Create module packet lost and return module id. + * + * @param mixed $id_agent Id agent. + * @param mixed $id_group Id group. + * @param mixed $ip_target Ip target. + * + * @return interger Module id. + */ +function create_module_packet_lost($id_agent, $id_group, $ip_target) +{ + include_once 'include/functions_modules.php'; + + $array_values = [ + 'id_tipo_modulo' => '1', + 'descripcion' => 'Basic network connectivity check to measure packet loss in %', + 'max' => '0', + 'min' => '0', + 'snmp_oid' => '', + 'snmp_community' => 'public', + 'id_module_group' => $id_group, + 'module_interval' => '300', + 'module_ff_interval' => '0', + 'ip_target' => '', + 'tcp_port' => '0', + 'tcp_rcv' => '', + 'tcp_send' => '', + 'id_export' => '0', + 'plugin_user' => '', + 'plugin_pass' => '0', + 'plugin_parameter' => '', + 'id_plugin' => '9', + 'post_process' => '0', + 'prediction_module' => '0', + 'max_timeout' => '0', + 'max_retries' => '0', + 'disabled' => '', + 'id_modulo' => '4', + 'custom_id' => '', + 'history_data' => '1', + 'dynamic_interval' => '0', + 'dynamic_max' => '0', + 'dynamic_min' => '0', + 'dynamic_two_tailed' => '1', + 'parent_module_id' => '0', + 'min_warning' => '0', + 'max_warning' => '0', + 'str_warning' => '', + 'min_critical' => '0', + 'max_critical' => '0', + 'str_critical' => '', + 'custom_string_1' => '', + 'custom_string_2' => '', + 'custom_string_3' => '', + 'custom_integer_1' => '0', + 'custom_integer_2' => '0', + 'min_ff_event' => '0', + 'min_ff_event_normal' => '0', + 'min_ff_event_warning' => '0', + 'min_ff_event_critical' => '0', + 'ff_type' => '0', + 'each_ff' => '0', + 'ff_timeout' => '0', + 'unit' => '', + 'macros' => '{"1":{"macro":"_field1_","desc":"Test time","help":"","value":"8","hide":""},"2":{"macro":"_field2_","desc":"Target IP","help":"","value":"'.$ip_target.'","hide":""}}', + 'quiet' => '0', + 'cps' => '0', + 'critical_instructions' => '', + 'warning_instructions' => '', + 'unknown_instructions' => '', + 'critical_inverse' => '0', + 'warning_inverse' => '0', + 'percentage_critical' => '0', + 'percentage_warning' => '0', + 'cron_interval' => '* * * * *', + 'id_category' => '0', + 'disabled_types_event' => '{\"going_unknown\":0}', + 'module_macros' => 'W10=', + 'warning_time' => '0', + ]; + return modules_create_agent_module($id_agent, 'Basic_Network_Packetloss', $array_values); +} + + +/** + * Create module packet lost and return module id. + * + * @param string $ip_target Ip and red mask. + * + * @return interger Module id. + */ +function create_net_scan($ip_target) +{ + global $config; + include_once 'HostDevices.class.php'; + $HostDevices = new HostDevices(1); + $id_recon_server = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_DISCOVERY], 'id_server')['id_server']; + + $_POST = [ + 'page' => '1', + 'interval_manual_defined' => '1', + 'interval_select' => '-1', + 'interval_text' => '0', + 'interval' => '0', + 'interval_units' => '1', + 'taskname' => __('Basic network'), + 'id_recon_server' => $id_recon_server, + 'network' => $ip_target, + 'id_group' => '8', + 'comment' => __('Created on welcome'), + ]; + $task_created = $HostDevices->parseNetScan(); + if ($task_created === true) { + $HostDevicesFinal = new HostDevices(2); + $_POST = [ + 'task' => $HostDevices->task['id_rt'], + 'page' => '2', + 'recon_ports' => '', + 'auto_monitor' => 'on', + 'id_network_profile' => ['0' => '2'], + 'review_results' => 'on', + 'review_limited' => '0', + 'snmp_enabled' => 'on', + 'snmp_version' => '1', + 'snmp_skip_non_enabled_ifs' => 'on', + 'community' => '', + 'snmp_context' => '', + 'snmp_auth_user' => '', + 'snmp_security_level' => 'authNoPriv', + 'snmp_auth_method' => 'MD5', + 'snmp_auth_pass' => '', + 'snmp_privacy_method' => 'AES', + 'snmp_privacy_pass' => '', + 'os_detect' => 'on', + 'resolve_names' => 'on', + 'parent_detection' => 'on', + 'parent_recursion' => 'on', + 'vlan_enabled' => 'on', + ]; + + $task_final_created = $HostDevicesFinal->parseNetScan(); + if ($task_final_created === true) { + $net_scan_id = $HostDevices->task['id_rt']; + unset($HostDevices, $HostDevicesFinal); + return $net_scan_id; + } + } else { + return 0; + } +} diff --git a/pandora_console/include/styles/new_installation_welcome_window.css b/pandora_console/include/styles/new_installation_welcome_window.css index 0dbdcd5203..6d354b0c33 100644 --- a/pandora_console/include/styles/new_installation_welcome_window.css +++ b/pandora_console/include/styles/new_installation_welcome_window.css @@ -88,7 +88,8 @@ } #li-div_diagnosis, -#li-div_task_todo { +#li-div_task_todo, +#li-div_wizard_agent { border-left: unset !important; } @@ -96,3 +97,18 @@ #div_task_todo > label { font-weight: bold; } + +button.buttonButton.onlyIcon.fail, +button.submitButton.onlyIcon.fail { + mask: url(../../images/fail@svg.svg) no-repeat center / contain; + -webkit-mask: url(../../images/fail@svg.svg) no-repeat center / contain; +} + +.select2-container .select2-container--default .select2-container--open { + z-index: 2000; +} + +#div_wizard_agent > .select2 { + width: 75% !important; + max-width: 75% !important; +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index adf1325b07..01ba592d97 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -11841,10 +11841,6 @@ span.help_icon_15px > img { height: 15px !important; } -.select2-dropdown { - z-index: 1116 !important; -} - .icon_connection_check { width: 65px !important; height: 65px !important; diff --git a/pandora_console/include/styles/select2.min.css b/pandora_console/include/styles/select2.min.css index ad21d16958..9d81e83c30 100644 --- a/pandora_console/include/styles/select2.min.css +++ b/pandora_console/include/styles/select2.min.css @@ -71,7 +71,7 @@ position: absolute; left: -100000px; width: 100%; - z-index: 1115; + z-index: 1118; } .select2-results { display: block; From 068b19a82f0d98d8ef56df7bd7944f0c5f22a606 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 5 Jun 2023 13:28:37 +0200 Subject: [PATCH 05/11] #10598 fix autocomplete inside dialog --- pandora_console/include/class/WelcomeWindow.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index be86c7deb6..938dfde1a2 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -1309,6 +1309,10 @@ class WelcomeWindow extends Wizard } }) .show(); + + $('#text-id_agent').autocomplete({ + appendTo: '#dialog_alert_mail' + }); } $('#button-create_goliat').click(function(){ @@ -1389,8 +1393,8 @@ class WelcomeWindow extends Wizard url: "include/ajax/task_to_perform.php", data: { create_mail_alert: 1, - id_condition: $('#text-ip_target').val(), - id_agent_module: $('#text-ip_target').val(), + id_condition: $('#id_condition').val(), + id_agent_module: $('#id_agent_module').val(), }, success: function(data) { if (data !== 0) { From d9977a41bacf59934c062da14b801d638c0adee6 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 6 Jun 2023 07:56:34 +0200 Subject: [PATCH 06/11] #10598 remove image welcome wizard --- .../godmode/wizards/mini_diagnosis.php | 132 ------------------ .../include/class/WelcomeWindow.class.php | 19 --- .../include/styles/mini_diagnosis.css | 83 ----------- 3 files changed, 234 deletions(-) delete mode 100644 pandora_console/godmode/wizards/mini_diagnosis.php delete mode 100644 pandora_console/include/styles/mini_diagnosis.css diff --git a/pandora_console/godmode/wizards/mini_diagnosis.php b/pandora_console/godmode/wizards/mini_diagnosis.php deleted file mode 100644 index 022b46c203..0000000000 --- a/pandora_console/godmode/wizards/mini_diagnosis.php +++ /dev/null @@ -1,132 +0,0 @@ - '', - 'label' => __('Configuration'), - ], - [ - 'link' => '', - 'label' => __('Configuration wizard'), - ], - ] -); - -if ($config['pandora_uid'] === 'ONLINE') { - $status_um = true; -} - -require_once 'include/functions_servers.php'; -if (check_all_servers_up() === true) { - $status_su = true; -} - -if (empty($config['welcome_mail_configured']) === false) { - $status_cm = true; -} - -if (enterprise_installed()) { - $license_valid = true; - enterprise_include_once('include/functions_license.php'); - $license = enterprise_hook('license_get_info'); - $days_to_expiry = ((strtotime($license['expiry_date']) - time()) / (60 * 60 * 24)); - if ($license === ENTERPRISE_NOT_HOOK || $days_to_expiry <= 30) { - $license_valid = false; - } - - if ($license_valid === true) { - $status_lv = true; - } -} - - -ui_require_css_file('mini_diagnosis'); -$table = new stdClass(); -$table->width = '60%'; -$table->class = 'filter-table-adv databox'; -$table->size = []; -$table->data = []; -$table->size[0] = '30%'; -$table->size[1] = '30%'; -$table->data[0][0] = html_print_wizard_diagnosis(__('Verification update manager register'), 'update_manager', __('Verification update manager register'), $status_um, true); -$table->data[0][1] = html_print_wizard_diagnosis(__('Please ensure mail configuration matches your needs'), 'configure_email', __('Please ensure mail configuration matches your needs'), $status_cm, true); -$table->data[1][0] = html_print_wizard_diagnosis(__('All servers up'), 'servers_up', __('All servers up'), $status_su, true); -$table->data[1][1] = html_print_wizard_diagnosis(__('Valid license verification and expiration greater than 30 days'), 'license_valid', __('Valid license verification and expiration greater than 30 days'), $status_lv, true); -html_print_table($table); -?> - \ No newline at end of file diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index 938dfde1a2..36258b4b64 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -345,29 +345,10 @@ class WelcomeWindow extends Wizard 'class' => 'modal', ]; - $logo_url = 'images/custom_logo/pandora_logo_head_white_bg.png'; - if (enterprise_installed() === true) { $logo_url = ENTERPRISE_DIR.'/'.$logo_url; } - $inputs = [ - [ - 'class' => 'white_box', - 'block_content' => [ - [ - 'class' => 'centered_full', - 'arguments' => [ - 'type' => 'image', - 'src' => $logo_url, - 'value' => 1, - 'return' => true, - ], - ], - ], - ], - ]; - if (check_acl($config['id_user'], 0, 'PM')) { $flag_um = false; $flag_cm = false; diff --git a/pandora_console/include/styles/mini_diagnosis.css b/pandora_console/include/styles/mini_diagnosis.css deleted file mode 100644 index 7bae821ff8..0000000000 --- a/pandora_console/include/styles/mini_diagnosis.css +++ /dev/null @@ -1,83 +0,0 @@ -.rectangle { - background-color: #ffffff; - border: 2px solid #e5e9ed; - border-radius: 6px; - max-width: 475px; - width: 475px; - height: 161px; - display: contents; - justify-content: flex-start; -} - -.rectangle:hover { - background-color: #f3f5f7; -} - -.rectangle_Connected { - border-left: 4px solid #82b92e; -} - -.rectangle_Disconnected { - border-left: 4px solid #8a96a6; -} - -.status { - font-weight: bold; - margin-top: -10px; - margin-left: 20px; -} - -.Connected { - color: #82b92e; - font-family: Lato; - font-size: 15px; - line-height: 24px; -} - -.Disconnected { - color: #8a96a6; - font-family: Lato; - font-size: 15px; - line-height: 24px; -} - -.title { - margin-top: 20px; - margin-left: 20px; -} - -.title > img { - margin-top: 5px; -} - -.title > span { - color: #14524f; - font-family: Lato; - font-size: 18px; - line-height: 24px; - text-align: left; - margin-left: 10px; - margin-right: 10px; - display: inline-block; - margin-left: 20px; - margin-top: -20px; -} - -.description { - margin-top: 20px; - margin-left: 10px; - color: #454545; - font-family: Lato; - font-size: 15px; - line-height: 24px; - width: 430px; - text-align: left; -} - -.button { - text-align: right; -} - -span > img:hover { - cursor: pointer; -} From f748a07c7517d15408cd803cb959c4b9ff163b7f Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 13 Jul 2023 15:40:35 +0200 Subject: [PATCH 07/11] #10598 fix discovery include --- pandora_console/include/class/WelcomeWindow.class.php | 6 +++--- pandora_console/include/functions_welcome_wizard.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index 36258b4b64..d5dd35816c 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -603,7 +603,7 @@ class WelcomeWindow extends Wizard ], [ 'arguments' => [ - 'label' => __('Let`s do it!'), + 'label' => __("Let's do it!"), 'type' => 'button', 'attributes' => [ 'class' => 'secondary', @@ -754,7 +754,7 @@ class WelcomeWindow extends Wizard echo html_print_label_input_block( __('Ip target'), html_print_input_text( - 'ip_target', + 'ip_target_discovery', '192.168.10.0/24', '192.168.10.0/24', false, @@ -1352,7 +1352,7 @@ class WelcomeWindow extends Wizard url: "include/ajax/task_to_perform.php", data: { create_net_scan: 1, - ip_target: $('#text-ip_target').val(), + ip_target: $('#text-ip_target_discovery').val(), }, success: function(data) { if (data !== 0) { diff --git a/pandora_console/include/functions_welcome_wizard.php b/pandora_console/include/functions_welcome_wizard.php index 6993f16224..7f12048b1f 100644 --- a/pandora_console/include/functions_welcome_wizard.php +++ b/pandora_console/include/functions_welcome_wizard.php @@ -479,7 +479,7 @@ function create_module_packet_lost($id_agent, $id_group, $ip_target) function create_net_scan($ip_target) { global $config; - include_once 'HostDevices.class.php'; + include_once $config['homedir'].'/godmode/wizards/HostDevices.class.php'; $HostDevices = new HostDevices(1); $id_recon_server = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_DISCOVERY], 'id_server')['id_server']; From ee37487b7480f4e27726b26539fa697bea636db5 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 14 Jul 2023 11:44:37 +0200 Subject: [PATCH 08/11] #10598 unknown create template and show --- .../include/ajax/task_to_perform.php | 9 ++ .../include/class/WelcomeWindow.class.php | 121 ++++-------------- .../include/functions_welcome_wizard.php | 31 +++++ 3 files changed, 68 insertions(+), 93 deletions(-) diff --git a/pandora_console/include/ajax/task_to_perform.php b/pandora_console/include/ajax/task_to_perform.php index c889c37f8d..a8a13e08f2 100644 --- a/pandora_console/include/ajax/task_to_perform.php +++ b/pandora_console/include/ajax/task_to_perform.php @@ -35,6 +35,7 @@ $check_web = get_parameter('check_web', 0); $check_connectivity = get_parameter('check_connectivity', 0); $create_net_scan = get_parameter('create_net_scan', 0); $create_mail_alert = get_parameter('create_mail_alert', 0); +$create_unknown_template_alert = get_parameter('create_unknown_template_alert', 0); // Begin. global $config; @@ -179,3 +180,11 @@ if ($create_mail_alert) { ui_print_success_message(__('Congratulations, you have already created a simple alert. You can see it. Pandora FMS alerts are very flexible, you can do many more things with them, we recommend you to read the documentation for more information. You can create advanced alerts from here.')); } } + +if ($create_unknown_template_alert) { + if (is_array(alerts_get_alert_templates(['name' => io_safe_input('Unknown condition')]))) { + echo 1; + } else { + echo create_template_alert_unknown(); + } +} diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index d5dd35816c..0d1068ce67 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -822,7 +822,7 @@ class WelcomeWindow extends Wizard ' ); - $condition = alerts_get_alert_templates(['id IN (1,3)'], ['id', 'name']); + $condition = alerts_get_alert_templates(['(id IN (1,3) OR name = "'.io_safe_input('Unknown condition').'")'], ['id', 'name']); echo html_print_label_input_block( __('Contition'), @@ -1128,81 +1128,6 @@ class WelcomeWindow extends Wizard } }); - // Task to do buttons. - $('#button-go_wizard').click(function(){ - if ($('#task_to_perform :selected').val() === '') { - alert(""); - } else { - switch($('#task_to_perform :selected').val()) { - case 'wizard_agent': - deployAgent(); - break; - case 'check_mail_alert': - openCreateAlertMailDialog(); - break; - case 'check_connectivity': - openCreateConnectivityDialog(); - break; - case 'check_web': - openCreateModulesDialog(); - break; - case 'check_net': - openCreateBasicNetDialog(); - break; - }; - } - }); - - // Task to do buttons. - $('#button-go_wizard').click(function(){ - if ($('#task_to_perform :selected').val() === '') { - alert(""); - } else { - switch($('#task_to_perform :selected').val()) { - case 'wizard_agent': - deployAgent(); - break; - case 'check_mail_alert': - openCreateAlertMailDialog(); - break; - case 'check_connectivity': - openCreateConnectivityDialog(); - break; - case 'check_web': - openCreateModulesDialog(); - break; - case 'check_net': - openCreateBasicNetDialog(); - break; - }; - } - }); - - // Task to do buttons. - $('#button-go_wizard').click(function(){ - if ($('#task_to_perform :selected').val() === '') { - alert(""); - } else { - switch($('#task_to_perform :selected').val()) { - case 'wizard_agent': - deployAgent(); - break; - case 'check_mail_alert': - openCreateAlertMailDialog(); - break; - case 'check_connectivity': - openCreateConnectivityDialog(); - break; - case 'check_web': - openCreateModulesDialog(); - break; - case 'check_net': - openCreateBasicNetDialog(); - break; - }; - } - }); - function configureUpdateManager() { window.location = ''; } @@ -1276,23 +1201,33 @@ class WelcomeWindow extends Wizard } function openCreateAlertMailDialog() { - $('#dialog_alert_mail').dialog({ - title: '', - resizable: true, - draggable: true, - modal: true, - close: false, - height: 350, - width: 480, - overlay: { - opacity: 0.5, - background: "black" - } - }) - .show(); + $.ajax({ + async: false, + type: "POST", + url: "include/ajax/task_to_perform.php", + data: { + create_unknown_template_alert: 1, + }, + success: function(data) { + $('#dialog_alert_mail').dialog({ + title: '', + resizable: true, + draggable: true, + modal: true, + close: false, + height: 350, + width: 480, + overlay: { + opacity: 0.5, + background: "black" + } + }) + .show(); - $('#text-id_agent').autocomplete({ - appendTo: '#dialog_alert_mail' + $('#text-id_agent').autocomplete({ + appendTo: '#dialog_alert_mail' + }); + } }); } @@ -1351,7 +1286,7 @@ class WelcomeWindow extends Wizard type: "POST", url: "include/ajax/task_to_perform.php", data: { - create_net_scan: 1, + Contition: 1, ip_target: $('#text-ip_target_discovery').val(), }, success: function(data) { diff --git a/pandora_console/include/functions_welcome_wizard.php b/pandora_console/include/functions_welcome_wizard.php index 7f12048b1f..f1b8d672f1 100644 --- a/pandora_console/include/functions_welcome_wizard.php +++ b/pandora_console/include/functions_welcome_wizard.php @@ -535,3 +535,34 @@ function create_net_scan($ip_target) return 0; } } + + +/** + * Create new template unknown. + * + * @return boolean 1 correct create 0 bad create. + */ +function create_template_alert_unknown() +{ + $name = io_safe_input(__('Unknown condition')); + $type = 'critical'; + $values = [ + 'description' => __('This is a generic alert template to fire on UNKNOWN condition'), + 'max_value' => 0, + 'min_value' => 0, + 'id_group' => 0, + 'priority' => 4, + 'wizard_level' => 'nowizard', + 'time_threshold' => '300', + 'min_alerts_reset_counter' => 1, + 'schedule' => '{"monday":[{"start":"00:00:00","end":"00:00:00"}],"tuesday":[{"start":"00:00:00","end":"00:00:00"}],"wednesday":[{"start":"00:00:00","end":"00:00:00"}],"thursday":[{"start":"00:00:00","end":"00:00:00"}],"friday":[{"start":"00:00:00","end":"00:00:00"}],"saturday":[{"start":"00:00:00","end":"00:00:00"}],"sunday":[{"start":"00:00:00","end":"00:00:00"}]}', + 'recovery_notify' => true, + 'field2' => '[PANDORA] Alert for UNKNOWN status on _agent_ / _module_', + 'field2_recovery' => '[PANDORA] Alert RECOVERED for UNKNOWN status on _agent_ / _module_', + 'field3' => '

Automatic alert system


We have bad news for you, something is on UNKNOWN status!

Monitoring details

Data: _data_ (warning)

Agent: _agent_ _address_

Module: _module_ _moduledescription_

Timestamp: _timestamp_

This is a graph of latest 24hr data for this module

_modulegraph_24h_

Contact Us  |  Support  |  Docs

', + 'field3_recovery' => '

Automatic alert system


We have good news for you, alert has been recovered

Monitoring details

Data: _data_ (normal)

Agent: _agent_ _address_

Module: _module_ _moduledescription_

Timestamp: _timestamp_

This is a graph of latest 24hr data for this module

_modulegraph_24h_

Contact Us  |  Support  |  Docs

', + ]; + + $result = alerts_create_alert_template($name, $type, $values); + return $result; +} From 9e81e28c62d537fcc2610532eb026849de53e148 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 14 Jul 2023 12:12:20 +0200 Subject: [PATCH 09/11] #10598 basic_net fix --- pandora_console/include/class/WelcomeWindow.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index 0d1068ce67..77f722e5d3 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -1286,7 +1286,7 @@ class WelcomeWindow extends Wizard type: "POST", url: "include/ajax/task_to_perform.php", data: { - Contition: 1, + create_net_scan: 1, ip_target: $('#text-ip_target_discovery').val(), }, success: function(data) { From e6e4448ea949597d9b567ec50b9b790e304dfba7 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 14 Jul 2023 12:33:19 +0200 Subject: [PATCH 10/11] #10598 license and dropsearch select2 --- pandora_console/include/class/WelcomeWindow.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index 77f722e5d3..6d7baa647c 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -399,6 +399,10 @@ class WelcomeWindow extends Wizard $btn_license_valid_class = ''; $li_license_valid_class = 'row_green'; $flag_lv = true; + } else { + $btn_license_valid_class = 'fail'; + $li_license_valid_class = 'row_grey'; + $flag_lv = false; } } else { $show_license = false; @@ -1227,6 +1231,10 @@ class WelcomeWindow extends Wizard $('#text-id_agent').autocomplete({ appendTo: '#dialog_alert_mail' }); + + $("#id_agent_module").select2({ + dropdownParent: $("#dialog_alert_mail") + }); } }); } From 4407efecc06517edfa5dc0b2d1ea80dc7a631713 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 14 Jul 2023 12:39:13 +0200 Subject: [PATCH 11/11] #10598 remove show license and show always --- .../include/class/WelcomeWindow.class.php | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index 6d7baa647c..3a2d45f2e0 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -385,7 +385,6 @@ class WelcomeWindow extends Wizard $flag_su = true; } - $show_license = true; if (enterprise_installed()) { $license_valid = true; enterprise_include_once('include/functions_license.php'); @@ -405,7 +404,9 @@ class WelcomeWindow extends Wizard $flag_lv = false; } } else { - $show_license = false; + $btn_license_valid_class = 'fail'; + $li_license_valid_class = 'row_grey'; + $flag_lv = false; } $inputs[] = [ @@ -510,36 +511,34 @@ class WelcomeWindow extends Wizard ], ], ]; - if ($show_license) { - $inputs[] = [ - 'wrapper' => 'div', - 'block_id' => 'div_license_valid', - 'class' => 'hole flex-row flex-items-center w98p '.$li_license_valid_class, - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('Enterprise licence valid'), - 'arguments' => [ - 'class' => 'first_lbl', - 'name' => 'lbl_license_valid', - 'id' => 'lbl_license_valid', - ], - ], - [ - 'arguments' => [ - 'label' => '', - 'type' => 'button', - 'attributes' => [ - 'class' => (empty($btn_license_valid_class) === false) ? $btn_license_valid_class : 'invisible_important', - 'mode' => 'onlyIcon', - ], - 'name' => 'btn_license_valid_conf', - 'id' => 'btn_license_valid_conf', - ], + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_license_valid', + 'class' => 'hole flex-row flex-items-center w98p '.$li_license_valid_class, + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Enterprise licence valid'), + 'arguments' => [ + 'class' => 'first_lbl', + 'name' => 'lbl_license_valid', + 'id' => 'lbl_license_valid', ], ], - ]; - } + [ + 'arguments' => [ + 'label' => '', + 'type' => 'button', + 'attributes' => [ + 'class' => (empty($btn_license_valid_class) === false) ? $btn_license_valid_class : 'invisible_important', + 'mode' => 'onlyIcon', + ], + 'name' => 'btn_license_valid_conf', + 'id' => 'btn_license_valid_conf', + ], + ], + ], + ]; } else { $inputs[] = [ 'wrapper' => 'div',