From c05b4c53e82efcd5df56415aae2eb2000ff81ac6 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Fri, 7 Dec 2018 15:12:09 +0100 Subject: [PATCH 01/29] fix bug when updating path of ssl certificate in general setup Former-commit-id: dfe466e64e18c7e3ea949f7786e0ef6343334260 --- pandora_console/godmode/setup/setup_general.php | 5 +++++ pandora_console/include/functions_config.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index b935f4fc13..285ae1451b 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -292,6 +292,11 @@ $(document).ready (function () { $("#zone").attr("hidden", false); $("#timezone").attr("hidden", false); }); + + if ($("input[name=use_cert]").is(':checked')) { + $('#setup_general-13').show(); + } + $("input[name=use_cert]").change(function () { if( $(this).is(":checked") ){ var val = $(this).val(); diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index e773224c16..ec6d791d62 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -136,7 +136,7 @@ function config_update_config () { $error_update[] = __('Time source'); if (!config_update_value ('autoupdate', (bool) get_parameter ('autoupdate'))) $error_update[] = __('Automatic check for updates'); - if (!config_update_value ('cert_path', (bool) get_parameter ('cert_path'))) + if (!config_update_value ('cert_path', get_parameter ('cert_path'))) $error_update[] = __('SSL cert path'); if (!config_update_value ('https', (bool) get_parameter ('https'))) $error_update[] = __('Enforce https'); From 279e94f452dc3b86caf2e35b606239e3bf0a697b Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Tue, 11 Dec 2018 10:30:24 +0100 Subject: [PATCH 02/29] agent named replaced by agent alias in mobile console's alerts view Former-commit-id: 4140bddcf5785f76a948bbe1ba0f694a58c9b50a --- pandora_console/mobile/operation/alerts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/mobile/operation/alerts.php b/pandora_console/mobile/operation/alerts.php index cf9c89272f..b6a71dddba 100644 --- a/pandora_console/mobile/operation/alerts.php +++ b/pandora_console/mobile/operation/alerts.php @@ -263,7 +263,7 @@ class Alerts { $row = array(); if (isset($this->columns['agent']) && $this->columns['agent']) { - $row[__('Agent')] = sprintf($disabled_style, io_safe_output($alert['agent_name'])); + $row[__('Agent')] = sprintf($disabled_style, io_safe_output($alert['agent_alias'])); } $row[__('Module')] = sprintf($disabled_style, io_safe_output($alert['module_name'])); From c5c5ba94034a38d6eea7718f4fb339f4d1dc99f6 Mon Sep 17 00:00:00 2001 From: "manuel.montes" Date: Wed, 12 Dec 2018 12:21:52 +0100 Subject: [PATCH 03/29] Fixed bug in diagnostic info Former-commit-id: 0318eabdf8cbf60267667ba1b4d74d8e476d0b3d --- pandora_console/extras/pandora_diag.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/pandora_console/extras/pandora_diag.php b/pandora_console/extras/pandora_diag.php index 29e83182fe..b961c30091 100644 --- a/pandora_console/extras/pandora_diag.php +++ b/pandora_console/extras/pandora_diag.php @@ -122,8 +122,8 @@ function get_logs_size($file){ function get_status_logs($path){ $status_server_log = ""; - $size_server_log = get_logs_size($path); - if ($size_server_log <= 10240){ + $size_server_log = number_format(get_logs_size($path)); + if ($size_server_log <= 1048576){ $status_server_log = "Normal Status   You have less than 10 MB of logs"; }else{ $status_server_log = "Warning Status   You have more than 10 MB of logs"; @@ -344,11 +344,7 @@ render_info_data ("SELECT COUNT(*) FROM tagente","Total agents"); render_info_data ("SELECT COUNT(*) FROM tagente_modulo","Total modules"); render_info_data ("SELECT COUNT(*) FROM tgrupo","Total groups"); render_info_data ("SELECT COUNT(*) FROM tagente_datos","Total module data records"); -// render_info_data ("SELECT COUNT(*) FROM tagente_datos_string","Total module string data records"); -// render_info_data ("SELECT COUNT(*) FROM tagente_datos_log4x","Total module log4x data records"); render_info_data ("SELECT COUNT(*) FROM tagent_access","Total agent access record"); -// render_info ("tagente_estado"); -// render_info ("talert_template_modules"); render_info_data ("SELECT COUNT(*) FROM tevento","Total events"); if($config['enterprise_installed']) @@ -560,7 +556,7 @@ render_row(status_values($read_buffer_size_min_rec_value,$read_buffer_size), 'Re render_row(status_values($read_rnd_buffer_size_min_rec_value,$read_rnd_buffer_size), 'Read rnd-buffer size ','Read rnd-buffer size '); render_row(status_values($query_cache_min_res_unit_min_rec_value,$query_cache_min_res_unit), 'Query cache min-res-unit ','Query cache min-res-unit '); render_row(status_values($innodb_file_per_table_min_rec_value,$innodb_file_per_table), 'InnoDB file per table ','InnoDB file per table '); -echo "".__("Tables fragmentation in the PandoraFMS database").""; +echo "".__("Tables fragmentation in the Pandora FMS database").""; @@ -568,14 +564,14 @@ render_row ($tables_fragmentation_max_rec_value . "%", "Tables fragmentation (ma render_row (number_format($tables_fragmentation, 2) . "%", "Tables fragmentation (current value)"); render_row (status_fragmentation_tables($tables_fragmentation_max_rec_value, $tables_fragmentation), "Status fragmentation tables"); -echo "".__(" PandoraFMS logs dates").""; +echo "".__(" Pandora FMS logs dates").""; -render_row(number_format(get_logs_size($path_server_logs)/1024, 2) . "M", 'Size server logs (current value)'); +render_row(number_format(get_logs_size($path_server_logs)/1048576, 3) . "M", 'Size server logs (current value)'); render_row(get_status_logs($path_server_logs),'Status server logs'); -render_row(number_format(get_logs_size($path_console_logs)/1024, 2) . "M", 'Size console logs (current value)'); +render_row(number_format(get_logs_size($path_console_logs)/1048576, 3) . "M", 'Size console logs (current value)'); render_row(get_status_logs($path_console_logs),'Status console logs'); -echo "".__(" PandoraFMS Licence Information").""; +echo "".__(" Pandora FMS Licence Information").""; render_row( html_print_textarea ('keys[customer_key]', 10, 255, $settings->customer_key, 'style="height:40px; width:450px;"', true),'Customer key'); render_row( $license['expiry_date'],'Expires'); From 471c01a4c52d2876f7c3eef414652a8aad80cada Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Wed, 9 Jan 2019 10:20:17 +0100 Subject: [PATCH 04/29] fixed bad link to node in metaconsole's custom graph item editor Former-commit-id: 22fb4302de980d8b3e16fb90d087b71c218598a1 --- .../godmode/reporting/reporting_builder.item_editor.php | 2 +- pandora_console/include/ajax/reporting.ajax.php | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index a929740e39..4f4b5e7c22 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -2492,7 +2492,7 @@ function edit_custom_graph() { } }); - window.location.href = server_url + "/index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1&id=" + id_element_graph + hash_data; + window.location.href = server_url + "index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1&id=" + id_element_graph + hash_data; Date: Wed, 9 Jan 2019 16:20:24 +0100 Subject: [PATCH 05/29] Added option in setup for unique main IP in agents - #1744 Former-commit-id: f8f9668a14818a01b811a73052e2e7e82e9a8c7a --- .../godmode/agentes/agent_manager.php | 4 +++- .../godmode/agentes/configurar_agente.php | 22 ++++++++++++++++++- .../godmode/setup/setup_general.php | 5 +++++ pandora_console/include/functions_config.php | 10 +++++++-- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index f94cb7737b..40469f75b2 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -228,7 +228,9 @@ if($new_agent){ } $table->data[2][0] = __('IP Address'); -$table->data[2][1] = html_print_input_text ('direccion', $direccion_agente, '', 16, 100, true); +$table->data[2][1] = html_print_input_text ('direccion', $direccion_agente, '', 16, 100, true). + html_print_checkbox ("unique_ip", 1, $config['unique_ip'], true).__('Unique IP') . + ui_print_help_tip (__("Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent"), true); if ($id_agente) { $table->data[2][1] .= '    '; diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index fab0ad7637..92c3cc4b73 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -81,6 +81,7 @@ $alias_as_name = 0; $direccion_agente = get_parameter('direccion', ''); $direccion_agente = trim(io_safe_output($direccion_agente)); $direccion_agente = io_safe_input($direccion_agente); +$unique_ip = 0; $intervalo = SECONDS_5MINUTES; $ff_interval = 0; $quiet_module = 0; @@ -160,6 +161,7 @@ if ($create_agent) { $alias = (string) get_parameter_post("alias",''); $alias_as_name = (int) get_parameter_post("alias_as_name", 0); $direccion_agente = (string) get_parameter_post("direccion",''); + $unique_ip = (int) get_parameter_post("unique_ip", 0); //safe_output only validate ip $direccion_agente = trim(io_safe_output($direccion_agente)); @@ -214,7 +216,12 @@ if ($create_agent) { $nombre_agente = $alias; } - if(!$exists_alias){ + if($unique_ip && $direccion_agente != ''){ + $sql = 'SELECT direccion FROM tagente WHERE direccion = "' . $direccion_agente . '"'; + $exists_ip = db_get_row_sql($sql); + } + + if(!$exists_alias && !$exists_ip){ $id_agente = db_process_sql_insert ( 'tagente', array ( @@ -304,6 +311,9 @@ if ($create_agent) { if($exists_alias){ $agent_creation_error = __('Could not be created, because name already exists'); } + elseif($exists_ip){ + $agent_creation_error = __('Could not be created, because IP already exists'); + } } } } @@ -712,6 +722,7 @@ if ($update_agent) { // if modified some agent paramenter $alias = str_replace('`','‘',(string) get_parameter_post ("alias", "")); $alias_as_name = (int) get_parameter_post ('alias_as_name', 0); $direccion_agente = (string) get_parameter_post ("direccion", ''); + $unique_ip = (int) get_parameter_post ('unique_ip', 0); //safe_output only validate ip $direccion_agente = trim(io_safe_output($direccion_agente)); @@ -795,9 +806,18 @@ if ($update_agent) { // if modified some agent paramenter ui_print_error_message(__('No agent alias specified')); //If there is an agent with the same name, but a different ID } + + if($unique_ip && $direccion_agente != ''){ + $sql = 'SELECT direccion FROM tagente WHERE direccion = "' . $direccion_agente . '"'; + $exists_ip = db_get_row_sql($sql); + } + if ($grupo <= 0) { ui_print_error_message(__('The group id %d is incorrect.', $grupo)); } + elseif($exists_ip){ + ui_print_error_message(__('Duplicate main IP address')); + } else { //If different IP is specified than previous, add the IP if ($direccion_agente != '' && diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index b935f4fc13..aedeec5173 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -230,6 +230,11 @@ $table->data[38][0] = __('Set alias as name by default in agent creation'); $table->data[38][1] = __('Yes').'   '.html_print_radio_button ('alias_as_name', 1, '', $config["alias_as_name"], true).'  '; $table->data[38][1] .= __('No').'   '.html_print_radio_button ('alias_as_name', 0, '', $config["alias_as_name"], true); +$table->data[39][0] = __('Unique IP') . + ui_print_help_tip (__("Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent"), true); +$table->data[39][1] = __('Yes').'   '.html_print_radio_button ('unique_ip', 1, '', $config["unique_ip"], true).'  '; +$table->data[39][1] .= __('No').'   '.html_print_radio_button ('unique_ip', 0, '', $config["unique_ip"], true); + echo '
'; echo "
"; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index bd0c78bd76..a1f2320d9f 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -204,10 +204,12 @@ function config_update_config () { $error_update[] = __('Identification_reminder'); if (!config_update_value ('include_agents', (bool)get_parameter('include_agents'))) $error_update[] = __('Include_agents'); - if (!config_update_value ('alias_as_name', get_parameter('alias_as_name'))) - $error_update[] = __('alias_as_name'); + if (!config_update_value ('alias_as_name', get_parameter('alias_as_name'))) + $error_update[] = __('alias_as_name'); if (!config_update_value ('auditdir', get_parameter('auditdir'))) $error_update[] = __('Audit log directory'); + if (!config_update_value ('unique_ip', get_parameter('unique_ip'))) + $error_update[] = __('unique_ip'); break; case 'enterprise': if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) { @@ -1123,6 +1125,10 @@ function config_process_config () { config_update_value ('limit_parameters_massive', ini_get("max_input_vars") / 2); } + if (!isset ($config["unique_ip"])) { + config_update_value ('unique_ip', 0); + } + /* *Parse the ACL IP list for access API */ From e316977d4b407bd7ae393d087de35bf930c7d947 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Wed, 16 Jan 2019 12:23:19 +0100 Subject: [PATCH 06/29] Refactorize and add two new fields to api_get_groups api function Former-commit-id: 2d59091279c284d549c09744ee61c8fee1e33564 --- pandora_console/include/functions_api.php | 34 +++++++++++------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 53479ae7ed..aa21faad1a 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -283,30 +283,28 @@ function api_get_test_event_replication_db() { //-------------------------DEFINED OPERATIONS FUNCTIONS----------------- function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db) { - if (defined ('METACONSOLE')) { - return; - } - if ($other['type'] == 'string') { - if ($other['data'] != '') { - returnError('error_parameter', 'Error in the parameters.'); - return; - } - else {//Default values - $separator = ';'; - } - } - else if ($other['type'] == 'array') { - $separator = $other['data'][0]; - } - - $groups = users_get_groups ($user_in_db, "IR"); + $returnAllGroup = true; + $returnAllColumns = false; + + if (isset($other['data'][1])) + $returnAllGroup = ( $other['data'][1] == '1' ? true : false); + + if (isset($other['data'][2])) + $returnAllColumns = ( $other['data'][2] == '1' ? true : false); + + $groups = users_get_groups ($user_in_db, "IR", $returnAllGroup, $returnAllColumns); $data_groups = array(); foreach ($groups as $id => $group) { $data_groups[] = array($id, $group); } - + + if (!isset($other['data'][0])) + $separator = ';'; // by default + else + $separator = $other['data'][0]; + $data['type'] = 'array'; $data['data'] = $data_groups; From 4d4569cadbbf4656ae23553951792735036094e2 Mon Sep 17 00:00:00 2001 From: "tatiana.llorente@artica.es" Date: Fri, 25 Jan 2019 13:52:49 +0100 Subject: [PATCH 07/29] Fixed error with slashes - #3426 Former-commit-id: 8dbead7acd73faa66e406cccf1fe81ed775eb933 --- pandora_console/include/functions_config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 2fd79d6d43..3e414f636a 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -2248,7 +2248,7 @@ function config_check () { __('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'), __("Problems with disable functions in PHP.INI")); } - $result_ejecution = exec($config['phantomjs_bin'] . '/phantomjs --version'); + $result_ejecution = exec('"'.io_safe_output($config['phantomjs_bin']) . '/phantomjs" --version'); if(!isset($result_ejecution) || $result_ejecution == '') { if ($config['language'] == 'es') { set_pandora_error_for_header( From 1d7f5365ab7097160a5ad3ba8d1fc534e8d731d9 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 30 Jan 2019 12:07:17 +0100 Subject: [PATCH 08/29] add params setup historic database Former-commit-id: 6a2d0cf00f18ceee467ca98279adf5285ea161dd --- pandora_console/godmode/setup/performance.php | 754 +++++++++++++++--- pandora_console/godmode/setup/setup.php | 304 +++---- 2 files changed, 824 insertions(+), 234 deletions(-) diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index ceeae084c8..4c99c79232 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -1,107 +1,545 @@ -width = '100%'; +$table_status->class = 'databox filters'; +$table_status->style[0] = 'font-weight: bold'; +$table_status->size[0] = '10%'; + +$table_status->data = []; + +$sql = "SELECT UNIX_TIMESTAMP(NOW()) - `value` AS updated_at + FROM tconfig + WHERE token = 'db_maintance'"; + +$time_pandora_db_active = db_get_sql($sql); + +if ($time_pandora_db_active < SECONDS_12HOURS) { + $table_status->data[0][0] = html_print_image( + 'images/dot_green.png', + true + ); +} else { + $table_status->data[0][0] = html_print_image( + 'images/dot_red.png', + true + ); +} + +$table_status->data[0][0] .= ' '.__('Pandora_db running in active database.'); +$table_status->data[0][0] .= ' '.__('Executed:').' '; +$table_status->data[0][0] .= human_time_description_raw( + $time_pandora_db_active, + true +); + +$table_status->data[0][0] .= ' '.__('ago').'.'; + +$table_status->data[0][0] .= ui_print_help_tip( + __('WIP'), + true +); + +if ($config['history_db_enabled'] == 1) { + if (! isset($config['history_db_connection']) + || $config['history_db_connection'] === false + ) { + $config['history_db_connection'] = db_connect( + $config['history_db_host'], + $config['history_db_name'], + $config['history_db_user'], + io_output_password($config['history_db_pass']), + $config['history_db_port'], + false + ); + } + + if ($config['history_db_connection'] !== false) { + $time_pandora_db_history = mysql_db_process_sql( + $sql, + 'insert_id', + $config['history_db_connection'], + false + ); + } + + if ($time_pandora_db_history !== false + && $time_pandora_db_history[0]['updated_at'] < SECONDS_12HOURS + ) { + $table_status->data[1][0] = html_print_image( + 'images/dot_green.png', + true + ); + } else { + $table_status->data[1][0] = html_print_image( + 'images/dot_red.png', + true + ); + } + + $table_status->data[1][0] .= ' '.__('Pandora_db running in historical database.'); + $table_status->data[1][0] .= ' '.__('Executed:').' '; + if ($time_pandora_db_history !== false) { + $table_status->data[1][0] .= human_time_description_raw( + $time_pandora_db_history[0]['updated_at'], + true + ).' '.__('ago').'.'; + } else { + $table_status->data[1][0] .= __('not executed'); + } + + $table_status->data[1][0] .= ui_print_help_tip( + __('WIP'), + true + ); +} -Update operation is done in config_process.php -This is done in that way so the user can see the changes inmediatly. -If you added a new token, please check config_update_config() in functions_config.php -to add it there. -*/ $table = new StdClass(); $table->width = '100%'; -$table->class = "databox filters"; -$table->data = array (); -$table->style[0] = "font-weight: bold"; +$table->class = 'databox filters'; +$table->data = []; +$table->style[0] = 'font-weight: bold'; $table->size[0] = '70%'; $table->size[1] = '30%'; enterprise_hook('enterprise_warnings_history_days'); -$table->data[1][0] = __('Max. days before delete events') . ui_print_help_tip(__('If the compaction or purge of the data is more frequent than the events deletion, anomalies in module graphs could appear'), true); -$table->data[1][1] = html_print_input_text ('event_purge', $config["event_purge"], '', 5, 5, true); +$table->data[1][0] = __('Max. days before delete events'); +$table->data[1][0] .= ui_print_help_tip( + __('If the compaction or purge of the data is more frequent than the events deletion, anomalies in module graphs could appear'), + true +); + +$table->data[1][1] = html_print_input_text( + 'event_purge', + $config['event_purge'], + '', + 5, + 5, + true +); $table->data[2][0] = __('Max. days before delete traps'); -$table->data[2][1] = html_print_input_text ('trap_purge', $config["trap_purge"], '', 5, 5, true); +$table->data[2][1] = html_print_input_text( + 'trap_purge', + $config['trap_purge'], + '', + 5, + 5, + true +); $table->data[3][0] = __('Max. days before delete audit events'); -$table->data[3][1] = html_print_input_text ('audit_purge', $config["audit_purge"], '', 5, 5, true); +$table->data[3][1] = html_print_input_text( + 'audit_purge', + $config['audit_purge'], + '', + 5, + 5, + true +); $table->data[4][0] = __('Max. days before delete string data'); -$table->data[4][1] = html_print_input_text ('string_purge', $config["string_purge"], '', 5, 5, true); +$table->data[4][1] = html_print_input_text( + 'string_purge', + $config['string_purge'], + '', + 5, + 5, + true +); $table->data[5][0] = __('Max. days before delete GIS data'); -$table->data[5][1] = html_print_input_text ('gis_purge', $config["gis_purge"], '', 5, 5, true); +$table->data[5][1] = html_print_input_text( + 'gis_purge', + $config['gis_purge'], + '', + 5, + 5, + true +); -$table->data[6][0] = __('Max. days before purge') . ui_print_help_tip(__('Configure a purge period more frequent than a compact data period has no sense'), true); -$table->data[6][1] = html_print_input_text ('days_purge', $config["days_purge"], '', 5, 5, true); +$table->data[6][0] = __('Max. days before purge'); +$table->data[6][0] .= ui_print_help_tip( + __('Configure a purge period more frequent than a compact data period has no sense'), + true +); +$table->data[6][1] = html_print_input_text( + 'days_purge', + $config['days_purge'], + '', + 5, + 5, + true +); $table->data[7][0] = __('Max. days before compact data'); -$table->data[7][1] = html_print_input_text ('days_compact', $config["days_compact"], '', 5, 5, true); +$table->data[7][1] = html_print_input_text( + 'days_compact', + $config['days_compact'], + '', + 5, + 5, + true +); $table->data[8][0] = __('Max. days before delete unknown modules'); -$table->data[8][1] = html_print_input_text ('days_delete_unknown', $config["days_delete_unknown"], '', 5, 5, true); +$table->data[8][1] = html_print_input_text( + 'days_delete_unknown', + $config['days_delete_unknown'], + '', + 5, + 5, + true +); $table->data[9][0] = __('Max. days before delete autodisabled agents'); -$table->data[9][1] = html_print_input_text ('days_autodisable_deletion', $config["days_autodisable_deletion"], '', 5, 5, true); +$table->data[9][1] = html_print_input_text( + 'days_autodisable_deletion', + $config['days_autodisable_deletion'], + '', + 5, + 5, + true +); -$table->data[10][0] = __('Retention period of past special days') . ui_print_help_tip(__('This number is days to keep past special days. 0 means never remove.'), true); -$table->data[10][1] = html_print_input_text ('num_past_special_days', $config["num_past_special_days"], '', 5, 5, true); +$table->data[10][0] = __('Retention period of past special days'); +$table->data[10][0] .= ui_print_help_tip( + __('This number is days to keep past special days. 0 means never remove.'), + true +); +$table->data[10][1] = html_print_input_text( + 'num_past_special_days', + $config['num_past_special_days'], + '', + 5, + 5, + true +); -$table->data[11][0] = __('Max. macro data fields') . ui_print_help_tip(__('Number of macro fields in alerts and templates between 1 and 15'), true); -$table->data[11][1] = html_print_input_text ('max_macro_fields', $config["max_macro_fields"], '', 5, 5, true, false, false, "onChange=\"change_macro_fields()\""); +$table->data[11][0] = __('Max. macro data fields'); +$table->data[11][0] .= ui_print_help_tip( + __('Number of macro fields in alerts and templates between 1 and 15'), + true +); +$table->data[11][1] = html_print_input_text( + 'max_macro_fields', + $config['max_macro_fields'], + '', + 5, + 5, + true, + false, + false, + 'onChange="change_macro_fields()"' +); -if (enterprise_installed ()) { - $table->data[12][0] = __('Max. days before delete inventory data'); - $table->data[12][1] = html_print_input_text ('inventory_purge', $config["inventory_purge"], '', 5, 5, true); +if (enterprise_installed()) { + $table->data[12][0] = __('Max. days before delete inventory data'); + $table->data[12][1] = html_print_input_text( + 'inventory_purge', + $config['inventory_purge'], + '', + 5, + 5, + true + ); +} + +if ($config['history_db_enabled'] == 1) { + if (! isset($config['history_db_connection']) + || $config['history_db_connection'] === false + ) { + $config['history_db_connection'] = db_connect( + $config['history_db_host'], + $config['history_db_name'], + $config['history_db_user'], + io_output_password($config['history_db_pass']), + $config['history_db_port'], + false + ); + } + + if ($config['history_db_connection'] != false) { + $config_history_array = mysql_db_process_sql( + 'SELECT * FROM tconfig', + 'affected_rows', + $config['history_db_connection'], + false + ); + + $config_history = false; + + if (isset($config_history_array) && is_array($config_history_array)) { + foreach ($config_history_array as $key => $value) { + $config_history[$value['token']] = $value['value']; + } + } + } + + if ($config_history === false) { + $config_history = []; + $config_history['days_purge'] = 180; + $config_history['days_compact'] = 120; + $config_history['step_compact'] = 1; + $config_history['event_purge'] = 180; + $config_history['string_purge'] = 180; + } + + $table_historical = new StdClass(); + $table_historical->width = '100%'; + $table_historical->class = 'databox filters'; + $table_historical->data = []; + $table_historical->style[0] = 'font-weight: bold'; + + $table_historical->size[0] = '70%'; + $table_historical->size[1] = '30%'; + + enterprise_hook('enterprise_warnings_history_days'); + + $table_historical->data[0][0] = __('Max. days before purge'); + $table_historical->data[0][0] .= ui_print_help_tip( + __('Configure a purge period more frequent than a compact data period has no sense'), + true + ); + $table_historical->data[0][1] = html_print_input_text( + 'historical_days_purge', + $config_history['days_purge'], + '', + 5, + 5, + true + ); + + $table_historical->data[1][0] = __('Max. days before compact data'); + $table_historical->data[1][1] = html_print_input_text( + 'historical_days_compact', + $config_history['days_compact'], + '', + 5, + 5, + true + ); + + $table_historical->data[2][0] = __('Compact interpolation in hours (1 Fine-20 bad)'); + $table_historical->data[2][0] .= ui_print_help_tip( + __('Data will be compacted in intervals of the specified length.'), + true + ); + $table_historical->data[2][1] = html_print_input_text( + 'historical_step_compact', + $config_history['step_compact'], + '', + 5, + 5, + true + ); + + $table_historical->data[3][0] = __('Max. days before delete events'); + $table_historical->data[3][0] .= ui_print_help_tip( + __('If the compaction or purge of the data is more frequent than the events deletion, anomalies in module graphs could appear'), + true + ); + + $table_historical->data[3][1] = html_print_input_text( + 'historical_event_purge', + $config_history['event_purge'], + '', + 5, + 5, + true + ); + + $table_historical->data[4][0] = __('Max. days before delete string data'); + $table_historical->data[4][1] = html_print_input_text( + 'historical_string_purge', + $config_history['string_purge'], + '', + 5, + 5, + true + ); + + $table_historical->data[4][1] .= html_print_input_hidden( + 'historical_history_db_enabled', + 0, + true + ); } $table_other = new stdClass(); $table_other->width = '100%'; $table_other->class = 'databox filters'; -$table_other->data = array (); -$table_other->style[0] = "font-weight: bold"; +$table_other->data = []; +$table_other->style[0] = 'font-weight: bold'; $table_other->size[0] = '70%'; $table_other->size[1] = '30%'; -$table_other->data[1][0] = __('Item limit for realtime reports') . ui_print_help_tip(__('Set a value too high cause a slowdown on console and a performance penalty in the system.'), true); -$table_other->data[1][1] = html_print_input_text ('report_limit', - $config["report_limit"], '', 5, 5, true); - -$table_other->data[2][0] = __('Compact interpolation in hours (1 Fine-20 bad)') . ui_print_help_tip(__('Data will be compacted in intervals of the specified length.'), true); -$table_other->data[2][1] = html_print_input_text ('step_compact', - $config["step_compact"], '', 5, 5, true); +$table_other->data[1][0] = __('Item limit for realtime reports'); +$table_other->data[1][0] .= ui_print_help_tip( + __('Set a value too high cause a slowdown on console and a performance penalty in the system.'), + true +); +$table_other->data[1][1] = html_print_input_text( + 'report_limit', + $config['report_limit'], + '', + 5, + 5, + true +); -$intervals = array (); +$table_other->data[2][0] = __('Compact interpolation in hours (1 Fine-20 bad)'); +$table_other->data[2][0] .= ui_print_help_tip( + __('Data will be compacted in intervals of the specified length.'), + true +); +$table_other->data[2][1] = html_print_input_text( + 'step_compact', + $config['step_compact'], + '', + 5, + 5, + true +); + +$intervals = []; $intervals[SECONDS_1HOUR] = __('1 hour'); $intervals[SECONDS_12HOURS] = __('12 hours'); $intervals[SECONDS_1DAY] = __('Last day'); @@ -112,49 +550,172 @@ $intervals[SECONDS_2WEEK] = __('2 weeks'); $intervals[SECONDS_1MONTH] = __('Last month'); $table_other->data[3][0] = __('Default hours for event view'); -$table_other->data[3][1] = html_print_input_text ('event_view_hr', $config["event_view_hr"], '', 5, 5, true); +$table_other->data[3][1] = html_print_input_text( + 'event_view_hr', + $config['event_view_hr'], + '', + 5, + 5, + true +); $table_other->data[5][0] = __('Use realtime statistics'); -$table_other->data[5][1] = __('Yes').' '.html_print_radio_button ('realtimestats', 1, '', $config["realtimestats"], true).'  '; -$table_other->data[5][1] .= __('No').' '.html_print_radio_button ('realtimestats', 0, '', $config["realtimestats"], true); +$table_other->data[5][1] = __('Yes').' '.html_print_radio_button( + 'realtimestats', + 1, + '', + $config['realtimestats'], + true +).'  '; +$table_other->data[5][1] .= __('No').' '.html_print_radio_button( + 'realtimestats', + 0, + '', + $config['realtimestats'], + true +); -$table_other->data[6][0] = __('Batch statistics period (secs)') . ui_print_help_tip(__('If realtime statistics are disabled, statistics interval resfresh will be set here.'), true); -$table_other->data[6][1] = html_print_input_text ('stats_interval', $config["stats_interval"], '', 5, 5, true); +$table_other->data[6][0] = __('Batch statistics period (secs)'); +$table_other->data[6][0] .= ui_print_help_tip( + __('If realtime statistics are disabled, statistics interval resfresh will be set here.'), + true +); +$table_other->data[6][1] = html_print_input_text( + 'stats_interval', + $config['stats_interval'], + '', + 5, + 5, + true +); -$table_other->data[7][0] = __('Use agent access graph') . ui_print_help_icon("agent_access", true); -$table_other->data[7][1] = __('Yes').' '.html_print_radio_button ('agentaccess', 1, '', $config["agentaccess"], true).'  '; -$table_other->data[7][1] .= __('No').' '.html_print_radio_button ('agentaccess', 0, '', $config["agentaccess"], true); +$table_other->data[7][0] = __('Use agent access graph'); +$table_other->data[7][0] .= ui_print_help_icon( + 'agent_access', + true +); +$table_other->data[7][1] = __('Yes').' '; +$table_other->data[7][1] .= html_print_radio_button( + 'agentaccess', + 1, + '', + $config['agentaccess'], + true +).'  '; +$table_other->data[7][1] .= __('No').' '; +$table_other->data[7][1] .= html_print_radio_button( + 'agentaccess', + 0, + '', + $config['agentaccess'], + true +); -$table_other->data[8][0] = __('Max. recommended number of files in attachment directory') . ui_print_help_tip(__('This number is the maximum number of files in attachment directory. If this number is reached then a warning message will appear in the header notification space.'), true); -$table_other->data[8][1] = html_print_input_text ('num_files_attachment', $config["num_files_attachment"], '', 5, 5, true); +$table_other->data[8][0] = __('Max. recommended number of files in attachment directory'); +$table_other->data[8][0] .= ui_print_help_tip( + __('This number is the maximum number of files in attachment directory. If this number is reached then a warning message will appear in the header notification space.'), + true +); +$table_other->data[8][1] = html_print_input_text( + 'num_files_attachment', + $config['num_files_attachment'], + '', + 5, + 5, + true +); $table_other->data[9][0] = __('Delete not init modules'); -$table_other->data[9][1] = __('Yes').' '.html_print_radio_button ('delete_notinit', 1, '', $config["delete_notinit"], true).'  '; -$table_other->data[9][1] .= __('No').' '.html_print_radio_button ('delete_notinit', 0, '', $config["delete_notinit"], true); +$table_other->data[9][1] = __('Yes').' '; +$table_other->data[9][1] .= html_print_radio_button( + 'delete_notinit', + 1, + '', + $config['delete_notinit'], + true +).'  '; +$table_other->data[9][1] .= __('No').' '.html_print_radio_button( + 'delete_notinit', + 0, + '', + $config['delete_notinit'], + true +); -$table_other->data[10][0] = __('Big Operation Step to purge old data') . ui_print_help_tip(__('The number of blocks that a time interval is split into. A bigger value means bigger blocks, which is faster but heavier on the database. Default is 100.'), true); -$table_other->data[10][1] = html_print_input_text ('big_operation_step_datos_purge', $config["big_operation_step_datos_purge"], '', 5, 5, true); +$table_other->data[10][0] = __('Big Operation Step to purge old data'); +$table_other->data[10][0] .= ui_print_help_tip( + __('The number of blocks that a time interval is split into. A bigger value means bigger blocks, which is faster but heavier on the database. Default is 100.'), + true +); +$table_other->data[10][1] = html_print_input_text( + 'big_operation_step_datos_purge', + $config['big_operation_step_datos_purge'], + '', + 5, + 5, + true +); -$table_other->data[11][0] = __('Small Operation Step to purge old data') . ui_print_help_tip(__('The number of rows that are processed in a single query in deletion. Default is 1000. Increase to 3000-5000 in fast systems. Decrease to 500 or 250 on systems with locks.'), true); -$table_other->data[11][1] = html_print_input_text ('small_operation_step_datos_purge', $config["small_operation_step_datos_purge"], '', 5, 5, true); +$table_other->data[11][0] = __('Small Operation Step to purge old data'); +$table_other->data[11][0] .= ui_print_help_tip( + __('The number of rows that are processed in a single query in deletion. Default is 1000. Increase to 3000-5000 in fast systems. Decrease to 500 or 250 on systems with locks.'), + true +); +$table_other->data[11][1] = html_print_input_text( + 'small_operation_step_datos_purge', + $config['small_operation_step_datos_purge'], + '', + 5, + 5, + true +); -$table_other->data[12][0] = __('Graph container - Max. Items') . ui_print_help_tip(__('The number of graphs that are viewed in a container. Default is 10 .Increasing this number could lead to performance problems'), true); -$table_other->data[12][1] = html_print_input_text ('max_graph_container', $config["max_graph_container"], '', 5, 5, true); +$table_other->data[12][0] = __('Graph container - Max. Items'); +$table_other->data[12][0] .= ui_print_help_tip( + __('The number of graphs that are viewed in a container. Default is 10 .Increasing this number could lead to performance problems'), + true +); +$table_other->data[12][1] = html_print_input_text( + 'max_graph_container', + $config['max_graph_container'], + '', + 5, + 5, + true +); echo ''; -echo "
"; -echo "" . __('Database maintenance options') . ""; -html_print_input_hidden ('update_config', 1); -html_print_table ($table); -echo "
"; -echo "
"; -echo "" . __('Others') . ""; -html_print_input_hidden ('update_config', 1); -html_print_table ($table_other); -echo "
"; +echo '
'; + echo ''.__('Database maintenance status').''; + html_print_table($table_status); +echo '
'; + +echo '
'; + echo ''.__('Database maintenance options').''; + html_print_table($table); +echo '
'; + +if ($config['history_db_enabled'] == 1) { + echo '
'; + echo ''.__('Historical database maintenance options').''; + html_print_table($table_historical); + echo '
'; +} + +echo '
'; + echo ''.__('Others').''; + html_print_table($table_other); +echo '
'; + echo '
'; -html_print_submit_button (__('Update'), 'update_button', false, 'class="sub upd"'); +html_print_input_hidden('update_config', 1); +html_print_submit_button( + __('Update'), + 'update_button', + false, + 'class="sub upd"' +); echo '
'; echo ''; ?> @@ -162,14 +723,13 @@ echo ''; diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 1b4f2a208c..7f88982a14 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -1,175 +1,205 @@ - $timezone) { - if (strpos($timezone, $zone) === false) { - unset($timezones[$timezone_key]); - } - } - - echo json_encode($timezones); - } - return; +if (is_ajax()) { + $get_os_icon = (bool) get_parameter('get_os_icon'); + $select_timezone = get_parameter('select_timezone', 0); + + if ($get_os_icon) { + $id_os = (int) get_parameter('id_os'); + ui_print_os_icon($id_os, false); + return; + } + + if ($select_timezone) { + $zone = get_parameter('zone'); + + $timezones = timezone_identifiers_list(); + foreach ($timezones as $timezone_key => $timezone) { + if (strpos($timezone, $zone) === false) { + unset($timezones[$timezone_key]); + } + } + + echo json_encode($timezones); + } + + return; } -if (! check_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_user'])) { - db_pandora_audit("ACL Violation", "Trying to access Setup Management"); - require ("general/noaccess.php"); - return; +if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) { + db_pandora_audit('ACL Violation', 'Trying to access Setup Management'); + include 'general/noaccess.php'; + return; } -// Load enterprise extensions -enterprise_include_once ('include/functions_setup.php'); -enterprise_include_once ('include/functions_io.php'); -enterprise_include_once ('godmode/setup/setup.php'); + +// Load enterprise extensions. +enterprise_include_once('include/functions_setup.php'); +enterprise_include_once('include/functions_io.php'); +enterprise_include_once('godmode/setup/setup.php'); /* -NOTICE FOR DEVELOPERS: + NOTICE FOR DEVELOPERS: -Update operation is done in config_process.php -This is done in that way so the user can see the changes inmediatly. -If you added a new token, please check config_update_config() in functions_config.php -to add it there. + Update operation is done in config_process.php + This is done in that way so the user can see the changes inmediatly. + If you added a new token, please check config_update_config() in functions_config.php + to add it there. */ -// Gets section to jump to another section -$section = (string) get_parameter ("section", "general"); +// Gets section to jump to another section. +$section = (string) get_parameter('section', 'general'); -$buttons = array(); +$buttons = []; -// Draws header -$buttons['general'] = array('active' => false, - 'text' => '' . - html_print_image("images/gm_setup.png", true, array ("title" => __('General'))) . ''); +// Draws header. +$buttons['general'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/gm_setup.png', true, ['title' => __('General')]).'', +]; if (enterprise_installed()) { - $buttons = setup_enterprise_add_Tabs($buttons); + $buttons = setup_enterprise_add_Tabs($buttons); } -$buttons['auth'] = array('active' => false, - 'text' => '' . - html_print_image("images/key.png", true, array ("title" => __('Authentication'))) . ''); +$buttons['auth'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/key.png', true, ['title' => __('Authentication')]).'', +]; -$buttons['perf'] = array('active' => false, - 'text' => '' . - html_print_image("images/performance.png", true, array ("title" => __('Performance'))) . ''); +$buttons['perf'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/performance.png', true, ['title' => __('Performance')]).'', +]; -$buttons['vis'] = array('active' => false, - 'text' => '' . - html_print_image("images/chart.png", true, array ("title" => __('Visual styles'))) . ''); +$buttons['vis'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/chart.png', true, ['title' => __('Visual styles')]).'', +]; -if (check_acl ($config['id_user'], 0, "AW")) { - if ($config['activate_netflow']) { - $buttons['net'] = array('active' => false, - 'text' => '' . - html_print_image("images/op_netflow.png", true, array ("title" => __('Netflow'))) . ''); - } +if (check_acl($config['id_user'], 0, 'AW')) { + if ($config['activate_netflow']) { + $buttons['net'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/op_netflow.png', true, ['title' => __('Netflow')]).'', + ]; + } } -$buttons['ehorus'] = array('active' => false, - 'text' => '' . - html_print_image("images/ehorus/ehorus.png", true, array ("title" => __('eHorus'))) . ''); +$buttons['ehorus'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('eHorus')]).'', +]; $help_header = ''; if (enterprise_installed()) { - $subpage = setup_enterprise_add_subsection_main($section, $buttons, $help_header); + $subpage = setup_enterprise_add_subsection_main($section, $buttons, $help_header); } switch ($section) { - case 'general': - $buttons['general']['active'] = true; - $subpage = ' » ' . __('General'); - break; - case 'auth': - $buttons['auth']['active'] = true; - $subpage = ' » ' . __('Authentication'); - break; - case 'perf': - $buttons['perf']['active'] = true; - $subpage = ' » ' . __('Performance'); - $help_header = 'performance'; - break; - case 'vis': - $buttons['vis']['active'] = true; - $subpage = ' » ' . __('Visual styles'); - break; - case 'net': - $buttons['net']['active'] = true; - $subpage = ' » ' . __('Netflow'); - break; - case 'ehorus': - $buttons['ehorus']['active'] = true; - $subpage = ' » ' . __('eHorus'); - break; + case 'general': + default: + $buttons['general']['active'] = true; + $subpage = ' » '.__('General'); + break; + + case 'auth': + $buttons['auth']['active'] = true; + $subpage = ' » '.__('Authentication'); + break; + + case 'perf': + $buttons['perf']['active'] = true; + $subpage = ' » '.__('Performance'); + $help_header = 'performance'; + break; + + case 'vis': + $buttons['vis']['active'] = true; + $subpage = ' » '.__('Visual styles'); + break; + + case 'net': + $buttons['net']['active'] = true; + $subpage = ' » '.__('Netflow'); + break; + + case 'ehorus': + $buttons['ehorus']['active'] = true; + $subpage = ' » '.__('eHorus'); + break; } -// Header -ui_print_page_header (__('Configuration') . $subpage, "", false, $help_header, true, $buttons); +// Header. +ui_print_page_header(__('Configuration').$subpage, '', false, $help_header, true, $buttons); if (isset($config['error_config_update_config'])) { - if ($config['error_config_update_config']['correct'] == false) { - ui_print_error_message($config['error_config_update_config']['message']); - } - else { - ui_print_success_message(__('Correct update the setup options')); - } - - unset($config['error_config_update_config']); + if ($config['error_config_update_config']['correct'] == false) { + ui_print_error_message($config['error_config_update_config']['message']); + } else { + ui_print_success_message(__('Correct update the setup options')); + } + + unset($config['error_config_update_config']); } switch ($section) { - case "general": - require_once($config['homedir'] . "/godmode/setup/setup_general.php"); - break; - case "auth": - require_once($config['homedir'] . "/godmode/setup/setup_auth.php"); - break; - case "perf": - require_once($config['homedir'] . "/godmode/setup/performance.php"); - break; - case "net": - require_once($config['homedir'] . "/godmode/setup/setup_netflow.php"); - break; - case "vis": - require_once($config['homedir'] . "/godmode/setup/setup_visuals.php"); - break; - case "ehorus": - require_once($config['homedir'] . "/godmode/setup/setup_ehorus.php"); - break; - default: - enterprise_hook('setup_enterprise_select_tab', array($section)); - break; -} + case 'general': + include_once $config['homedir'].'/godmode/setup/setup_general.php'; + break; -?> + case 'auth': + include_once $config['homedir'].'/godmode/setup/setup_auth.php'; + break; + + case 'perf': + include_once $config['homedir'].'/godmode/setup/performance.php'; + break; + + case 'net': + include_once $config['homedir'].'/godmode/setup/setup_netflow.php'; + break; + + case 'vis': + include_once $config['homedir'].'/godmode/setup/setup_visuals.php'; + break; + + case 'ehorus': + include_once $config['homedir'].'/godmode/setup/setup_ehorus.php'; + break; + + default: + enterprise_hook('setup_enterprise_select_tab', [$section]); + break; +} From 9af1680e1589cac3013d46c45b40317bf3f59563 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 30 Jan 2019 16:57:07 +0100 Subject: [PATCH 09/29] fixed error php7 info install and RPM Former-commit-id: 4c38ee93e01d2ff88bb0d3dc563cf7bbbbcd9946 --- pandora_console/install.php | 3 +-- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pandora_console/install.php b/pandora_console/install.php index 18a2a6d9cb..493cc357d0 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -487,7 +487,7 @@ function install_step2() { echo "

Checking software dependencies

"; echo ""; $res = 0; - $res += check_variable(phpversion(),"5.2","PHP version >= 5.2",1); + $res += check_variable(phpversion(),"7.0","PHP version >= 7.0",1); $res += check_extension("gd","PHP GD extension"); $res += check_extension("ldap","PHP LDAP extension"); $res += check_extension("snmp","PHP SNMP extension"); @@ -518,7 +518,6 @@ function install_step2() { font-size: 8.5pt;margin-top: 2px; font-weight: bolder;'>DB Engines"; echo ""; - check_extension("mysql", "PHP MySQL extension"); check_extension("mysqli", "PHP MySQL(mysqli) extension"); echo "
"; echo "
"; diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 3ece0b1383..f8cca88d0a 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -26,7 +26,7 @@ BuildRoot: %{_tmppath}/%{name} BuildArch: noarch AutoReq: 0 Requires: %{httpd_name} >= 2.0.0 -Requires: mod_php >= 5.2.0 +Requires: mod_php >= 7.0 Requires: php-gd, php-ldap, php-snmp, php-session, php-gettext Requires: php-mysqlnd, php-mbstring, php-zip, php-zlib, php-curl Requires: xorg-x11-fonts-75dpi, xorg-x11-fonts-misc, php-pecl-zip diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 91dcf164e1..7e3d73910f 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -29,7 +29,7 @@ BuildArch: noarch AutoReq: 0 Requires: apache2 Requires: apache2-mod_php7 -Requires: php >= 4.3.0 +Requires: php >= 7.0 Requires: php-gd, php-snmp, php-json, php-gettext Requires: php-mysqlnd, php-ldap, php-mbstring, php Requires: graphviz, xorg-x11-fonts-core, graphviz-gd From 20e0508e01122f2461cceaabe83d96b0e9ab53b6 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 4 Feb 2019 12:10:52 +0100 Subject: [PATCH 10/29] fixed pdf report Former-commit-id: 515b8f06f3584c6aaa1a32ea29a2f555e7afccad --- .../include/functions_reporting.php | 8 +- .../include/functions_reporting_html.php | 279 +++++++++++------- pandora_console/include/styles/pandora.css | 48 +-- pandora_console/include/styles/pandoraPDF.css | 71 +++++ pandora_console/index.php | 1 - 5 files changed, 269 insertions(+), 138 deletions(-) create mode 100644 pandora_console/include/styles/pandoraPDF.css diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 03c5427d60..a4dbe7685d 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -261,7 +261,7 @@ function reporting_make_reporting_data( } if (isset($content['style']['name_label'])) { - // Add macros name + // Add macros name. $items_label = []; $items_label['type'] = $content['type']; $items_label['id_agent'] = $content['id_agent']; @@ -272,11 +272,10 @@ function reporting_make_reporting_data( $metaconsole_on = is_metaconsole(); $server_name = $content['server_name']; - // Metaconsole connection + // Metaconsole connection. if ($metaconsole_on && $server_name != '') { $connection = metaconsole_get_connection($server_name); if (!metaconsole_load_external_db($connection)) { - // ui_print_error_message ("Error connecting to ".$server_name); continue; } } @@ -889,7 +888,6 @@ function reporting_SLA( if ($metaconsole_on && $server_name != '') { $connection = metaconsole_get_connection($server_name); if (!metaconsole_load_external_db($connection)) { - // ui_print_error_message ("Error connecting to ".$server_name); continue; } } @@ -898,7 +896,7 @@ function reporting_SLA( || modules_is_not_init($sla['id_agent_module']) ) { if ($metaconsole_on) { - // Restore db connection + // Restore db connection. metaconsole_restore_db(); } diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 8bc7c973f3..84396cfb91 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -102,12 +102,12 @@ function html_do_report_info($report) $date_today = date($config['date_format']); - $html = '
'.' - - - - - '; + $html = '
'.__('Generated').': '.$date_today.'
'.__('Report date').':
+ + + + + '; if (isset($report['period'])) { if (is_numeric($report['datetime']) && is_numeric($report['period'])) { $html .= ''; @@ -119,10 +119,10 @@ function html_do_report_info($report) } $html .= ' - - - -
'.__('Generated').': '.$date_today.'
'.__('Report date').': '.date($config['date_format'], ($report['datetime'] - $report['period'])).'
'.__('Description').': '.io_safe_output($report['description']).'
'.'
'; + + '.__('Description').': '.io_safe_output($report['description']).' + + '.''; echo $html; } @@ -397,9 +397,20 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) } -function reporting_html_SLA($table, $item, $mini) +function reporting_html_SLA($table, $item, $mini, $pdf=0) { - $style = db_get_value('style', 'treport_content', 'id_rc', $item['id_rc']); + if ($table === false) { + $table = new stdClass(); + $table->width = '99%'; + $table->class = 'table_beauty'; + } + + $style = db_get_value( + 'style', + 'treport_content', + 'id_rc', + $item['id_rc'] + ); $style = json_decode(io_safe_output($style), true); $same_agent_in_resume = ''; @@ -423,7 +434,9 @@ function reporting_html_SLA($table, $item, $mini) $table->data['sla']['cell'] = $item['failed']; } else { if (!empty($item['planned_downtimes'])) { - $downtimes_table = reporting_html_planned_downtimes_table($item['planned_downtimes']); + $downtimes_table = reporting_html_planned_downtimes_table( + $item['planned_downtimes'] + ); if (!empty($downtimes_table)) { $table->colspan['planned_downtime']['cell'] = 3; @@ -459,7 +472,7 @@ function reporting_html_SLA($table, $item, $mini) $table1->headstyle[4] = 'text-align: right'; $table1->headstyle[5] = 'text-align: right'; - // second_table for time globals + // Second_table for time globals. $table2 = new stdClass(); $table2->width = '99%'; @@ -490,7 +503,7 @@ function reporting_html_SLA($table, $item, $mini) $table2->headstyle[5] = 'text-align: right'; $table2->headstyle[6] = 'text-align: right'; - // third_table for time globals + // Third_table for time globals. $table3 = new stdClass(); $table3->width = '99%'; @@ -520,15 +533,23 @@ function reporting_html_SLA($table, $item, $mini) foreach ($item['data'] as $sla) { if (isset($sla)) { - $the_first_men_time = get_agent_first_time(io_safe_output($sla['agent'])); + $the_first_men_time = get_agent_first_time( + io_safe_output($sla['agent']) + ); - // first_table + // First_table. $row = []; $row[] = $sla['agent']; $row[] = $sla['module']; if (is_numeric($sla['dinamic_text'])) { - $row[] = sla_truncate($sla['max'], $config['graph_precision']).' / '.sla_truncate($sla['min'], $config['graph_precision']); + $row[] = sla_truncate( + $sla['max'], + $config['graph_precision'] + ).' / '.sla_truncate( + $sla['min'], + $config['graph_precision'] + ); } else { $row[] = $sla['dinamic_text']; } @@ -550,47 +571,64 @@ function reporting_html_SLA($table, $item, $mini) $row[] = ''.__('Fail').''; } - // second table for time globals + // Second table for time globals. $row2 = []; $row2[] = $sla['agent'].' -- ['.$sla['module'].']'; if ($sla['time_total'] != 0) { - $row2[] = human_time_description_raw($sla['time_total']); + $row2[] = human_time_description_raw( + $sla['time_total'] + ); } else { $row2[] = '--'; } if ($sla['time_error'] != 0) { - $row2[] = ''.human_time_description_raw($sla['time_error'], true).''; + $row2[] = ''.human_time_description_raw( + $sla['time_error'], + true + ).''; } else { $row2[] = '--'; } if ($sla['time_ok'] != 0) { - $row2[] = ''.human_time_description_raw($sla['time_ok'], true).''; + $row2[] = ''.human_time_description_raw( + $sla['time_ok'], + true + ).''; } else { $row2[] = '--'; } if ($sla['time_unknown'] != 0) { - $row2[] = ''.human_time_description_raw($sla['time_unknown'], true).''; + $row2[] = ''.human_time_description_raw( + $sla['time_unknown'], + true + ).''; } else { $row2[] = '--'; } if ($sla['time_not_init'] != 0) { - $row2[] = ''.human_time_description_raw($sla['time_not_init'], true).''; + $row2[] = ''.human_time_description_raw( + $sla['time_not_init'], + true + ).''; } else { $row2[] = '--'; } if ($sla['time_downtime'] != 0) { - $row2[] = ''.human_time_description_raw($sla['time_downtime'], true).''; + $row2[] = ''.human_time_description_raw( + $sla['time_downtime'], + true + ).''; } else { $row2[] = '--'; } - // third table for checks globals + // Third table for checks globals. $row3 = []; $row3[] = $sla['agent'].' -- ['.$sla['module'].']'; $row3[] = $sla['checks_total']; @@ -605,11 +643,20 @@ function reporting_html_SLA($table, $item, $mini) } $table->colspan['sla']['cell'] = 2; - $table->data['sla']['cell'] = html_print_table($table1, true); + $table->data['sla']['cell'] = html_print_table( + $table1, + true + ); $table->colspan['time_global']['cell'] = 2; - $table->data['time_global']['cell'] = html_print_table($table2, true); + $table->data['time_global']['cell'] = html_print_table( + $table2, + true + ); $table->colspan['checks_global']['cell'] = 2; - $table->data['checks_global']['cell'] = html_print_table($table3, true); + $table->data['checks_global']['cell'] = html_print_table( + $table3, + true + ); } else { $table->colspan['error']['cell'] = 3; $table->data['error']['cell'] = __('There are no Agent/Modules defined'); @@ -631,9 +678,12 @@ function reporting_html_SLA($table, $item, $mini) } $table->colspan['charts']['cell'] = 2; - $table->data['charts']['cell'] = html_print_table($table1, true); + $table->data['charts']['cell'] = html_print_table( + $table1, + true + ); - // table_legend_graphs; + // Table_legend_graphs. $table1 = new stdClass(); $table1->width = '99%'; $table1->data = []; @@ -669,9 +719,16 @@ function reporting_html_SLA($table, $item, $mini) $table1->data[0][11] = ''.__('Ignore time').''; $table->colspan['legend']['cell'] = 2; - $table->data['legend']['cell'] = html_print_table($table1, true); + $table->data['legend']['cell'] = html_print_table( + $table1, + true + ); } } + + if ($pdf !== 0) { + return html_print_table($table, true); + } } @@ -794,7 +851,7 @@ function reporting_html_event_report_group($table, $item, $pdf=0) } foreach ($item['data'] as $k => $event) { - // First pass along the class of this row + // First pass along the class of this row. if ($item['show_summary_group']) { $table1->cellclass[$k][1] = $table1->cellclass[$k][2] = $table1->cellclass[$k][4] = $table1->cellclass[$k][5] = $table1->cellclass[$k][6] = $table1->cellclass[$k][7] = get_priority_class($event['criticity']); } else { @@ -1559,53 +1616,53 @@ function reporting_html_group_report($table, $item) $table->colspan['group_report']['cell'] = 3; $table->cellstyle['group_report']['cell'] = 'text-align: center;'; $table->data['group_report']['cell'] = " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
".__('Total')."
".__('Unknown')."
".__('Agents')."
".$item['data']['group_stats']['total_agents']."
".$item['data']['group_stats']['agents_unknown']."
".__('Total')."
".__('Normal')."
".__('Critical')."
".__('Warning')."
".__('Unknown')."
".__('Not init')."
".__('Monitors')."
".$item['data']['group_stats']['monitor_checks']."
".$item['data']['group_stats']['monitor_ok']."
".$item['data']['group_stats']['monitor_critical']."
".$item['data']['group_stats']['monitor_warning']."
".$item['data']['group_stats']['monitor_unknown']."
".$item['data']['group_stats']['monitor_not_init']."
".__('Defined')."
".__('Fired')."
".__('Alerts')."
".$item['data']['group_stats']['monitor_alerts']."
".$item['data']['group_stats']['monitor_alerts_fired']."
".__('Last %s', human_time_description_raw($item['date']['period']))."
".__('Events')."
".$item['data']['count_events'].'
'; + + +
".__('Total')."
+
".__('Unknown')."
+ + +
".__('Agents')."
+
".$item['data']['group_stats']['total_agents']."
+
".$item['data']['group_stats']['agents_unknown']."
+ + + +
".__('Total')."
+
".__('Normal')."
+
".__('Critical')."
+
".__('Warning')."
+
".__('Unknown')."
+
".__('Not init')."
+ + +
".__('Monitors')."
+
".$item['data']['group_stats']['monitor_checks']."
+
".$item['data']['group_stats']['monitor_ok']."
+
".$item['data']['group_stats']['monitor_critical']."
+
".$item['data']['group_stats']['monitor_warning']."
+
".$item['data']['group_stats']['monitor_unknown']."
+
".$item['data']['group_stats']['monitor_not_init']."
+ + + +
".__('Defined')."
+
".__('Fired')."
+ + +
".__('Alerts')."
+
".$item['data']['group_stats']['monitor_alerts']."
+
".$item['data']['group_stats']['monitor_alerts_fired']."
+ + + +
".__('Last %s', human_time_description_raw($item['date']['period']))."
+ + +
".__('Events')."
+
".$item['data']['count_events'].'
+ + '; } @@ -2302,15 +2359,15 @@ function reporting_html_url(&$table, $item, $key) $table->colspan['data']['cell'] = 3; $table->cellstyle['data']['cell'] = 'text-align: left;'; $table->data['data']['cell'] = ' - '; + '; // TODO: make this dynamic and get the height if the iframe to resize this item $table->data['data']['cell'] .= ' - '; + '; } @@ -2635,8 +2692,8 @@ function get_agent_first_time($agent_name) $utimestamp = db_get_all_rows_sql( 'SELECT utimestamp FROM tagente_datos WHERE id_agente_modulo IN - (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = '.$id.') - ORDER BY utimestamp ASC LIMIT 1' + (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = '.$id.') + ORDER BY utimestamp ASC LIMIT 1' ); $utimestamp = $utimestamp[0]['utimestamp']; @@ -2878,7 +2935,7 @@ function reporting_get_stats_summary($data, $graph_width, $graph_height) $table_sum->data[] = $tdata; $output = '
- '.__('Summary').''.html_print_table($table_sum, true).'
'; + '.__('Summary').''.html_print_table($table_sum, true).'
'; return $output; } @@ -3459,12 +3516,12 @@ function reporting_get_agents_by_status($data, $graph_width=250, $graph_height=1 if (!defined('METACONSOLE')) { $agents_data = '
- '.__('Agents by status').''.html_print_table($table_agent, true).'
'; + '.__('Agents by status').''.html_print_table($table_agent, true).''; } else { $table_agent->style = []; $table_agent->class = 'tactical_view'; $agents_data = '
- '.__('Agents by status').''.html_print_table($table_agent, true).'
'; + '.__('Agents by status').''.html_print_table($table_agent, true).''; } return $agents_data; @@ -3487,7 +3544,7 @@ function reporting_get_total_agents_and_monitors($data, $graph_width=250, $graph $total_data[3] = $total_module <= 0 ? '-' : $total_module; $table_total->data[] = $total_data; $total_agent_module = '
- '.__('Total agents and monitors').''.html_print_table($table_total, true).'
'; + '.__('Total agents and monitors').''.html_print_table($table_total, true).''; return $total_agent_module; } @@ -3506,12 +3563,12 @@ function reporting_get_total_servers($num_servers) if (!defined('METACONSOLE')) { $node_overview = '
- '.__('Node overview').''.html_print_table($table_node, true).'
'; + '.__('Node overview').''.html_print_table($table_node, true).''; } else { $table_node->style = []; $table_node->class = 'tactical_view'; $node_overview = '
- '.__('Node overview').''.html_print_table($table_node, true).'
'; + '.__('Node overview').''.html_print_table($table_node, true).''; } return $node_overview; @@ -3555,7 +3612,7 @@ function reporting_get_events($data, $links=false) if (!defined('METACONSOLE')) { $event_view = '
- '.__('Events by severity').''.html_print_table($table_events, true).'
'; + '.__('Events by severity').''.html_print_table($table_events, true).''; } else { $table_events->class = 'tactical_view'; $table_events->styleTable = 'text-align:center;'; @@ -3565,7 +3622,7 @@ function reporting_get_events($data, $links=false) $table_events->size[3] = '10%'; $event_view = '
- '.__('Important Events by Criticity').''.html_print_table($table_events, true).'
'; + '.__('Important Events by Criticity').''.html_print_table($table_events, true).''; } return $event_view; @@ -3597,9 +3654,9 @@ function reporting_get_last_activity() case 'mysql': $sql = sprintf( 'SELECT id_usuario,accion,fecha,ip_origen,descripcion,utimestamp - FROM tsesion - WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - '.SECONDS_1WEEK.") - AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 5", + FROM tsesion + WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - '.SECONDS_1WEEK.") + AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 5", $config['id_user'] ); break; @@ -3607,9 +3664,9 @@ function reporting_get_last_activity() case 'postgresql': $sql = sprintf( "SELECT \"id_usuario\", accion, fecha, \"ip_origen\", descripcion, utimestamp - FROM tsesion - WHERE (\"utimestamp\" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - ".SECONDS_1WEEK.") - AND \"id_usuario\" = '%s' ORDER BY \"utimestamp\" DESC LIMIT 5", + FROM tsesion + WHERE (\"utimestamp\" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - ".SECONDS_1WEEK.") + AND \"id_usuario\" = '%s' ORDER BY \"utimestamp\" DESC LIMIT 5", $config['id_user'] ); break; @@ -3617,9 +3674,9 @@ function reporting_get_last_activity() case 'oracle': $sql = sprintf( "SELECT id_usuario, accion, fecha, ip_origen, descripcion, utimestamp - FROM tsesion - WHERE ((utimestamp > ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - '.SECONDS_1WEEK.") - AND id_usuario = '%s') AND rownum <= 10 ORDER BY utimestamp DESC", + FROM tsesion + WHERE ((utimestamp > ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - '.SECONDS_1WEEK.") + AND id_usuario = '%s') AND rownum <= 10 ORDER BY utimestamp DESC", $config['id_user'] ); break; @@ -3797,7 +3854,7 @@ function reporting_get_event_histogram($events, $text_header_event=false) if (!defined('METACONSOLE')) { if (!$text_header_event) { $event_graph = '
- '.$text_header_event.''.html_print_table($table, true).'
'; + '.$text_header_event.''.html_print_table($table, true).''; } else { $table->class = 'noclass'; $event_graph = html_print_table($table, true); @@ -3895,9 +3952,9 @@ function reporting_get_event_histogram_meta($width) $time_condition = 'utimestamp > '.$bottom.' AND utimestamp < '.$top; $sql = sprintf( 'SELECT criticity,utimestamp - FROM tmetaconsole_event - WHERE %s %s %s - ORDER BY criticity DESC', + FROM tmetaconsole_event + WHERE %s %s %s + ORDER BY criticity DESC', $time_condition, $groups_condition, $status_condition @@ -3981,7 +4038,7 @@ function reporting_get_event_histogram_meta($width) if (!$text_header_event) { $event_graph = '
- '.$text_header_event.''.html_print_table($table, true).'
'; + '.$text_header_event.''.html_print_table($table, true).''; } else { $table->class = 'noclass'; $event_graph = html_print_table($table, true); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index f42c64f70a..cd5a3d8eaf 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -1,24 +1,30 @@ -/* -Author: The Pandora FMS team -Name: Default theme -Description: The default Pandora FMS theme layout - -// Pandora FMS - http://pandorafms.com -// ========================================================== -// Copyright (c) 2004-2011 Artica Soluciones Tecnológicas S.L - -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; version 2 - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ +/** + * Extension to manage a list of gateways and the node address where they should + * point to. + * + * @category Extensions + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ /* Tree view styles */ @import url(tree.css); diff --git a/pandora_console/include/styles/pandoraPDF.css b/pandora_console/include/styles/pandoraPDF.css new file mode 100644 index 0000000000..10dc892ec6 --- /dev/null +++ b/pandora_console/include/styles/pandoraPDF.css @@ -0,0 +1,71 @@ +/** + * Extension to manage a list of gateways and the node address where they should + * point to. + * + * @category Extensions + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ + +.content_table { + width: 100%; + font-size: 20pt !important; + page-break-inside: avoid; + border-collapse: collapse; +} + +.content_table tr th, +.content_table tr td { + padding: 10px; +} + +thead.header_tr tr { + background: #e6e6e6; +} +thead.header_tr tr th { + font-weight: normal; + text-align: right; +} +thead.header_tr tr th.th_first { + font-weight: bold; + text-align: left; +} + +.table_beauty { + font-size: 20pt !important; + border-collapse: collapse; + width: 100%; +} + +.table_beauty tr td { + font-size: 20pt !important; + padding: 5px; + border: 0.1pt solid #acacac; +} + +.table_beauty tr td table { + font-size: 20pt !important; +} + +.table_beauty tr td table tr td { + font-size: 20pt !important; +} diff --git a/pandora_console/index.php b/pandora_console/index.php index ad4b93465a..321b5956dc 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1363,4 +1363,3 @@ require 'include/php_to_js_values.php'; if (__PAN_XHPROF__ === 1) { pandora_xhprof_display_result('node_index'); } - From 418d497291f8ee971be4ea0c8516bf1a9e1a74b5 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 5 Feb 2019 10:40:24 +0100 Subject: [PATCH 11/29] fixed errors pdf Former-commit-id: f7ad69f6b5e0910e5f31464ddfe94593529ef6a7 --- .../include/functions_reporting_html.php | 317 +++++++++++------- pandora_console/include/styles/pandoraPDF.css | 47 +-- 2 files changed, 226 insertions(+), 138 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 84396cfb91..d79afa08e8 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -1,25 +1,32 @@ '.__('Description').': '.io_safe_output($report['description']).' - '.''; + '.''; echo $html; } @@ -153,8 +160,6 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) $label = ''; } - // $aux = explode("-",$item['subtitle']); - // $item['subtitle'] = db_get_value ("alias","tagente","nombre",$item['agent_name']) .' -'. $aux[1]; reporting_html_header( $table, $mini, @@ -177,6 +182,7 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) switch ($item['type']) { case 'availability': + default: reporting_html_availability($table, $item); break; @@ -380,7 +386,11 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) break; case 'module_histogram_graph': - reporting_enterprise_html_module_histogram_graph($table, $item, $mini); + reporting_enterprise_html_module_histogram_graph( + $table, + $item, + $mini + ); break; } @@ -399,11 +409,7 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) function reporting_html_SLA($table, $item, $mini, $pdf=0) { - if ($table === false) { - $table = new stdClass(); - $table->width = '99%'; - $table->class = 'table_beauty'; - } + $return_pdf = ''; $style = db_get_value( 'style', @@ -411,6 +417,7 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0) 'id_rc', $item['id_rc'] ); + $style = json_decode(io_safe_output($style), true); $same_agent_in_resume = ''; @@ -447,7 +454,7 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0) if (isset($item['data'])) { $table1 = new stdClass(); $table1->width = '99%'; - + $table1->class = 'content_table databox'; $table1->align = []; $table1->align[0] = 'left'; $table1->align[1] = 'left'; @@ -475,6 +482,7 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0) // Second_table for time globals. $table2 = new stdClass(); $table2->width = '99%'; + $table2->class = 'content_table'; $table2->align = []; $table2->align[0] = 'left'; @@ -506,6 +514,7 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0) // Third_table for time globals. $table3 = new stdClass(); $table3->width = '99%'; + $table3->class = 'content_table'; $table3->align = []; $table3->align[0] = 'left'; @@ -562,12 +571,12 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0) } else if (reporting_sla_is_ignored_from_array($sla)) { $row[] = ''.__('N/A').''; $row[] = ''.__('No data').''; - // Normal calculation + // Normal calculation. } else if ($sla['sla_status']) { - $row[] = ''.sla_truncate($sla['sla_value'], $config['graph_precision']).'%'.''; + $row[] = ''.sla_truncate($sla['sla_value'], $config['graph_precision']).'%'; $row[] = ''.__('OK').''; } else { - $row[] = ''.sla_truncate($sla['sla_value'], $config['graph_precision']).'%'.''; + $row[] = ''.sla_truncate($sla['sla_value'], $config['graph_precision']).'%'; $row[] = ''.__('Fail').''; } @@ -642,92 +651,131 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0) } } - $table->colspan['sla']['cell'] = 2; - $table->data['sla']['cell'] = html_print_table( - $table1, - true - ); - $table->colspan['time_global']['cell'] = 2; - $table->data['time_global']['cell'] = html_print_table( - $table2, - true - ); - $table->colspan['checks_global']['cell'] = 2; - $table->data['checks_global']['cell'] = html_print_table( - $table3, - true - ); + if ($pdf === 0) { + $table->colspan['sla']['cell'] = 2; + $table->data['sla']['cell'] = html_print_table( + $table1, + true + ); + $table->colspan['time_global']['cell'] = 2; + $table->data['time_global']['cell'] = html_print_table( + $table2, + true + ); + $table->colspan['checks_global']['cell'] = 2; + $table->data['checks_global']['cell'] = html_print_table( + $table3, + true + ); + } else { + $return_pdf .= ''; + $return_pdf .= html_print_table( + $table1, + true + ); + $return_pdf .= ''; + + $return_pdf .= ''; + $return_pdf .= html_print_table( + $table2, + true + ); + $return_pdf .= ''; + + $return_pdf .= ''; + $return_pdf .= html_print_table( + $table3, + true + ); + $return_pdf .= ''; + } } else { $table->colspan['error']['cell'] = 3; $table->data['error']['cell'] = __('There are no Agent/Modules defined'); } if (!empty($item['charts'])) { - $table1 = new stdClass(); - $table1->width = '99%'; - $table1->size = []; - $table1->size[0] = '10%'; + /* + $table1 = new stdClass(); + $table1->width = '99%'; + $table1->size = []; + $table1->size[0] = '10%'; - $table1->data = []; + $table1->data = []; - foreach ($item['charts'] as $chart) { + foreach ($item['charts'] as $chart) { $table1->data[] = [ $chart['agent'].'
'.$chart['module'], $chart['chart'], ]; - } + } - $table->colspan['charts']['cell'] = 2; - $table->data['charts']['cell'] = html_print_table( - $table1, - true - ); + if ($pdf === 0) { + $table->colspan['charts']['cell'] = 2; + $table->data['charts']['cell'] = html_print_table( + $table1, + true + ); + } else { + $return_pdf .= html_print_table( + $table1, + true + ); + } - // Table_legend_graphs. - $table1 = new stdClass(); - $table1->width = '99%'; - $table1->data = []; - $table1->size = []; - $table1->size[0] = '2%'; - $table1->data[0][0] = ''; - $table1->size[1] = '14%'; - $table1->data[0][1] = ''.__('OK').''; + // Table_legend_graphs. + $table1 = new stdClass(); + $table1->width = '99%'; + $table1->data = []; + $table1->size = []; + $table1->size[0] = '2%'; + $table1->data[0][0] = ''; + $table1->size[1] = '14%'; + $table1->data[0][1] = ''.__('OK').''; - $table1->size[2] = '2%'; - $table1->data[0][2] = ''; - $table1->size[3] = '14%'; - $table1->data[0][3] = ''.__('Critical').''; + $table1->size[2] = '2%'; + $table1->data[0][2] = ''; + $table1->size[3] = '14%'; + $table1->data[0][3] = ''.__('Critical').''; - $table1->size[4] = '2%'; - $table1->data[0][4] = ''; - $table1->size[5] = '14%'; - $table1->data[0][5] = ''.__('Unknow').''; + $table1->size[4] = '2%'; + $table1->data[0][4] = ''; + $table1->size[5] = '14%'; + $table1->data[0][5] = ''.__('Unknow').''; - $table1->size[6] = '2%'; - $table1->data[0][6] = ''; - $table1->size[7] = '14%'; - $table1->data[0][7] = ''.__('Not Init').''; + $table1->size[6] = '2%'; + $table1->data[0][6] = ''; + $table1->size[7] = '14%'; + $table1->data[0][7] = ''.__('Not Init').''; - $table1->size[8] = '2%'; - $table1->data[0][8] = ''; - $table1->size[9] = '14%'; - $table1->data[0][9] = ''.__('Downtimes').''; + $table1->size[8] = '2%'; + $table1->data[0][8] = ''; + $table1->size[9] = '14%'; + $table1->data[0][9] = ''.__('Downtimes').''; - $table1->size[10] = '2%'; - $table1->data[0][10] = ''; - $table1->size[11] = '15%'; - $table1->data[0][11] = ''.__('Ignore time').''; + $table1->size[10] = '2%'; + $table1->data[0][10] = ''; + $table1->size[11] = '15%'; + $table1->data[0][11] = ''.__('Ignore time').''; - $table->colspan['legend']['cell'] = 2; - $table->data['legend']['cell'] = html_print_table( - $table1, - true - ); + if ($pdf === 0) { + $table->colspan['legend']['cell'] = 2; + $table->data['legend']['cell'] = html_print_table( + $table1, + true + ); + } else { + $return_pdf .= html_print_table( + $table1, + true + ); + } + */ } } if ($pdf !== 0) { - return html_print_table($table, true); + return $return_pdf; } } @@ -860,7 +908,7 @@ function reporting_html_event_report_group($table, $item, $pdf=0) $data = []; - // Colored box + // Colored box. switch ($event['estado']) { case 0: $img_st = 'images/star.png'; @@ -1075,9 +1123,10 @@ function reporting_html_event_report_module($table, $item, $pdf=0) $table1->cellclass[$i][1] = $table1->cellclass[$i][3] = $table1->cellclass[$i][4] = get_priority_class($event['criticity']); } - // Colored box + // Colored box. switch ($event['estado']) { case 0: + default: $img_st = 'images/star.png'; $title_st = __('New event'); break; @@ -1233,8 +1282,10 @@ function reporting_html_inventory_changes($table, $item) foreach ($item['data'] as $module_item) { $table1 = null; $table1->width = '99%'; + $table1->cellstyle = []; - $table1->cellstyle[0][0] = $table1->cellstyle[0][1] = 'background: #373737; color: #FFF;'; + $table1->cellstyle[0][0] = 'background: #373737; color: #FFF;'; + $table1->cellstyle[0][1] = 'background: #373737; color: #FFF;'; $table1->data[0][0] = $module_item['agent']; $table1->data[0][1] = $module_item['module']; @@ -1700,9 +1751,10 @@ function reporting_html_event_report_agent($table, $item, $pdf=0) } $data = []; - // Colored box + // Colored box. switch ($event['status']) { case 0: + default: $img_st = 'images/star.png'; $title_st = __('New event'); break; @@ -1738,7 +1790,7 @@ function reporting_html_event_report_agent($table, $item, $pdf=0) false, true ); - // $data[] = $event['event_type']; + $data[] = events_print_type_img($event['type'], true); $data[] = get_priority_name($event['criticity']); @@ -2361,7 +2413,7 @@ function reporting_html_url(&$table, $item, $key) $table->data['data']['cell'] = ' '; - // TODO: make this dynamic and get the height if the iframe to resize this item + // TODO: make this dynamic and get the height if the iframe to resize this item. $table->data['data']['cell'] .= '