From 1d7f5365ab7097160a5ad3ba8d1fc534e8d731d9 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 30 Jan 2019 12:07:17 +0100 Subject: [PATCH 1/4] 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 d9ba3af358495127cf9754cc205735cd8263e7b4 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Date: Thu, 14 Feb 2019 16:31:19 +0100 Subject: [PATCH 2/4] Fixed errors in setup performances Former-commit-id: 1eb48c00f527f43504a41aea8b352f30792e080b --- pandora_console/godmode/setup/performance.php | 198 ++++++++++-------- 1 file changed, 110 insertions(+), 88 deletions(-) diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index 66c99ea57c..946a39770d 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -63,76 +63,85 @@ if ($update_config == 1 && $config['history_db_enabled'] == 1) { $historical_event_purge = get_parameter('historical_event_purge', 0); $historical_string_purge = get_parameter('historical_string_purge', 0); - $config_history = mysql_db_process_sql( - 'SELECT * FROM tconfig', + $history_connect = @mysql_db_process_sql( + 'SELECT 1 FROM tconfig', 'affected_rows', $config['history_db_connection'], false ); - if (!$config_history) { - $sql = "INSERT INTO tconfig (token, `value`) VALUES - ('days_purge', ".$historical_days_purge."), - ('days_compact', ".$historical_days_compact."), - ('step_compact', ".$historical_step_compact."), - ('event_purge', ".$historical_event_purge."), - ('string_purge', ".$historical_string_purge."), - ('history_db_enabled', 0)"; + $config_history = false; + if ($history_connect !== false) { + $config_history = mysql_db_process_sql( + 'SELECT * FROM tconfig', + 'affected_rows', + $config['history_db_connection'], + false + ); - mysql_db_process_sql( - $sql, - 'insert_id', - $config['history_db_connection'], - false - ); - } else { - $sql = 'UPDATE tconfig SET `value` = '.$historical_days_purge." WHERE token = 'days_purge'"; - mysql_db_process_sql( - $sql, - 'update_id', - $config['history_db_connection'], - false - ); - $sql = 'UPDATE tconfig SET `value` = '.$historical_days_compact." WHERE token = 'days_compact'"; - mysql_db_process_sql( - $sql, - 'update_id', - $config['history_db_connection'], - false - ); - $sql = 'UPDATE tconfig SET `value` = '.$historical_step_compact." WHERE token = 'step_compact'"; - mysql_db_process_sql( - $sql, - 'update_id', - $config['history_db_connection'], - false - ); - $sql = 'UPDATE tconfig SET `value` = '.$historical_event_purge." WHERE token = 'event_purge'"; - mysql_db_process_sql( - $sql, - 'update_id', - $config['history_db_connection'], - false - ); - $sql = 'UPDATE tconfig SET `value` = '.$historical_string_purge." WHERE token = 'string_purge'"; - mysql_db_process_sql( - $sql, - 'update_id', - $config['history_db_connection'], - false - ); - $sql = "UPDATE tconfig SET `value` = 0 WHERE token = 'history_db_enabled'"; - mysql_db_process_sql( - $sql, - 'update_id', - $config['history_db_connection'], - false - ); + if (!$config_history) { + $sql = "INSERT INTO tconfig (token, `value`) VALUES + ('days_purge', ".$historical_days_purge."), + ('days_compact', ".$historical_days_compact."), + ('step_compact', ".$historical_step_compact."), + ('event_purge', ".$historical_event_purge."), + ('string_purge', ".$historical_string_purge."), + ('history_db_enabled', 0)"; + + mysql_db_process_sql( + $sql, + 'insert_id', + $config['history_db_connection'], + false + ); + } else { + $sql = 'UPDATE tconfig SET `value` = '.$historical_days_purge." WHERE token = 'days_purge'"; + mysql_db_process_sql( + $sql, + 'update_id', + $config['history_db_connection'], + false + ); + $sql = 'UPDATE tconfig SET `value` = '.$historical_days_compact." WHERE token = 'days_compact'"; + mysql_db_process_sql( + $sql, + 'update_id', + $config['history_db_connection'], + false + ); + $sql = 'UPDATE tconfig SET `value` = '.$historical_step_compact." WHERE token = 'step_compact'"; + mysql_db_process_sql( + $sql, + 'update_id', + $config['history_db_connection'], + false + ); + $sql = 'UPDATE tconfig SET `value` = '.$historical_event_purge." WHERE token = 'event_purge'"; + mysql_db_process_sql( + $sql, + 'update_id', + $config['history_db_connection'], + false + ); + $sql = 'UPDATE tconfig SET `value` = '.$historical_string_purge." WHERE token = 'string_purge'"; + mysql_db_process_sql( + $sql, + 'update_id', + $config['history_db_connection'], + false + ); + $sql = "UPDATE tconfig SET `value` = 0 WHERE token = 'history_db_enabled'"; + mysql_db_process_sql( + $sql, + 'update_id', + $config['history_db_connection'], + false + ); + } } } } - $table_status = new StdClass(); $table_status->width = '100%'; $table_status->class = 'databox filters'; @@ -147,6 +156,7 @@ $sql = "SELECT UNIX_TIMESTAMP(NOW()) - `value` AS updated_at $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', @@ -168,11 +178,6 @@ $table_status->data[0][0] .= human_time_description_raw( $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 @@ -187,13 +192,23 @@ if ($config['history_db_enabled'] == 1) { ); } - if ($config['history_db_connection'] !== false) { - $time_pandora_db_history = mysql_db_process_sql( - $sql, - 'insert_id', - $config['history_db_connection'], - false - ); + $history_connect = @mysql_db_process_sql( + 'SELECT 1 FROM tconfig', + 'affected_rows', + $config['history_db_connection'], + false + ); + + $time_pandora_db_history = false; + if ($history_connect !== 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 @@ -220,11 +235,6 @@ if ($config['history_db_enabled'] == 1) { } else { $table_status->data[1][0] .= __('not executed'); } - - $table_status->data[1][0] .= ui_print_help_tip( - __('WIP'), - true - ); } @@ -395,21 +405,33 @@ if ($config['history_db_enabled'] == 1) { ); } - if ($config['history_db_connection'] != false) { - $config_history_array = mysql_db_process_sql( - 'SELECT * FROM tconfig', - 'affected_rows', - $config['history_db_connection'], - false - ); + $history_connect = @mysql_db_process_sql( + 'SELECT 1 FROM tconfig', + 'affected_rows', + $config['history_db_connection'], + false + ); - $config_history = false; + $config_history = false; + if ($history_connect !== false) { + if ($config['history_db_connection'] != false) { + $config_history_array = mysql_db_process_sql( + 'SELECT * FROM tconfig', + 'affected_rows', + $config['history_db_connection'], + 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 (isset($config_history_array) && is_array($config_history_array)) { + foreach ($config_history_array as $key => $value) { + $config_history[$value['token']] = $value['value']; + } } } + } else { + echo ui_print_error_message( + __('The tconfig table does not exist in the bbdd') + ); } if ($config_history === false) { From 624d8041683a594bbe1658e7237d6ef34e92fd63 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Date: Thu, 14 Feb 2019 16:53:01 +0100 Subject: [PATCH 3/4] Fixed minor error Former-commit-id: 05fc8b97c42ee9907954cb28d9e560c9076d50e9 --- pandora_console/godmode/setup/performance.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index 946a39770d..9e663e63cc 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -430,7 +430,7 @@ if ($config['history_db_enabled'] == 1) { } } else { echo ui_print_error_message( - __('The tconfig table does not exist in the bbdd') + __('The tconfig table does not exist in the historical database') ); } From cd83f324a1385e813aac1e4d345a8cbc78fbf838 Mon Sep 17 00:00:00 2001 From: artica Date: Fri, 15 Feb 2019 00:01:26 +0100 Subject: [PATCH 4/4] Auto-updated build strings. Former-commit-id: 3efb9b48fb3cc1021d0b3e7752c3cd1607e863a5 --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 4 ++-- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 0ee00a8f17..c9e01190e9 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.731-190214 +Version: 7.0NG.731-190215 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 9ebfc5d3dc..f50b4ee8dc 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.731-190214" +pandora_version="7.0NG.731-190215" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 664a9964e3..187f94b41d 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.731'; -use constant AGENT_BUILD => '190214'; +use constant AGENT_BUILD => '190215'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 5c097c9a07..16bf75ef2f 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.731 -%define release 190214 +%define release 190215 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 820f5d3ec1..1dd06bf43e 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.731 -%define release 190214 +%define release 190215 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 8adeac4f7a..340a0c2712 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.731" -PI_BUILD="190214" +PI_BUILD="190215" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 3b606d8ec0..b7dff2f2ec 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190214} +{190215} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 30fff5f13b..48aba959cb 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.731(Build 190214)") +#define PANDORA_VERSION ("7.0NG.731(Build 190215)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index a34c9905ea..2b58063706 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.731(Build 190214))" + VALUE "ProductVersion", "(7.0NG.731(Build 190215))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 285b64c80f..12ecde5daf 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.731-190214 +Version: 7.0NG.731-190215 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 02c1b2ed71..0171643ae5 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.731-190214" +pandora_version="7.0NG.731-190215" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 380d9b5a0b..4de1f20d2f 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC190214'; +$build_version = 'PC190215'; $pandora_version = 'v7.0NG.731'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 2a190ff74e..5608de3f79 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -128,8 +128,8 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 0c678b8e79..e0834c0d3a 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.731 -%define release 190214 +%define release 190215 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index c2eabe1dbe..29a5c3e307 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.731 -%define release 190214 +%define release 190215 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 3ed28d9c0c..1b9483c5fe 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.731" -PI_BUILD="190214" +PI_BUILD="190215" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 312570299d..97816668a5 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.731 PS190214"; +my $version = "7.0NG.731 PS190215"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index c7f32c51d7..08854530dd 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.731 PS190214"; +my $version = "7.0NG.731 PS190215"; # save program name for logging my $progname = basename($0);