diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 0ee00a8f17..9e5ab2a275 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-190218 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..b292a5b27e 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-190218" 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..e115ed1464 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 => '190218'; # 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..09dda6c12c 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 190218 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..cfbcd4d9e2 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 190218 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..ea0776fa0b 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="190218" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 3b606d8ec0..6e9ed1ef35 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190214} +{190218} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 30fff5f13b..e13c1aaaef 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 190218)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index a34c9905ea..ebc2597545 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 190218))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 285b64c80f..3a35a79ccb 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-190218 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..4e85297bc6 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-190218" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index 4a9130a3db..1a505538ed 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -328,4 +328,3 @@ function mainModuleGroups() extensions_add_operation_menu_option(__('Module groups'), 'estado', 'module_groups/brick.png', 'v1r1', 'view'); extensions_add_main_function('mainModuleGroups'); - diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 004c947af4..f511304d8a 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -236,7 +236,7 @@ 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 dfa28988a8..071f6a8ae0 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; @@ -161,6 +162,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)); @@ -216,7 +218,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', [ @@ -326,6 +333,8 @@ if ($create_agent) { $agent_creation_error = __('Could not be created'); if ($exists_alias) { $agent_creation_error = __('Could not be created, because name already exists'); + } else if ($exists_ip) { + $agent_creation_error = __('Could not be created, because IP already exists'); } } } @@ -758,6 +767,7 @@ if ($update_agent) { $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)); @@ -860,8 +870,15 @@ if ($update_agent) { // 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)); + } else if ($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/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index a6b8657c16..700aab40ee 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -143,7 +143,7 @@ if ($update) { } } } else { - // Standard procedure + // Standard procedure. foreach ($agents_ as $agent_) { if ($modules_ == false) { $modules_ = []; @@ -315,7 +315,7 @@ if ($module_type != '') { $names = agents_get_modules( array_keys($agents), - 'DISTINCT(tagente_modulo.nombre)', + 'tagente_modulo.nombre', $filter, false ); @@ -1965,4 +1965,3 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' return true; } - diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index c274ce7b30..8af8bc881c 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -2721,7 +2721,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; diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index f8d53e722f..9e663e63cc 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -1,37 +1,242 @@ 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').'.'; + +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 + ); + } + + $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 + && $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'); + } +} - 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%'; @@ -44,42 +249,279 @@ $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); + $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 + ); + } + + $history_connect = @mysql_db_process_sql( + 'SELECT 1 FROM tconfig', + 'affected_rows', + $config['history_db_connection'], + 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']; + } + } + } + } else { + echo ui_print_error_message( + __('The tconfig table does not exist in the historical database') + ); + } + + 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(); @@ -91,7 +533,11 @@ $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][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'], @@ -101,7 +547,11 @@ $table_other->data[1][1] = html_print_input_text( 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][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'], @@ -122,46 +572,131 @@ $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] = html_print_checkbox_toogle_switch('realtimestats', 1, $config['realtimestats'], true); +$table_other->data[5][1] = html_print_checkbox_toogle_switch( + 'realtimestats', + 1, + $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] = html_print_checkbox_toogle_switch('agentaccess', 1, $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] = html_print_checkbox_toogle_switch('delete_notinit', 1, $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 ''.__('Database maintenance status').''; + html_print_table($table_status); echo '
'; echo '
'; -echo ''.__('Others').''; -html_print_input_hidden('update_config', 1); -html_print_table($table_other); + 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 '
'; ?> @@ -170,7 +705,6 @@ echo ''; function change_macro_fields() { var value = $("#text-max_macro_fields").val(); - console.log(value); if (value <= 0) { $("#text-max_macro_fields").val(1); } diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index f5f229ddd5..7f88982a14 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -1,17 +1,32 @@ false, 'text' => ''.html_print_image('images/gm_setup.png', true, ['title' => __('General')]).'', @@ -114,6 +129,7 @@ if (enterprise_installed()) { switch ($section) { case 'general': + default: $buttons['general']['active'] = true; $subpage = ' » '.__('General'); break; @@ -145,7 +161,7 @@ switch ($section) { break; } -// Header +// Header. ui_print_page_header(__('Configuration').$subpage, '', false, $help_header, true, $buttons); if (isset($config['error_config_update_config'])) { diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 8196d98873..2889c365c5 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -269,7 +269,13 @@ $table->data[37][0] = __('Audit log directory').ui_print_help_tip(__('Directory $table->data[37][1] = html_print_input_text('auditdir', io_safe_output($config['auditdir']), '', 30, 100, true); $table->data[38][0] = __('Set alias as name by default in agent creation'); -$table->data[38][1] = html_print_checkbox_toogle_switch('alias_as_name', 1, $config['alias_as_name'], true); +$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/ajax/reporting.ajax.php b/pandora_console/include/ajax/reporting.ajax.php index a5737ea71e..55ed7dd216 100755 --- a/pandora_console/include/ajax/reporting.ajax.php +++ b/pandora_console/include/ajax/reporting.ajax.php @@ -198,12 +198,7 @@ if ($get_metaconsole_hash_data) { $console_password = $auth_serialized['console_password']; } - $pwd = $auth_token; - // Create HASH login info - $user = str_rot13($config['id_user']); - $hashdata = $user.$pwd; - $hashdata = md5($hashdata); - $url_hash = "&loginhash=auto&loginhash_data=$hashdata&loginhash_user=$user"; + $url_hash = metaconsole_get_servers_url_hash($server); echo $url_hash; return; diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 380d9b5a0b..040ea33307 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 = 'PC190218'; $pandora_version = 'v7.0NG.731'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 545d84d640..8cc6290ca6 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -363,23 +363,18 @@ 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; + $returnAllGroup = true; + $returnAllColumns = false; + + if (isset($other['data'][1])) { + $returnAllGroup = ( $other['data'][1] == '1' ? true : false); } - 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]; + if (isset($other['data'][2])) { + $returnAllColumns = ( $other['data'][2] == '1' ? true : false); } - $groups = users_get_groups($user_in_db, 'IR'); + $groups = users_get_groups($user_in_db, 'IR', $returnAllGroup, $returnAllColumns); $data_groups = []; foreach ($groups as $id => $group) { @@ -389,6 +384,13 @@ function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db) ]; } + if (!isset($other['data'][0])) { + $separator = ';'; + // by default + } else { + $separator = $other['data'][0]; + } + $data['type'] = 'array'; $data['data'] = $data_groups; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index f0163384ba..1fbee04026 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -294,6 +294,10 @@ function config_update_config() 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': @@ -1657,6 +1661,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 */ @@ -2843,7 +2851,7 @@ function config_check() ); } - $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( diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index f3f3d2b0fa..4cc54c5857 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -166,92 +166,30 @@ function events_get_events_grouped( $groupby_extra = ''; } - switch ($config['dbtype']) { - case 'mysql': - db_process_sql('SET group_concat_max_len = 9999999'); - $event_lj = events_get_secondary_groups_left_join($table); - if ($total) { - $sql = "SELECT COUNT(*) FROM (SELECT * - FROM $table te $event_lj - WHERE 1=1 ".$sql_post.' - GROUP BY estado, evento, id_agente, id_agentmodule'.$groupby_extra.') AS t'; - } else { - $sql = "SELECT *, MAX(id_evento) AS id_evento, - GROUP_CONCAT(DISTINCT user_comment SEPARATOR '
') AS user_comment, - GROUP_CONCAT(DISTINCT id_evento SEPARATOR ',') AS similar_ids, - COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep, - MIN(utimestamp) AS timestamp_rep_min, - (SELECT owner_user FROM $table WHERE id_evento = MAX(te.id_evento)) owner_user, - (SELECT id_usuario FROM $table WHERE id_evento = MAX(te.id_evento)) id_usuario, - (SELECT id_agente FROM $table WHERE id_evento = MAX(te.id_evento)) id_agente, - (SELECT criticity FROM $table WHERE id_evento = MAX(te.id_evento)) AS criticity, - (SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp, - (SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = te.id_agentmodule) AS module_name - FROM $table te $event_lj - WHERE 1=1 ".$sql_post.' - GROUP BY estado, evento, id_agente, id_agentmodule'.$groupby_extra; - $sql .= ' '.events_get_sql_order($sort_field, $order, 2); - $sql .= ' LIMIT '.$offset.','.$pagination; - } - break; - - case 'postgresql': - if ($total) { - $sql = "SELECT COUNT(*) - FROM $table te - WHERE 1=1 ".$sql_post.' - GROUP BY estado, evento, id_agentmodule, id_evento, id_agente, id_usuario, id_grupo, estado, timestamp, utimestamp, event_type, id_alert_am, criticity, user_comment, tags, source, id_extra'.$groupby_extra; - } else { - $sql = "SELECT *, MAX(id_evento) AS id_evento, array_to_string(array_agg(DISTINCT user_comment), '
') AS user_comment, - array_to_string(array_agg(DISTINCT id_evento), ',') AS similar_ids, - COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep, - MIN(utimestamp) AS timestamp_rep_min, - (SELECT owner_user FROM $table WHERE id_evento = MAX(te.id_evento)) owner_user, - (SELECT id_usuario FROM $table WHERE id_evento = MAX(te.id_evento)) id_usuario, - (SELECT id_agente FROM $table WHERE id_evento = MAX(te.id_evento)) id_agente, - (SELECT criticity FROM $table WHERE id_evento = MAX(te.id_evento)) AS criticity, - (SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp - FROM $table te - WHERE 1=1 ".$sql_post.' - GROUP BY estado, evento, id_agentmodule, id_evento, - id_agente, id_usuario, id_grupo, estado, - timestamp, utimestamp, event_type, id_alert_am, - criticity, user_comment, tags, source, id_extra, - te.critical_instructions, - te.warning_instructions, - te.unknown_instructions, - te.owner_user, - te.ack_utimestamp, - te.custom_data '.$groupby_extra.' - ORDER BY timestamp_rep ASC LIMIT '.$pagination.' OFFSET '.$offset; - } - break; - - case 'oracle': - if ($total) { - $sql = "SELECT COUNT(*) - FROM $table te - WHERE 1=1 $sql_post - GROUP BY estado, to_char(evento), id_agentmodule".$groupby_extra.') b '; - } else { - $set = []; - $set['limit'] = $pagination; - $set['offset'] = $offset; - - $sql = "SELECT ta.*, tb.event_rep, tb.timestamp_rep, tb.timestamp_rep_min, tb.user_comments, tb.similar_ids - FROM $table ta - INNER JOIN (SELECT MAX(id_evento) AS id_evento, COUNT(id_evento) AS event_rep, - MAX(utimestamp) AS timestamp_rep, MIN(utimestamp) AS timestamp_rep_min, - TAB_TO_STRING(CAST(COLLECT(TO_CHAR(user_comment) ORDER BY id_evento ASC) AS t_varchar2_tab), '
') AS user_comments, - TAB_TO_STRING(CAST(COLLECT(CAST(id_evento AS VARCHAR2(4000)) ORDER BY id_evento ASC) AS t_varchar2_tab)) AS similar_ids - FROM $table te - WHERE 1=1 $sql_post - GROUP BY estado, to_char(evento), id_agentmodule$groupby_extra) tb - ON ta.id_evento = tb.id_evento - ORDER BY tb.timestamp_rep ASC"; - $sql = oracle_recode_query($sql, $set); - } - break; + db_process_sql('SET group_concat_max_len = 9999999'); + $event_lj = events_get_secondary_groups_left_join($table); + if ($total) { + $sql = "SELECT COUNT(*) FROM (SELECT id_evento + FROM $table te $event_lj + WHERE 1=1 ".$sql_post.' + GROUP BY estado, evento, id_agente, id_agentmodule'.$groupby_extra.') AS t'; + } else { + $sql = "SELECT *, MAX(id_evento) AS id_evento, + GROUP_CONCAT(DISTINCT user_comment SEPARATOR '
') AS user_comment, + GROUP_CONCAT(DISTINCT id_evento SEPARATOR ',') AS similar_ids, + COUNT(id_evento) AS event_rep, MAX(utimestamp) AS timestamp_rep, + MIN(utimestamp) AS timestamp_rep_min, + (SELECT owner_user FROM $table WHERE id_evento = MAX(te.id_evento)) owner_user, + (SELECT id_usuario FROM $table WHERE id_evento = MAX(te.id_evento)) id_usuario, + (SELECT id_agente FROM $table WHERE id_evento = MAX(te.id_evento)) id_agente, + (SELECT criticity FROM $table WHERE id_evento = MAX(te.id_evento)) AS criticity, + (SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp, + (SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = te.id_agentmodule) AS module_name + FROM $table te $event_lj + WHERE 1=1 ".$sql_post.' + GROUP BY estado, evento, id_agente, id_agentmodule'.$groupby_extra; + $sql .= ' '.events_get_sql_order($sort_field, $order, 2); + $sql .= ' LIMIT '.$offset.','.$pagination; } // Extract the events by filter (or not) from db @@ -260,16 +198,6 @@ function events_get_events_grouped( if ($total) { return reset($events[0]); } else { - // Override the column 'user_comment' with the column 'user_comments' when oracle - if (!empty($events) && $config['dbtype'] == 'oracle') { - array_walk( - $events, - function (&$value, $key) { - set_if_defined($value['user_comment'], $value['user_comments']); - } - ); - } - return $events; } } @@ -4871,6 +4799,10 @@ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep= */ function events_get_secondary_groups_left_join($table) { + if (users_is_admin()) { + return ''; + } + if ($table == 'tevento') { return 'LEFT JOIN tagent_secondary_group tasg ON te.id_agente = tasg.id_agent'; } diff --git a/pandora_console/include/graphs/functions_gd.php b/pandora_console/include/graphs/functions_gd.php index 17d8fedd95..262ed22bb3 100755 --- a/pandora_console/include/graphs/functions_gd.php +++ b/pandora_console/include/graphs/functions_gd.php @@ -144,7 +144,7 @@ function gd_histogram($width, $height, $mode, $data, $max_value, $font, $title, foreach ($data as $label => $value) { imagefilledrectangle($image, $leftmargin, $margin_up, (($value / $size_per) + $leftmargin), ($margin_up + $rectangle_height - 1), $colors[$c]); if ($mode != 2) { - ImageTTFText($image, $fontsize, 0, 0, ($margin_up + 8), $black, $font, $label); + imagettftext($image, $fontsize, 0, 0, ($margin_up + 8), $black, $font, $label); } $margin_up += ($rectangle_height + 1); @@ -164,9 +164,9 @@ function gd_histogram($width, $height, $mode, $data, $max_value, $font, $title, imageline($image, $risk_low, 0, $risk_low, $height, $grey); imageline($image, $risk_med, 0, $risk_med, $height, $grey); imageline($image, $risk_high, 0, $risk_high, $height, $grey); - ImageTTFText($image, $fontsize, 0, ($risk_low - 20), $height, $grey, $font, 'Low'); - ImageTTFText($image, $fontsize, 0, ($risk_med - 20), $height, $grey, $font, 'Med.'); - ImageTTFText($image, $fontsize, 0, ($risk_high - 25), $height, $grey, $font, 'High'); + imagettftext($image, $fontsize, 0, ($risk_low - 20), $height, $grey, $font, 'Low'); + imagettftext($image, $fontsize, 0, ($risk_med - 20), $height, $grey, $font, 'Med.'); + imagettftext($image, $fontsize, 0, ($risk_high - 25), $height, $grey, $font, 'High'); } imagepng($image); @@ -279,7 +279,7 @@ function gd_progress_bubble($width, $height, $progress, $title, $font, $out_of_l // Write the value $size = imagettfbbox($fontsize, 0, $font, $value_text); - ImageTTFText( + imagettftext( $image, $fontsize, 0, @@ -409,12 +409,12 @@ function drawRating($rating, $width, $height, $font, $out_of_lim_str, $mode, $fo if ($rating > 50) { if ($rating > 100) { - ImageTTFText($image, ($fontsize + 2), 0, ($width / 4), (($height / 2) + ($height / 5)), $back, $font, $out_of_lim_str); + imagettftext($image, ($fontsize + 2), 0, ($width / 4), (($height / 2) + ($height / 5)), $back, $font, $out_of_lim_str); } else { - ImageTTFText($image, $fontsize, 0, (($width / 2) - ($width / 10)), (($height / 2) + ($height / 5)), $back, $font, $value_text); + imagettftext($image, $fontsize, 0, (($width / 2) - ($width / 10)), (($height / 2) + ($height / 5)), $back, $font, $value_text); } } else { - ImageTTFText($image, $fontsize, 0, (($width / 2) - ($width / 10)), (($height / 2) + ($height / 5)), $text, $font, $value_text); + imagettftext($image, $fontsize, 0, (($width / 2) - ($width / 10)), (($height / 2) + ($height / 5)), $text, $font, $value_text); } break; diff --git a/pandora_console/install.php b/pandora_console/install.php index 7398f87bcb..7a0c15c766 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -1,16 +1,32 @@ @@ -113,7 +129,7 @@
0) { @@ -41,24 +40,67 @@ if ($id_group > 0) { $childrens_ids = array_keys($groups); } -// Group selection +if (!isset($date_from)) { + $date_from = ''; +} + +if (!isset($date_to)) { + $date_to = ''; +} + +if (($date_from === '') && ($date_to === '')) { + if ($event_view_hr > 0) { + $filter_resume['hours_max'] = $event_view_hr; + $unixtime = (get_system_time() - ($event_view_hr * SECONDS_1HOUR)); + $sql_post .= ' AND (utimestamp > '.$unixtime.')'; + } +} else { + // Some of this values will have the user's timezone, + // so we need to reverse it to the system's timezone + // before using it into the db. + $fixed_offset = get_fixed_offset(); + + if (!empty($date_from)) { + if (empty($time_from)) { + $time_from = '00:00:00'; + } + + $utimestamp_from = (strtotime($date_from.' '.$time_from) - $fixed_offset); + $filter_resume['time_from'] = date(DATE_FORMAT.' '.TIME_FORMAT, $utimestamp_from); + $sql_post .= ' AND (utimestamp >= '.$utimestamp_from.')'; + } + + if (!empty($date_to)) { + if (empty($time_to)) { + $time_to = '23:59:59'; + } + + $utimestamp_to = (strtotime($date_to.' '.$time_to) - $fixed_offset); + $filter_resume['time_to'] = date(DATE_FORMAT.' '.TIME_FORMAT, $utimestamp_to); + $sql_post .= ' AND (utimestamp <= '.$utimestamp_to.')'; + } +} + +// Group selection. if ($id_group > 0 && in_array($id_group, array_keys($groups))) { if ($propagate) { $childrens_str = implode(',', $childrens_ids); - $sql_post = " AND (id_grupo IN ($childrens_str) OR id_group IN ($childrens_str))"; + $sql_post .= " AND (id_grupo IN ($childrens_str) OR id_group IN ($childrens_str))"; } else { - // If a group is selected and it's in the groups allowed - $sql_post = " AND (id_grupo = $id_group OR id_group = $id_group)"; + // If a group is selected and it's in the groups allowed. + $sql_post .= " AND (id_grupo = $id_group OR id_group = $id_group)"; } } else { - $sql_post = sprintf( - ' AND (id_grupo IN (%s) OR id_group IN (%s)) ', - implode(',', array_keys($groups)), - implode(',', array_keys($groups)) - ); + if (!users_is_admin() && !users_can_manage_group_all('ER')) { + $sql_post .= sprintf( + ' AND (id_grupo IN (%s) OR id_group IN (%s)) ', + implode(',', array_keys($groups)), + implode(',', array_keys($groups)) + ); + } } -// Skip system messages if user is not PM +// Skip system messages if user is not PM. if (!check_acl($id_user, 0, 'PM')) { $sql_post .= ' AND id_grupo != 0'; } @@ -164,7 +206,7 @@ if ($source != '') { $sql_post .= " AND source LIKE '%$source%'"; } -// In metaconsole mode the agent search is performed by name +// In metaconsole mode the agent search is performed by name. if ($meta) { $text_agent = get_parameter('text_agent', ''); $id_agent = get_parameter('id_agent', 0); @@ -179,7 +221,7 @@ if ($meta) { break; case -1: - // Agent doesnt exist. No results will returned + // Agent doesnt exist. No results will returned. $sql_post .= ' AND 1 = 0'; break; @@ -192,9 +234,7 @@ if ($meta) { -if ($meta) { - // There is another filter. -} else { +if (!$meta) { if (!empty($text_module)) { $filter_resume['module'] = $text_module; $sql_post .= " AND id_agentmodule IN ( @@ -210,48 +250,7 @@ if ($id_user_ack != '0') { $sql_post .= " AND id_usuario = '".$id_user_ack."'"; } -if (!isset($date_from)) { - $date_from = ''; -} - -if (!isset($date_to)) { - $date_to = ''; -} - -if (($date_from == '') && ($date_to == '')) { - if ($event_view_hr > 0) { - $filter_resume['hours_max'] = $event_view_hr; - $unixtime = (get_system_time() - ($event_view_hr * SECONDS_1HOUR)); - $sql_post .= ' AND (utimestamp > '.$unixtime.')'; - } -} else { - // Some of this values will have the user's timezone, - // so we need to reverse it to the system's timezone - // before using it into the db - $fixed_offset = get_fixed_offset(); - - if (!empty($date_from)) { - if (empty($time_from)) { - $time_from = '00:00:00'; - } - - $utimestamp_from = (strtotime($date_from.' '.$time_from) - $fixed_offset); - $filter_resume['time_from'] = date(DATE_FORMAT.' '.TIME_FORMAT, $utimestamp_from); - $sql_post .= ' AND (utimestamp >= '.$utimestamp_from.')'; - } - - if (!empty($date_to)) { - if (empty($time_to)) { - $time_to = '23:59:59'; - } - - $utimestamp_to = (strtotime($date_to.' '.$time_to) - $fixed_offset); - $filter_resume['time_to'] = date(DATE_FORMAT.' '.TIME_FORMAT, $utimestamp_to); - $sql_post .= ' AND (utimestamp <= '.$utimestamp_to.')'; - } -} - -// Search by tag +// Search by tag. if (!empty($tag_with)) { if (!users_is_admin()) { $user_tags = array_flip(tags_get_tags_for_module_search()); @@ -305,7 +304,7 @@ if (!empty($tag_without)) { $sql_post .= ' ) '; } -// Filter/Only alerts +// Filter/Only alerts. if (isset($filter_only_alert)) { if ($filter_only_alert == 0) { $filter_resume['alerts'] = $filter_only_alert; @@ -316,7 +315,7 @@ if (isset($filter_only_alert)) { } } -// Tags ACLS +// Tags ACLS. if ($id_group > 0 && in_array($id_group, array_keys($groups))) { $group_array = (array) $id_group; } else { @@ -335,7 +334,7 @@ if (check_acl($id_user, 0, 'ER')) { [], true ); - // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)" + // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)". } else if (check_acl($id_user, 0, 'EW')) { $tags_acls_condition = tags_get_acl_tags( $id_user, @@ -348,7 +347,7 @@ if (check_acl($id_user, 0, 'ER')) { [], true ); - // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)" + // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)". } else if (check_acl($id_user, 0, 'EM')) { $tags_acls_condition = tags_get_acl_tags( $id_user, @@ -361,14 +360,14 @@ if (check_acl($id_user, 0, 'ER')) { [], true ); - // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)" + // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)". } if (($tags_acls_condition != ERR_WRONG_PARAMETERS) && ($tags_acls_condition != ERR_ACL) && ($tags_acls_condition != -110000)) { $sql_post .= $tags_acls_condition; } -// Metaconsole fitlers +// Metaconsole fitlers. if ($meta) { if ($server_id) { $filter_resume['server'] = $server_id; diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 2d967815bd..1dae4de28f 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.731 -%define release 190214 +%define release 190218 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index bc06faf96d..b77f52a1cc 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.731 -%define release 190214 +%define release 190218 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index d607a98e44..fcd9e02811 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.731-190214 +Version: 7.0NG.731-190218 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index 37d7388974..15426ec341 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/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-190218" package_cpan=0 package_pandora=1 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index db418c8607..ffe32ec95c 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -45,7 +45,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.731"; -my $pandora_build = "190214"; +my $pandora_build = "190218"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 2a00199ac6..1e4e84845b 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -32,7 +32,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.731"; -my $pandora_build = "190214"; +my $pandora_build = "190218"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 0c678b8e79..8e88f8c8e7 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 190218 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index c2eabe1dbe..4d51b35563 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 190218 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 3ed28d9c0c..adde2139a0 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="190218" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 312570299d..100e38cea1 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 PS190218"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index c7f32c51d7..a19ae1e3ff 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 PS190218"; # save program name for logging my $progname = basename($0);