diff --git a/extras/docker/build_and_push.sh b/extras/docker/build_and_push.sh index 91e6fa15e5..c58a73bf8e 100755 --- a/extras/docker/build_and_push.sh +++ b/extras/docker/build_and_push.sh @@ -1,3 +1,4 @@ #!/bin/bash docker build --rm=true --pull --no-cache --build-arg BRANCH="develop" --build-arg DB_PASS="pandora" -t pandorafms/pandorafms:7 . && \ +[ "$QA_ENV" == "" ] && \ docker push pandorafms/pandorafms:7 diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 60178d6c50..67cd410a32 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.738-190905 +Version: 7.0NG.738-190923 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 e02ac99a67..385336710c 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.738-190905" +pandora_version="7.0NG.738-190923" 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 1e5871de4a..eafeb00e78 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.738'; -use constant AGENT_BUILD => '190905'; +use constant AGENT_BUILD => '190923'; # 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 a22caf27cc..f189eea490 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.738 -%define release 190905 +%define release 190923 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 ee53894623..561e65e18a 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.738 -%define release 190905 +%define release 190923 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 b8234a70cd..1c0ee8ad1d 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.738" -PI_BUILD="190905" +PI_BUILD="190923" OS_NAME=`uname -s` FORCE=0 @@ -162,7 +162,15 @@ uninstall () { rm -Rf $PANDORA_BASE$PANDORA_EXEC_BIN 2> /dev/null rm -Rf $PANDORA_BASE$PANDORA_REVENT_BIN 2> /dev/null rm -f $DESTDIR/etc/logrotate.d/pandora_agent - + + # Remove systemd service if exists + if [ $(systemctl --v | grep systemd | wc -l) != 0 ] + then + PANDORA_AGENT_SERVICE="/etc/systemd/system/pandora_agent_daemon.service" + rm -f $PANDORA_AGENT_SERVICE + systemctl reset-failed + fi + #Test if exist Pandora Server in this machine if [ -d $PANDORA_BASE$PANDORA_TEMP/data_in ] then @@ -465,6 +473,22 @@ install () { else RCDIRS="/etc/rc2.d /etc/rc3.d" fi + + # Create systemd service + if [ $(systemctl --v | grep systemd | wc -l) != 0 ] + then + echo "Creating systemd service for pandora_agent_daemon" + + PANDORA_AGENT_SERVICE="/etc/systemd/system/pandora_agent_daemon.service" + EXEC_START='ExecStart='$PANDORA_BASE$PANDORA_BIN' '$PANDORA_BASE$PANDORA_CFG + + rm -f $PANDORA_AGENT_SERVICE + cp pandora_agent_daemon.service $PANDORA_AGENT_SERVICE + + sed -i "s|^ExecStart=.*$|$EXEC_START|g" $PANDORA_AGENT_SERVICE + + systemctl daemon-reload + fi fi [ "$RCDIRS" ] && for RCDIR in $RCDIRS do diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index ebac265083..b8f1bcf5e7 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190905} +{190923} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 5b5fb5fc5e..9b445b24aa 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.738(Build 190905)") +#define PANDORA_VERSION ("7.0NG.738(Build 190923)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 2d39c90e46..b185cf6fec 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.738(Build 190905))" + VALUE "ProductVersion", "(7.0NG.738(Build 190923))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index d406b35c6e..d883d99eac 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.738-190905 +Version: 7.0NG.738-190923 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 7097063187..6ed2c0da18 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.738-190905" +pandora_version="7.0NG.738-190923" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/files_repo/files_repo_form.php b/pandora_console/extensions/files_repo/files_repo_form.php index 2035cfbd1a..b8e6a084b9 100644 --- a/pandora_console/extensions/files_repo/files_repo_form.php +++ b/pandora_console/extensions/files_repo/files_repo_form.php @@ -44,24 +44,16 @@ $groups = groups_get_all(); // Add the All group to the beginning to be always the first // Use this instead array_unshift to keep the array keys $groups = ([0 => __('All')] + $groups); -$html = ''; -$style = 'style="padding: 2px 10px; display: inline-block;"'; +$groups_selected = []; foreach ($groups as $id => $name) { - $checked = in_array($id, $file['groups']); - $all_checked = false; - if ($id === 0) { - $checkbox = html_print_checkbox_extended('groups[]', $id, $checked, false, '', 'class="chkb_all"', true); - $all_checked = $checked; - } else { - $checkbox = html_print_checkbox_extended('groups[]', $id, $checked, $all_checked, '', 'class="chkb_group"', true); + if (in_array($id, $file['groups'])) { + $groups_selected[] = $id; } - - $html .= "
$name $checkbox
"; } $row = []; $row[0] = __('Groups'); -$row[1] = $html; +$row[1] = html_print_select($groups, 'groups[]', $groups_selected, '', '', '', true, true, '', '', ''); $table->data[] = $row; $table->colspan[][1] = 3; diff --git a/pandora_console/extensions/files_repo/functions_files_repo.php b/pandora_console/extensions/files_repo/functions_files_repo.php index 3d9bdccd38..32ce4c216c 100644 --- a/pandora_console/extensions/files_repo/functions_files_repo.php +++ b/pandora_console/extensions/files_repo/functions_files_repo.php @@ -193,7 +193,7 @@ function files_repo_add_file($file_input_name='upfile', $description='', $groups global $config; $attachment_path = io_safe_output($config['attachment_store']); - $files_repo_path = $attachment_path.'/'.'files_repo'; + $files_repo_path = $attachment_path.'/files_repo'; $result = []; $result['status'] = false; diff --git a/pandora_console/extras/mr/32.sql b/pandora_console/extras/mr/32.sql new file mode 100644 index 0000000000..18e31dfb38 --- /dev/null +++ b/pandora_console/extras/mr/32.sql @@ -0,0 +1,23 @@ +START TRANSACTION; + +ALTER TABLE `tdatabase` MODIFY `last_error` text; +ALTER TABLE `tdatabase` MODIFY `host` VARCHAR(255) DEFAULT ''; +ALTER TABLE `tdatabase` ADD COLUMN `label` VARCHAR(255) DEFAULT ''; +ALTER TABLE `tdatabase` MODIFY `os_user` VARCHAR(255) DEFAULT ''; +ALTER TABLE `tdatabase` MODIFY `db_port` INT UNSIGNED NOT NULL DEFAULT 3306; +ALTER TABLE `tdatabase` MODIFY `os_port` INT UNSIGNED NOT NULL DEFAULT 22; +ALTER TABLE `tdatabase` ADD COLUMN `ssh_key` TEXT; +ALTER TABLE `tdatabase` ADD COLUMN `ssh_pubkey` TEXT; + +UPDATE `tdatabase` set `label`=`host`; + +UPDATE `tlayout_data` SET `height` = 70 , `width` = 70 WHERE `height` = 0 && `width` = 0 && image NOT LIKE '%dot%' && ((`type` IN (0,5)) || +(`type` = 10 && `image` IS NOT NULL && `image` != '' && `image` != 'none') || +(`type` = 11 && `image` IS NOT NULL && `image` != '' && `image` != 'none' && `show_statistics` = 0)); + + +ALTER TABLE `treport_content` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0'; +ALTER TABLE `treport_content_template` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0'; + + +COMMIT; diff --git a/pandora_console/extras/pandora_diag.php b/pandora_console/extras/pandora_diag.php index 9258a3be42..eb9a199456 100644 --- a/pandora_console/extras/pandora_diag.php +++ b/pandora_console/extras/pandora_diag.php @@ -726,7 +726,7 @@ render_info_data( echo "".__(' Pandora FMS Licence Information').''; render_row(html_print_textarea('keys[customer_key]', 10, 255, $settings->customer_key, 'style="height:40px; width:450px;"', true), 'Customer key'); - render_row($license['expiry_date'], 'Expires'); + render_row($license['expiry_date'], $license['expiry_caption']); render_row($license['limit'].' agents', 'Platform Limit'); render_row($license['count'].' agents', 'Current Platform Count'); render_row($license['count_enabled'].' agents', 'Current Platform Count (enabled: items)'); diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 704ab61d74..a449004ce8 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -219,14 +219,17 @@ CREATE TABLE IF NOT EXISTS `tdashboard` ( -- Table `tdatabase` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tdatabase` ( - `id` int(10) unsigned NOT NULL auto_increment, - `host` varchar(100) default '', - `os_port` int(4) unsigned default '22', - `os_user` varchar(100) default '', - `db_port` int(4) unsigned default '3306', + `id` INT(10) unsigned NOT NULL auto_increment, + `host` VARCHAR(255) default '', + `label` VARCHAR(255) default '', + `os_port` INT UNSIGNED NOT NULL DEFAULT 22, + `os_user` VARCHAR(255) default '', + `db_port` INT UNSIGNED NOT NULL DEFAULT 3306, `status` tinyint(1) unsigned default '0', `action` tinyint(1) unsigned default '0', - `last_error` varchar(255) default '', + `ssh_key` TEXT, + `ssh_pubkey` TEXT, + `last_error` TEXT, PRIMARY KEY (`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; @@ -798,6 +801,7 @@ ALTER TABLE `treport_content_template` ADD COLUMN `agent_min_value` TINYINT(1) D ALTER TABLE `treport_content_template` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content_template` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '1'; ALTER TABLE `treport_content_template` ADD COLUMN `failover_type` tinyint(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0'; -- ----------------------------------------------------- -- Table `treport_content_sla_com_temp` (treport_content_sla_combined_template) @@ -1454,6 +1458,7 @@ ALTER TABLE `treport_content` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '0'; ALTER TABLE `treport_content` ADD COLUMN `failover_type` tinyint(1) DEFAULT '0'; ALTER table `treport_content` MODIFY COLUMN `name` varchar(300) NULL; +ALTER TABLE `treport_content` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0'; -- --------------------------------------------------------------------- -- Table `tmodule_relationship` diff --git a/pandora_console/general/firts_task/HA_cluster_builder.php b/pandora_console/general/firts_task/HA_cluster_builder.php index fa85e28381..6d82d94ad0 100644 --- a/pandora_console/general/firts_task/HA_cluster_builder.php +++ b/pandora_console/general/firts_task/HA_cluster_builder.php @@ -1,15 +1,25 @@ - true, 'message' => __('There are no HA clusters defined yet.') ]); ?> @@ -44,8 +52,9 @@ ui_print_info_message(['no_close' => true, 'message' => __('There are no HA clus

"; + echo "
"; ?> true, 'message' => __('There are no HA clus ?> - diff --git a/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php b/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php index b40cf80855..47a5cc5a35 100644 --- a/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php +++ b/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php @@ -353,7 +353,7 @@ html_print_table($table); echo "
"; echo ''; html_print_submit_button(__('WMI Explore'), 'wmi_explore', false, ['class' => 'sub next']); -echo '
'; +echo '
'; if ($wmiexplore && $fail) { ui_print_error_message(__('Unable to do WMI explorer')); @@ -364,7 +364,7 @@ unset($table); echo ''; if ($wmiexplore && !$fail) { - echo ''; + echo '
'; echo "
"; echo ''; @@ -379,7 +379,7 @@ if ($wmiexplore && !$fail) { // Namespace html_print_input_hidden('server_to_exec', $server_to_exec); - $table->width = '98%'; + $table->width = '100%'; // Mode selector $modes = []; @@ -404,7 +404,7 @@ if ($wmiexplore && !$fail) { $table->colspan[1][0] = 2; $table->data[1][2] = ''.__('Modules').''; - $table->cellstyle[1][2] = 'vertical-align: middle;'; + $table->cellstyle[1][2] = 'text-align: center;'; // Components list $table->data[2][0] = '
'; @@ -495,7 +495,7 @@ if ($wmiexplore && !$fail) { 'width: 300px;' ); $table->data[2][0] .= '
'; - $table->cellstyle[2][0] = 'vertical-align: top; text-align: center;'; + $table->cellstyle[2][0] = 'vertical-align: bottom; text-align: center;'; // Components arrow diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 8881c14501..e97fa7cf39 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -1358,7 +1358,11 @@ if ($update_module || $create_module) { $parent_module_id = (int) get_parameter('parent_module_id'); $ip_target = (string) get_parameter('ip_target'); - if ($ip_target == '') { + // No autofill if the module is a webserver module. + if ($ip_target == '' + && $id_module_type < MODULE_WEBSERVER_CHECK_LATENCY + && $id_module_type > MODULE_WEBSERVER_RETRIEVE_STRING_DATA + ) { $ip_target = 'auto'; } @@ -1381,11 +1385,7 @@ if ($update_module || $create_module) { $ff_type = (int) get_parameter('ff_type'); $each_ff = (int) get_parameter('each_ff'); $ff_timeout = (int) get_parameter('ff_timeout'); - $unit = (string) get_parameter('unit_select'); - if ($unit == 'none') { - $unit = (string) get_parameter('unit_text'); - } - + $unit = (string) get_parameter('unit'); $id_tag = (array) get_parameter('id_tag_selected'); $serialize_ops = (string) get_parameter('serialize_ops'); $critical_instructions = (string) get_parameter('critical_instructions'); @@ -2107,8 +2107,7 @@ if ($delete_module) { } } -// MODULE DUPLICATION -// ==================. +// MODULE DUPLICATION. if (!empty($duplicate_module)) { // DUPLICATE agent module ! $id_duplicate_module = $duplicate_module; @@ -2154,8 +2153,46 @@ if (!empty($duplicate_module)) { } } -// UPDATE GIS -// ==========. +// MODULE ENABLE/DISABLE. +if ($enable_module) { + $result = modules_change_disabled($enable_module, 0); + $modulo_nombre = db_get_row_sql('SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = '.$enable_module.''); + $modulo_nombre = $modulo_nombre['nombre']; + + if ($result === NOERR) { + enterprise_hook('config_agents_enable_module_conf', [$id_agente, $enable_module]); + db_pandora_audit('Module management', 'Enable #'.$enable_module.' | '.$modulo_nombre.' | '.$agent['alias']); + } else { + db_pandora_audit('Module management', 'Fail to enable #'.$enable_module.' | '.$modulo_nombre.' | '.$agent['alias']); + } + + ui_print_result_message( + $result, + __('Successfully enabled'), + __('Could not be enabled') + ); +} + +if ($disable_module) { + $result = modules_change_disabled($disable_module, 1); + $modulo_nombre = db_get_row_sql('SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = '.$disable_module.''); + $modulo_nombre = $modulo_nombre['nombre']; + + if ($result === NOERR) { + enterprise_hook('config_agents_disable_module_conf', [$id_agente, $disable_module]); + db_pandora_audit('Module management', 'Disable #'.$disable_module.' | '.$modulo_nombre.' | '.$agent['alias']); + } else { + db_pandora_audit('Module management', 'Fail to disable #'.$disable_module.' | '.$modulo_nombre.' | '.$agent['alias']); + } + + ui_print_result_message( + $result, + __('Successfully disabled'), + __('Could not be disabled') + ); +} + +// UPDATE GIS. $updateGIS = get_parameter('update_gis', 0); if ($updateGIS) { $updateGisData = get_parameter('update_gis_data'); @@ -2243,8 +2280,11 @@ switch ($tab) { break; case 'alert': - // Because $id_agente is set, it will show only agent alerts. - // This var is for not display create button on alert list. + /* + * Because $id_agente is set, it will show only agent alerts + * This var is for not display create button on alert list + */ + $dont_display_alert_create_bttn = true; include 'godmode/alerts/alert_list.php'; break; diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index f52707cb2a..013aa83498 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -1930,11 +1930,7 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' case 'unit_select': if ($value != -1) { - if ($value == 'none') { - $values['unit'] = (string) get_parameter('unit_text'); - } else { - $values['unit'] = $value; - } + $values['unit'] = (string) get_parameter('unit'); } break; diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 798d03707d..fa015300d6 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -153,6 +153,7 @@ $checks_in_ok_status = true; $unknown_checks = true; $agent_max_value = true; $agent_min_value = true; +$uncompressed_module = true; switch ($action) { case 'new': @@ -427,6 +428,7 @@ switch ($action) { ); $idAgentModule = $item['id_agent_module']; $period = $item['period']; + $uncompressed_module = $item['uncompressed_module']; break; case 'historical_data': @@ -810,7 +812,6 @@ switch ($action) { break; } - $urlForm = $config['homeurl'].'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=item_editor&action='.$actionParameter.'&id_report='.$idReport; echo ''; @@ -1565,10 +1566,8 @@ $class = 'databox filters'; $all_modules = ''; } else { $all_modules = db_get_all_rows_sql( - 'SELECT DISTINCT nombre, id_agente_modulo - FROM tagente_modulo - WHERE id_agente - IN ('.implode(',', array_values($id_agents)).')' + 'SELECT DISTINCT nombre FROM + tagente_modulo WHERE id_agente IN ('.implode(',', array_values($id_agents)).')' ); } @@ -2794,6 +2793,23 @@ $class = 'databox filters'; ?> + + + + + + + + + + @@ -3529,6 +3545,9 @@ $(document).ready (function () { $("#id_agents").change(agent_changed_by_multiple_agents); + // Load selected modules by default + $("#id_agents2").trigger('click'); + $("#combo_group").change ( function () { jQuery.post ("ajax.php", @@ -4523,6 +4542,7 @@ function chooseType() { $('#row_select_fields').hide(); $("#row_select_fields2").hide(); $("#row_select_fields3").hide(); + $("#row_uncompressed_module").hide(); // SLA list default state. $("#sla_list").hide(); @@ -4731,6 +4751,7 @@ function chooseType() { $("#row_module").show(); $("#row_period").show(); $("#row_historical_db_check").hide(); + $("#row_uncompressed_module").show(); break; case 'historical_data': diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index aa89496ef7..fa2e7440fa 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1908,6 +1908,11 @@ switch ($action) { $values['id_agent'] = get_parameter('group'); } + if ($values['type'] == 'sumatory') { + $values['uncompressed_module'] = get_parameter('uncompressed_module', 0); + } + + $values['header_definition'] = get_parameter('header'); $values['column_separator'] = get_parameter('field'); $values['line_separator'] = get_parameter('line'); @@ -2464,6 +2469,10 @@ switch ($action) { $values['id_agent'] = get_parameter('group'); } + if ($values['type'] == 'sumatory') { + $values['uncompressed_module'] = get_parameter('uncompressed_module', 0); + } + $values['header_definition'] = get_parameter('header'); $values['column_separator'] = get_parameter('field'); $values['line_separator'] = get_parameter('line'); diff --git a/pandora_console/godmode/setup/license.php b/pandora_console/godmode/setup/license.php index 06d7d2e7e3..c459cdb39f 100644 --- a/pandora_console/godmode/setup/license.php +++ b/pandora_console/godmode/setup/license.php @@ -107,7 +107,7 @@ $table->data = []; $table->data[0][0] = ''.__('Customer key').''; $table->data[0][1] = html_print_textarea('keys[customer_key]', 10, 255, $settings->customer_key, 'style="height:50px; width:450px;"', true); -$table->data[1][0] = ''.__('Expires').''; +$table->data[1][0] = ''.__($license['expiry_caption']).''; $table->data[1][1] = html_print_input_text('expires', $license['expiry_date'], '', 10, 255, true, true); $table->data[2][0] = ''.__('Platform Limit').''; diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index ab1d1ef269..1385a9f193 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -58,6 +58,16 @@ global $config; check_login(); +if (is_ajax()) { + enterprise_include_once('include/functions_cron.php'); + + $test_address = get_parameter('test_address', ''); + + $res = enterprise_hook('send_email_attachment', [$test_address, __('This is an email test sent from Pandora FMS. If you can read this, your configuration works.'), __('Testing Pandora FMS email'), null]); + + echo $res; +} + $table = new StdClass(); $table->class = 'databox filters'; $table->id = 'setup_general'; @@ -68,6 +78,12 @@ $table->size[0] = '30%'; $table->style[0] = 'font-weight:bold'; $table->size[1] = '70%'; +$table_mail_conf = new stdClass(); +$table_mail_conf->width = '100%'; +$table_mail_conf->class = 'databox filters'; +$table_mail_conf->data = []; +$table_mail_conf->style[0] = 'font-weight: bold'; + // Current config["language"] could be set by user, not taken from global setup ! $current_system_lang = db_get_sql( 'SELECT `value` FROM tconfig WHERE `token` = "language"' @@ -330,6 +346,49 @@ echo ''.__('General options').''; html_print_input_hidden('update_config', 1); html_print_table($table); +$encryption = [ + 'ssl' => 'SSL/TLS', + 'sslv2' => 'SSLv2', + 'sslv3' => 'SSLv3', + 'tls' => 'STARTTLS', +]; + +echo ''; + +echo '
'; +echo ''.__('Mail configuration').''; + +$table_mail_conf->data[0][0] = __('From address'); +$table_mail_conf->data[0][1] = html_print_input_text('email_from_dir', $config['email_from_dir'], '', 30, 100, true); + +$table_mail_conf->data[1][0] = __('From name'); +$table_mail_conf->data[1][2] = html_print_input_text('email_from_name', $config['email_from_name'], '', 30, 100, true); + +$table_mail_conf->data[2][0] = __('SMTP Server'); +$table_mail_conf->data[2][1] = html_print_input_text('email_smtpServer', $config['email_smtpServer'], '', 30, 100, true); + +$table_mail_conf->data[3][0] = __('SMTP Port'); +$table_mail_conf->data[3][1] = html_print_input_text('email_smtpPort', $config['email_smtpPort'], '', 30, 100, true); + +$table_mail_conf->data[4][0] = __('Encryption'); +$table_mail_conf->data[4][1] = html_print_select($encryption, 'email_encryption', $config['email_encryption'], '', __('none'), 0, true); + +$table_mail_conf->data[5][0] = __('Email user'); +$table_mail_conf->data[5][1] = html_print_input_text('email_username', $config['email_username'], '', 30, 100, true); + +$table_mail_conf->data[6][0] = __('Email password'); +$table_mail_conf->data[6][1] = html_print_input_password('email_password', io_output_password($config['email_password']), '', 30, 100, true); + +$uniqid = uniqid(); + +$table_mail_conf->data[7][0] = html_print_button(__('Email test'), 'email_test_dialog', false, "show_email_test('$uniqid');", 'class="sub next"', true).ui_print_help_tip(__('Check the current saved email configuration by sending a test email to a desired account.'), true); + +print_email_test_modal_window($uniqid); + +html_print_input_hidden('update_config', 1); +html_print_table($table_mail_conf); + + echo '
'; echo '
'; @@ -337,6 +396,25 @@ html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"' echo '
'; echo ''; +// Print the modal window for the summary of each alerts group +function print_email_test_modal_window($id) +{ + // Email config table. + $table_mail_test = new stdClass(); + $table_mail_test->width = '100%'; + $table_mail_test->class = 'databox filters'; + $table_mail_test->data = []; + $table_mail_test->style[0] = 'font-weight: bold'; + $table_mail_test->colspan[1][0] = 2; + + $table_mail_test->data[0][0] = __('Address').ui_print_help_tip(__('Email address to which the test email will be sent. Please check your inbox after email is sent.'), true); + $table_mail_test->data[0][1] = html_print_input_text('email_test_address', '', '', 40, 100, true); + + $table_mail_test->data[1][0] = html_print_button(__('Send'), 'email_test', false, '', 'class="sub next"', true).'  '; + + echo ''; +} + ?> diff --git a/pandora_console/images/console/background/fondo-keep-alive.jpg b/pandora_console/images/console/background/fondo-keep-alive.jpg new file mode 100644 index 0000000000..fbb5b90a5c Binary files /dev/null and b/pandora_console/images/console/background/fondo-keep-alive.jpg differ diff --git a/pandora_console/images/console/icons/status.png b/pandora_console/images/console/icons/status.png new file mode 100644 index 0000000000..6fba320b6f Binary files /dev/null and b/pandora_console/images/console/icons/status.png differ diff --git a/pandora_console/images/console/icons/status_bad.png b/pandora_console/images/console/icons/status_bad.png new file mode 100644 index 0000000000..a6935a5a19 Binary files /dev/null and b/pandora_console/images/console/icons/status_bad.png differ diff --git a/pandora_console/images/console/icons/status_ok.png b/pandora_console/images/console/icons/status_ok.png new file mode 100644 index 0000000000..a23d4dad2e Binary files /dev/null and b/pandora_console/images/console/icons/status_ok.png differ diff --git a/pandora_console/images/console/icons/status_warning.png b/pandora_console/images/console/icons/status_warning.png new file mode 100644 index 0000000000..387de1c755 Binary files /dev/null and b/pandora_console/images/console/icons/status_warning.png differ diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 07cd4f492e..87a6f2dca0 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -727,7 +727,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.LICENSE.LIMITED', 'title' => __('Limited mode.'), 'message' => io_safe_output($config['limited_mode']), - 'url' => 'index.php?sec=gsetup&sec2=godmode/setup/license', + 'url' => ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/license'), ] ); } else { @@ -745,7 +745,7 @@ class ConsoleSupervisor 'Your license will expire in %d days. Please, contact our sales department.', $days_to_expiry ), - 'url' => 'index.php?sec=gsetup&sec2=godmode/setup/license', + 'url' => ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/license'), ] ); } else if ($days_to_expiry < 0) { @@ -755,7 +755,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.LICENSE.EXPIRATION', 'title' => __('Expired license'), 'message' => __('Your license has expired. Please, contact our sales department.'), - 'url' => 'index.php?sec=gsetup&sec2=godmode/setup/license', + 'url' => ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/license'), ] ); return false; @@ -832,7 +832,7 @@ class ConsoleSupervisor 'Directory %s is not writable. Please, configure corresponding permissions.', $config['attachment_store'] ), - 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'), ] ); return; @@ -854,7 +854,7 @@ class ConsoleSupervisor 'There are more than %d files in attachment, consider cleaning up attachment directory manually.', $config['num_files_attachment'] ), - 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=perf'), ] ); } else { @@ -886,7 +886,7 @@ class ConsoleSupervisor 'Remote configuration directory %s is not readable. Please, adjust configuration.', $config['remote_config'] ), - 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'), ] ); return; @@ -905,7 +905,7 @@ class ConsoleSupervisor 'Remote configuration directory %s is not writable. Please, adjust configuration.', $config['remote_config'].'/conf' ), - 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'), ] ); } else { @@ -923,7 +923,7 @@ class ConsoleSupervisor 'Collections directory %s is not writable. Please, adjust configuration.', $config['remote_config'].'/collections' ), - 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'), ] ); } else { @@ -941,7 +941,7 @@ class ConsoleSupervisor 'MD5 directory %s is not writable. Please, adjust configuration.', $config['remote_config'].'/md5' ), - 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'), ] ); } else { @@ -972,7 +972,7 @@ class ConsoleSupervisor $MAX_FILES_DATA_IN, $config['remote_config'] ), - 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=perf'), ] ); } else { @@ -995,7 +995,7 @@ class ConsoleSupervisor $MAX_BADXML_FILES_DATA_IN, $config['remote_config'] ), - 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=perf'), ] ); } else { @@ -1081,7 +1081,7 @@ class ConsoleSupervisor $modules_queued, $queue['queued_modules'] ), - 'url' => 'index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60', + 'url' => ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60'), ] ); } else { @@ -1191,7 +1191,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.SERVER.STATUS.'.$server['id_server'], 'title' => $msg, 'message' => $description, - 'url' => 'index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60', + 'url' => ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60'), ] ); } @@ -1499,7 +1499,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.HISTORYDB', 'title' => __('Historical database not available'), 'message' => __('Historical database is enabled, though not accessible with the current configuration.'), - 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db', + 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db'), ] ); } else { @@ -1546,7 +1546,7 @@ class ConsoleSupervisor 'Your database hasn\'t been through maintenance for 48hrs. Please, check documentation on how to perform this maintenance process on %s and enable it as soon as possible.', io_safe_output(get_product_name()) ), - 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=perf'), ] ); } else { @@ -1606,7 +1606,7 @@ class ConsoleSupervisor 'Historical database maintenance problem.' ), 'message' => __('Your historical database hasn\'t been through maintenance for 48hrs. Please, check documentation on how to perform this maintenance process on %s and enable it as soon as possible.', get_product_name()), - 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=perf'), ] ); } else { @@ -1645,7 +1645,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.HISTORYDB.MR', 'title' => __('Historical database MR mismatch'), 'message' => __('Your historical database is not using the same schema as the main DB. This could produce anomalies while storing historical data.'), - 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db', + 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db'), ] ); } else { @@ -1687,7 +1687,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.EXT.ELASTICSEARCH', 'title' => __('Log collector cannot connect to ElasticSearch'), 'message' => __('ElasticSearch is not available using current configuration.'), - 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=log', + 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=log'), ] ); } else { @@ -1757,7 +1757,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.METACONSOLE.DB_CONNECTION', 'title' => __('Metaconsole DB is not available.'), 'message' => __('Cannot connect with Metaconsole DB using current configuration.'), - 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=enterprise', + 'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=enterprise'), ] ); } @@ -1786,7 +1786,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.DOWNTIME', 'title' => __('Scheduled downtime running.'), 'message' => __('A scheduled downtime is running. Some monitoring data won\'t be available while downtime is taking place.'), - 'url' => 'index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list', + 'url' => ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list'), ] ); return; @@ -1947,7 +1947,7 @@ class ConsoleSupervisor date('M j, G:i:s ', $next_downtime_begin), date('M j, G:i:s ', $next_downtime_end) ), - 'url' => 'index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list', + 'url' => ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list'), ] ); return; @@ -2043,7 +2043,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.SECURITY.DEFAULT_PASSWORD', 'title' => __('Default password for "Admin" user has not been changed'), 'message' => __('Please, change the default password since it is a commonly reported vulnerability.'), - 'url' => 'index.php?sec=gusuarios&sec2=godmode/users/user_list', + 'url' => ui_get_full_url('index.php?sec=gusuarios&sec2=godmode/users/user_list'), ] ); } else { @@ -2069,7 +2069,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.MISC.FONTPATH', 'title' => __('Default font doesn\'t exist'), 'message' => __('Your defined font doesn\'t exist or is not defined. Please, check font parameters in your config'), - 'url' => 'index.php?sec=gsetup&sec2=godmode/setup/setup§ion=vis', + 'url' => ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup§ion=vis'), ] ); } else { @@ -2096,7 +2096,7 @@ class ConsoleSupervisor 'Your %s has the "develop_bypass" mode enabled. This is a developer mode and should be disabled in a production environment. This value is located in the main index.php file', get_product_name() ), - 'url' => 'index.php', + 'url' => ui_get_full_url('index.php'), ] ); } else { @@ -2119,7 +2119,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.MISC.EVENTSTORMPROTECTION', 'title' => __('Event storm protection is enabled.'), 'message' => __('Some events may get lost while this mode is enabled. The server must be restarted after altering this setting.'), - 'url' => 'index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general', + 'url' => ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general'), ] ); } else { @@ -2146,7 +2146,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.UPDATEMANAGER.OPENSETUP', 'title' => __('Failed to retrieve updates, please configure utility'), 'message' => $message, - 'url' => 'index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general', + 'url' => ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general'), ] ); } @@ -2165,8 +2165,8 @@ class ConsoleSupervisor 'New %s Console update', get_product_name() ), - 'message' => __('There is a new update available. Please go to Administration:Setup:Update Manager for more details.'), - 'url' => 'index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=online', + 'message' => __('There is a new update available. Please go to Administration:Setup:Update Manager for more details.'), + 'url' => ui_get_full_url('index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=online'), ] ); } else { @@ -2204,7 +2204,7 @@ class ConsoleSupervisor 'There is one or more minor releases available. .About minor release update.', $url ), - 'url' => 'index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', + 'url' => ui_get_full_url('index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online'), ] ); } else { @@ -2253,7 +2253,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.CRON.CONFIGURED', 'title' => __('DiscoveryConsoleTasks is not configured.'), 'message' => __($message_conf_cron), - 'url' => 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist', + 'url' => ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist'), ] ); } else { diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index fb51f94fe4..7e3667dd2c 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 = 'PC190905'; +$build_version = 'PC190923'; $pandora_version = 'v7.0NG.738'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 899b5b609b..8c5b1364f1 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -355,6 +355,12 @@ define('MODULE_PREDICTION_CLUSTER', 5); define('MODULE_PREDICTION_CLUSTER_AA', 6); define('MODULE_PREDICTION_CLUSTER_AP', 7); +// Type of Webserver Modules. +define('MODULE_WEBSERVER_CHECK_LATENCY', 30); +define('MODULE_WEBSERVER_CHECK_SERVER_RESPONSE', 31); +define('MODULE_WEBSERVER_RETRIEVE_NUMERIC_DATA', 32); +define('MODULE_WEBSERVER_RETRIEVE_STRING_DATA', 33); + // SNMP CONSTANTS. define('SNMP_DIR_MIBS', 'attachment/mibs'); @@ -624,3 +630,21 @@ define('DEFAULT_NODE_COLOR', COL_NOTINIT); define('DEFAULT_NODE_IMAGE', 'images/networkmap/unknown.png'); define('NODE_IMAGE_PADDING', 5); + +// Pandora Database HA constants. +define('HA_ACTION_NONE', 0); +define('HA_ACTION_DEPLOY', 1); +define('HA_ACTION_RECOVER', 2); +define('HA_ACTION_PROMOTE', 3); +define('HA_ACTION_DEMOTE', 4); +define('HA_ACTION_DISABLE', 5); +define('HA_ACTION_ENABLE', 6); +define('HA_ACTION_CLEANUP', 7); +define('HA_ACTION_RESYNC', 8); + +define('HA_UNINITIALIZED', 0); +define('HA_ONLINE', 1); +define('HA_PENDING', 2); +define('HA_PROCESSING', 3); +define('HA_DISABLED', 4); +define('HA_FAILED', 5); diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index fdcce4457a..826ca971c5 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -68,6 +68,57 @@ function agents_get_agent_id_by_module_id($id_agente_modulo) } +/** + * Search for agent data anywhere. + * + * Note: This method matches with server (perl) locate_agent. + * Do not change order! + * + * @param string $field Alias, name or IP address of searchable agent. + * + * @return array Agent of false if not found. + */ +function agents_locate_agent(string $field) +{ + global $config; + + $table = 'tagente'; + if (is_metaconsole()) { + $table = 'tmetaconsole_agent'; + } + + // Alias. + $sql = sprintf( + 'SELECT * + FROM %s + WHERE alias = "%s"', + $table, + $field + ); + $agent = db_get_row_sql($sql); + + if ($agent !== false) { + return $agent; + } + + // Addr. + $agent = agents_get_agent_with_ip($field); + if ($agent !== false) { + return $agent; + } + + // Name. + $sql = sprintf( + 'SELECT * + FROM %s + WHERE nombre = "%s"', + $table, + $field + ); + return db_get_row_sql($sql); +} + + /** * Get agent id from an agent alias. * diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index f59061a03c..bc5e64190d 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -325,6 +325,34 @@ function config_update_config() if (!config_update_value('unique_ip', get_parameter('unique_ip'))) { $error_update[] = __('unique_ip'); } + + if (!config_update_value('email_smtpServer', get_parameter('email_smtpServer'))) { + $error_update[] = __('Server SMTP'); + } + + if (!config_update_value('email_from_dir', get_parameter('email_from_dir'))) { + $error_update[] = __('From dir'); + } + + if (!config_update_value('email_from_name', get_parameter('email_from_name'))) { + $error_update[] = __('From name'); + } + + if (!config_update_value('email_smtpPort', (int) get_parameter('email_smtpPort'))) { + $error_update[] = __('Port SMTP'); + } + + if (!config_update_value('email_encryption', get_parameter('email_encryption'))) { + $error_update[] = __('Encryption'); + } + + if (!config_update_value('email_username', get_parameter('email_username'))) { + $error_update[] = __('Email user'); + } + + if (!config_update_value('email_password', get_parameter('email_password'))) { + $error_update[] = __('Email password'); + } break; case 'enterprise': @@ -419,34 +447,6 @@ function config_update_config() if (!config_update_value('inventory_changes_blacklist', implode(',', $inventory_changes_blacklist))) { $error_update[] = __('Inventory changes blacklist'); } - - if (!config_update_value('email_from_dir', get_parameter('email_from_dir'))) { - $error_update[] = __('From dir'); - } - - if (!config_update_value('email_from_name', get_parameter('email_from_name'))) { - $error_update[] = __('From name'); - } - - if (!config_update_value('email_smtpServer', get_parameter('email_smtpServer'))) { - $error_update[] = __('Server SMTP'); - } - - if (!config_update_value('email_smtpPort', (int) get_parameter('email_smtpPort'))) { - $error_update[] = __('Port SMTP'); - } - - if (!config_update_value('email_encryption', get_parameter('email_encryption'))) { - $error_update[] = __('Encryption'); - } - - if (!config_update_value('email_username', get_parameter('email_username'))) { - $error_update[] = __('Email user'); - } - - if (!config_update_value('email_password', get_parameter('email_password'))) { - $error_update[] = __('Email password'); - } } break; diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 3efbf59628..a99ab2e41e 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -46,6 +46,25 @@ function db_select_engine() } +/** + * Connects to target DB. + * + * @param array $setup Database definition. + * + * @return mixed Dbconnection or null. + */ +function get_dbconnection(array $setup) +{ + return mysqli_connect( + $setup['dbhost'], + $setup['dbuser'], + $setup['dbpass'], + $setup['dbname'], + $setup['dbport'] + ); +} + + function db_connect($host=null, $db=null, $user=null, $pass=null, $port=null, $critical=true, $charset=null) { global $config; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 08d60dbb6e..5fa4824a1e 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -98,6 +98,23 @@ function hd($var, $file='', $oneline=false) } +/** + * Encapsulation (ob) for debug print function. + * + * @param mixed $var Variable to be dumped. + * @param string $file Target file path. + * @param boolean $oneline Show in oneline. + * + * @return string Dump string. + */ +function obhd($var, $file='', $oneline=false) +{ + ob_start(); + hd($var, $file, $oneline); + return ob_get_clean(); +} + + function debug() { $args_num = func_num_args(); @@ -1570,6 +1587,7 @@ function html_print_input_image($name, $src, $value, $style='', $return=false, $ 'onkeypress', 'onkeydown', 'onkeyup', + 'class', ]; foreach ($attrs as $attribute) { @@ -3152,7 +3170,8 @@ function html_print_input($data, $wrapper='div', $input_only=false) ((isset($data['return']) === true) ? $data['return'] : false), ((isset($data['disabled']) === true) ? $data['disabled'] : false), ((isset($data['required']) === true) ? $data['required'] : false), - ((isset($data['class']) === true) ? $data['class'] : '') + ((isset($data['class']) === true) ? $data['class'] : ''), + ((isset($data['autocomplete']) === true) ? $data['autocomplete'] : 'off') ); break; diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index 98191d231f..36785064ef 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -545,7 +545,6 @@ function menu_add_extras(&$menu) $menu_extra['estado']['sub']['godmode/snmpconsole/snmp_filters']['text'] = __('SNMP filters'); $menu_extra['estado']['sub']['enterprise/godmode/snmpconsole/snmp_trap_editor']['text'] = __('SNMP trap editor'); $menu_extra['estado']['sub']['snmpconsole']['sub2']['godmode/snmpconsole/snmp_trap_generator']['text'] = __('SNMP trap generator'); - $menu_extra['estado']['sub']['snmpconsole']['sub2']['operation/snmpconsole/snmp_view']['text'] = __('SNMP console'); $menu_extra['workspace']['sub']['operation/incidents/incident_detail']['text'] = __('Manage incident'); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 4abf5152c1..4edd0ef642 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -4785,12 +4785,10 @@ function reporting_value($report, $content, $type, $pdf=false) 'period' => $content['period'], 'width' => '600px', 'pure' => false, - // true 'date' => $report['datetime'], 'only_image' => $only_image, 'homeurl' => ui_get_full_url(false, false, false, false), 'ttl' => 1, - // 2 'type_graph' => $config['type_module_charts'], 'time_interval' => $content['lapse'], 'server_id' => $id_meta, @@ -4800,323 +4798,104 @@ function reporting_value($report, $content, $type, $pdf=false) switch ($type) { case 'max': - if ($content['lapse_calc'] == 0) { - $value = reporting_get_agentmodule_data_max( - $content['id_agent_module'], - $content['period'], - $report['datetime'] - ); - if (!$config['simple_module_value']) { - $formated_value = $value; - } else { - $formated_value = format_for_graph($value, $config['graph_precision']).' '.$unit; - } - } else { - $value = ' - - - - - - - - - -
'; - if ($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3) { - $value .= ' - - - - - - - - - - -
- '.__('Agent').' - - '.__('Module').' - - '.__('Maximum').' -
- '.$agent_name.' - - '.$module_name.' - - '.format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision']).' '.$unit.' -
'; - } - - $value .= ' -
- '; - - if ($content['visual_format'] == 2 || $content['visual_format'] == 3) { - $params['force_interval'] = 'max_only'; - $value .= grafico_modulo_sparse($params); - } - - $value .= ' - -
'; - - if ($content['visual_format'] == 1 || $content['visual_format'] == 3) { - $value .= ' - - - - - - '; - $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module'], true); - $date_reference = getdate(); - - for ($i = $date_reference[0]; $i > ($date_reference[0] - $content['period']); $i -= $content['lapse']) { - $value .= ''; - } else { - $value .= 'N/A'; - } - } - - $value .= '
- '.__('Lapse').' - - '.__('Maximum').' -
'.date('Y-m-d H:i:s', ($i - $content['lapse'] + 1)).' to '.date('Y-m-d H:i:s', $i).''; - - if ($i > $time_begin['utimestamp']) { - $value .= format_for_graph( - reporting_get_agentmodule_data_max( - $content['id_agent_module'], - $content['lapse'], - $i - ), - $config['graph_precision'] - ).' '.$unit.'
'; - } - - $value .= ' -
'; - - $formated_value = $value; - } - break; - case 'min': - if ($content['lapse_calc'] == 0) { - $value = reporting_get_agentmodule_data_min( - $content['id_agent_module'], - $content['period'], - $report['datetime'] - ); - - if (!$config['simple_module_value']) { - $formated_value = $value; - } else { - $formated_value = format_for_graph($value, $config['graph_precision']).' '.$unit; - } - } else { - $value = ' - - - - - - - - - -
'; - - if ($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3) { - $value .= ' - - - - - - - - - - -
- '.__('Agent').' - - '.__('Module').' - - '.__('Minimum').' -
- '.$agent_name.' - - '.$module_name.' - - '.format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision']).' '.$unit.' -
'; - } - - $value .= ' -
- '; - - if ($content['visual_format'] == 2 || $content['visual_format'] == 3) { - $params['force_interval'] = 'min_only'; - $value .= grafico_modulo_sparse($params); - } - - $value .= ' -
'; - - if ($content['visual_format'] == 1 || $content['visual_format'] == 3) { - $value .= ' - - - - - - '; - $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']); - $date_reference = getdate(); - - for ($i = $date_reference[0]; $i > ($date_reference[0] - $content['period']); $i -= $content['lapse']) { - $value .= ''; - } else { - $value .= 'N/A'; - } - } - - $value .= '
- '.__('Lapse').' - - '.__('Minimum').' -
'.date('Y-m-d H:i:s', ($i - $content['lapse'] + 1)).' to '.date('Y-m-d H:i:s', $i).''; - - if ($i > $time_begin['utimestamp']) { - $value .= format_for_graph( - reporting_get_agentmodule_data_min( - $content['id_agent_module'], - $content['lapse'], - $i - ), - $config['graph_precision'] - ).' '.$unit.'
'; - } - - $value .= ' - -
'; - - $formated_value = $value; - } - break; - case 'avg': if ($content['lapse_calc'] == 0) { - $value = reporting_get_agentmodule_data_average( - $content['id_agent_module'], - $content['period'], - $report['datetime'] - ); + switch ($type) { + case 'max': + $value = reporting_get_agentmodule_data_max( + $content['id_agent_module'], + $content['period'], + $report['datetime'] + ); + break; + + case 'min': + $value = reporting_get_agentmodule_data_min( + $content['id_agent_module'], + $content['period'], + $report['datetime'] + ); + break; + + case 'avg': + $value = reporting_get_agentmodule_data_average( + $content['id_agent_module'], + $content['period'], + $report['datetime'] + ); + break; + } + if (!$config['simple_module_value']) { $formated_value = $value; } else { $formated_value = format_for_graph($value, $config['graph_precision']).' '.$unit; } } else { - $value = ' - - - - - - - - - -
'; + $return['visual_format'] = $content['visual_format']; - if ($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3) { - $value .= ' - - - - - - - - - - -
- '.__('Agent').' - - '.__('Module').' - - '.__('Average').' -
- '.$agent_name.' - - '.$module_name.' - - '.format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision']).' '.$unit.' -
'; + switch ($type) { + case 'max': + $params['force_interval'] = 'max_only'; + $value = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision']).' '.$unit; + break; + + case 'min': + $params['force_interval'] = 'min_only'; + $value = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision']).' '.$unit; + break; + + case 'avg': + $params['force_interval'] = 'avg_only'; + $value = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision']).' '.$unit; + break; } - $value .= ' -
- '; - if ($content['visual_format'] == 2 || $content['visual_format'] == 3) { - $params['force_interval'] = 'avg_only'; - $value .= grafico_modulo_sparse($params); + $return['data'][] = [ + __('Agent') => $agent_name, + __('Module') => $module_name, + __('Maximun') => $value, + ]; + + if ($content['visual_format'] != 1) { + $graph = grafico_modulo_sparse($params); + $return['data'][] = ['value' => $graph]; } - $value .= ' - -
'; - - if ($content['visual_format'] == 1 || $content['visual_format'] == 3) { - $value .= ' - - - - - - '; - $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']); - $date_reference = getdate(); - - for ($i = $date_reference[0]; $i > ($date_reference[0] - $content['period']); $i -= $content['lapse']) { - $value .= ''; - } else { - $value .= 'N/A'; - } - } + switch ($type) { + case 'max': + $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['lapse'], $i), $config['graph_precision']).' '.$unit; + break; - $value .= '
- '.__('Lapse').' - - '.__('Average').' -
'.date('Y-m-d H:i:s', ($i - $content['lapse'] + 1)).' to '.date('Y-m-d H:i:s', $i).''; + if ($content['visual_format'] != 2) { + $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module'], true); + for ($i = $report['datetime']; $i > ($report['datetime'] - $content['period']); $i -= $content['lapse']) { + $row = []; + $row[__('Lapse')] = date('Y-m-d H:i:s', ($i - $content['lapse'] + 1)).' to '.date('Y-m-d H:i:s', $i); if ($i > $time_begin['utimestamp']) { - $value .= format_for_graph( - reporting_get_agentmodule_data_average( - $content['id_agent_module'], - $content['lapse'], - $i - ), - $config['graph_precision'] - ).' '.$unit.'
'; + case 'min': + $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['lapse'], $i), $config['graph_precision']).' '.$unit; + break; + + case 'avg': + $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['lapse'], $i), $config['graph_precision']).' '.$unit; + break; + } + } else { + $row[__('Maximun')] = 'N/A'; + } + + $return['data'][] = $row; + } } - $value .= ' - -
'; + if ($config['metaconsole']) { + metaconsole_restore_db(); + } - $formated_value = $value; + return reporting_check_structure_content($return); } break; @@ -5124,7 +4903,8 @@ function reporting_value($report, $content, $type, $pdf=false) $value = reporting_get_agentmodule_data_sum( $content['id_agent_module'], $content['period'], - $report['datetime'] + $report['datetime'], + $content['uncompressed_module'] ); if (!$config['simple_module_value']) { $formated_value = $value; @@ -10946,17 +10726,19 @@ function reporting_get_agentmodule_data_min($id_agent_module, $period=0, $date=0 * @param int Agent module id to get the sumatory. * @param int Period of time to check (in seconds) * @param int Top date to check the values. Default current time. + * @param boolean Show uncompressed data from module * * @return float The sumatory of the module values in the interval. */ function reporting_get_agentmodule_data_sum( $id_agent_module, $period=0, - $date=0 + $date=0, + $uncompressed_module=true ) { global $config; - // Initialize variables + // Initialize variables. if (empty($date)) { $date = get_system_time(); } @@ -10978,21 +10760,24 @@ function reporting_get_agentmodule_data_sum( $id_module_type ); $module_interval = modules_get_interval($id_agent_module); - $uncompressed_module = is_module_uncompressed($module_name); + // Check if module must be compressed. + if (!$uncompressed_module) { + $uncompressed_module = is_module_uncompressed($module_name); + } // Wrong module type if (is_module_data_string($module_name)) { return 0; } - // Incremental modules are treated differently + // Incremental modules are treated differently. $module_inc = is_module_inc($module_name); - if ($uncompressed_module) { - // Get module data + if (!$uncompressed_module) { + // Get module data. $interval_data = db_get_all_rows_sql( ' - SELECT * FROM tagente_datos + SELECT * FROM tagente_datos WHERE id_agente_modulo = '.(int) $id_agent_module.' AND utimestamp > '.(int) $datelimit.' AND utimestamp < '.(int) $date.' @@ -11013,7 +10798,7 @@ function reporting_get_agentmodule_data_sum( return false; } - // Set initial conditions + // Set initial conditions. $total = 0; $partial_total = 0; $count_sum = 0; @@ -11022,18 +10807,9 @@ function reporting_get_agentmodule_data_sum( $partial_total = 0; $count_sum = 0; - switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - // Do none - break; - - case 'oracle': - $data['datos'] = oracle_format_float_to_php($data['datos']); - break; - } - - if (!$module_inc) { + if (!$uncompressed_module) { + $total += $data['datos']; + } else if (!$module_inc) { foreach ($data['data'] as $val) { if (is_numeric($val['datos'])) { $partial_total += $val['datos']; @@ -11045,7 +10821,7 @@ function reporting_get_agentmodule_data_sum( continue; } - $total += ($partial_total / $count_sum); + $total += $partial_total; } else { $last = end($data['data']); $total += $last['datos']; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 6a7d60c620..a15340ce4b 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2532,7 +2532,7 @@ function reporting_html_monitor_report($table, $item, $mini, $pdf=0) true ).' '.__('OK').': '.remove_right_zeros( number_format( - $item['data']['ok']['formated_value'], + $item['data']['ok']['value'], $config['graph_precision'] ) ).' %

'; @@ -2543,7 +2543,7 @@ function reporting_html_monitor_report($table, $item, $mini, $pdf=0) true ).' '.__('Not OK').': '.remove_right_zeros( number_format( - $item['data']['fail']['formated_value'], + $item['data']['fail']['value'], $config['graph_precision'] ) ).' % '.'

'; @@ -2784,20 +2784,130 @@ function reporting_html_value(&$table, $item, $mini, $only_value=false, $check_e $font_size = '3'; } - $table->colspan['data']['cell'] = 3; - $table->cellstyle['data']['cell'] = 'text-align: left;'; + if (isset($item['visual_format']) && $item['visual_format'] != 0 + && ($item['type'] == 'max_value' || $item['type'] == 'min_value' || $item['type'] == 'avg_value') + ) { + $table2 = new stdClass(); + $table2->width = '100%'; + switch ($item['type']) { + case 'max_value': + $table2->head = [ + __('Agent'), + __('Module'), + __('Maximun'), + ]; + break; - $table->data['data']['cell'] = '

'; + case 'min_value': + $table2->head = [ + __('Agent'), + __('Module'), + __('Minimun'), + ]; + break; - if ($check_empty && empty($item['data']['value'])) { - $table->data['data']['cell'] .= __('Unknown'); - } else if ($only_value) { - $table->data['data']['cell'] .= $item['data']['value']; + case 'avg_value': + $table2->head = [ + __('Agent'), + __('Module'), + __('Average'), + ]; + break; + } + + $table2->data = []; + + $data = $item['data'][0]; + + $row = [ + $data[__('Agent')], + $data[__('Module')], + $data[__('Maximun')], + ]; + + $table2->data[] = $row; + + $table2->title = $item['title']; + $table2->titleclass = 'title_table_pdf'; + $table2->titlestyle = 'text-align:left;'; + $table->colspan[1][0] = 3; + $table->colspan[2][0] = 3; + $table->colspan[3][0] = 3; + + array_push($table->data, html_print_table($table2, true)); + unset($item['data'][0]); + + if ($item['visual_format'] != 1) { + $value = $item['data'][1]['value']; + array_push($table->data, $value); + unset($item['data'][1]); + } + + if ($item['visual_format'] != 2) { + $table1 = new stdClass(); + $table1->width = '100%'; + switch ($item['type']) { + case 'max_value': + $table1->head = [ + __('Lapse'), + __('Maximun'), + ]; + break; + + case 'min_value': + $table1->head = [ + __('Lapse'), + __('Minimun'), + ]; + break; + + case 'avg_value': + $table1->head = [ + __('Lapse'), + __('Average'), + ]; + break; + } + + $table1->data = []; + foreach ($item['data'] as $data) { + if (!is_numeric($data[__('Maximun')])) { + $row = [ + $data[__('Lapse')], + $data[__('Maximun')], + ]; + } else { + $row = [ + $data[__('Lapse')], + remove_right_zeros(number_format($data[__('Maximun')], $config['graph_precision'])), + ]; + } + + $table1->data[] = $row; + } + + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + + array_push($table->data, html_print_table($table1, true)); + } } else { - $table->data['data']['cell'] .= $item['data']['formated_value']; - } + $table->colspan['data']['cell'] = 3; + $table->cellstyle['data']['cell'] = 'text-align: left;'; - $table->data['data']['cell'] .= '

'; + $table->data['data']['cell'] = '

'; + + if ($check_empty && empty($item['data']['value'])) { + $table->data['data']['cell'] .= __('Unknown'); + } else if ($only_value) { + $table->data['data']['cell'] .= $item['data']['value']; + } else { + $table->data['data']['cell'] .= $item['data']['formated_value']; + } + + $table->data['data']['cell'] .= '

'; + } } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 008c05b8d7..06c4b579ea 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -2679,6 +2679,7 @@ function get_shape_status_set($type) case STATUS_MODULE_UNKNOWN: case STATUS_AGENT_UNKNOWN: case STATUS_AGENT_DOWN: + case STATUS_AGENT_NO_MONITORS: $return = ['class' => 'status_rounded_rectangles']; break; diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 05009e7292..1fc5912fb9 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -1915,7 +1915,9 @@ function load_modal(settings) { text: settings.modal.cancel, click: function() { $(this).dialog("close"); - settings.cleanup(); + if (typeof settings.cleanup == "function") { + settings.cleanup(); + } } }, { diff --git a/pandora_console/include/load_session.php b/pandora_console/include/load_session.php index 80fb8643ef..39e0973287 100644 --- a/pandora_console/include/load_session.php +++ b/pandora_console/include/load_session.php @@ -91,6 +91,11 @@ function pandora_session_write($session_id, $data) { $session_id = addslashes($session_id); + // If it's an api call, the session must not be created. + if (get_parameter('op', false) && get_parameter('op2', false)) { + return true; + } + if (is_ajax()) { // Avoid session upadte while processing ajax responses - notifications. if (get_parameter('check_new_notifications', false)) { diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php index cbbe877f8d..53f2adcadd 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php @@ -291,21 +291,9 @@ final class Group extends Item $width = (int) $data['width']; $height = (int) $data['height']; if ($width === 0 || $height === 0) { - // TODO: This will be the default behaviour after we finish the - // builder. Don't delete this code. - // $sizeImage = getimagesize($config['homedir'].'/'.$imagePath); - // $data['width'] = $sizeImage[0]; - // $data['height'] = $sizeImage[1]; $sizeImage = getimagesize($config['homedir'].'/'.$imagePath); - $imageHeight = $sizeImage[1]; - - if ($width === 0) { - $data['width'] = 70; - } - - if ($height === 0) { - $data['height'] = ($imageHeight > 70) ? 70 : $imageHeight; - } + $data['width'] = $sizeImage[0]; + $data['height'] = $sizeImage[1]; } $data['html'] = ''; diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Icon.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Icon.php index 29605ffb4f..e67c76a6a7 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/Icon.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Icon.php @@ -120,21 +120,9 @@ final class Icon extends Item $width = (int) $data['width']; $height = (int) $data['height']; if ($width === 0 || $height === 0) { - // TODO: This will be the default behaviour after we finish the - // builder. Don't delete this code. - // $sizeImage = getimagesize($config['homedir'].'/'.$imagePath); - // $data['width'] = $sizeImage[0]; - // $data['height'] = $sizeImage[1]; $sizeImage = getimagesize($config['homedir'].'/'.$imagePath); - $imageHeight = $sizeImage[1]; - - if ($width === 0) { - $data['width'] = 70; - } - - if ($height === 0) { - $data['height'] = ($imageHeight > 70) ? 70 : $imageHeight; - } + $data['width'] = $sizeImage[0]; + $data['height'] = $sizeImage[1]; } return $data; diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php b/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php index 9af4287d26..c43fb39136 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php @@ -184,23 +184,9 @@ final class StaticGraph extends Item $width = (int) $data['width']; $height = (int) $data['height']; if ($width === 0 || $height === 0) { - // TODO: This will be the default behaviour after we finish the - // builder. Don't delete this code. - // $sizeImage = getimagesize($config['homedir'].'/'.$imagePath); - // $data['width'] = $sizeImage[0]; - // $data['height'] = $sizeImage[1]; - // Default value. Will be replaced by a dynamic image size - // calculation after the phase 3. $sizeImage = getimagesize($config['homedir'].'/'.$imagePath); - $imageHeight = $sizeImage[1]; - - if ($width === 0) { - $data['width'] = 70; - } - - if ($height === 0) { - $data['height'] = ($imageHeight > 70) ? 70 : $imageHeight; - } + $data['width'] = $sizeImage[0]; + $data['height'] = $sizeImage[1]; } // Get last value. diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 8c12d11d04..27b3094027 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -452,6 +452,9 @@ select:-internal-list-box { .mw120px { min-width: 120px; } +.mw180px { + min-width: 180px; +} .mw250px { min-width: 250px; } @@ -3182,6 +3185,7 @@ table#policy_modules td * { #news_board { min-width: 530px; + width: 100%; } #right_column_logon_ok { diff --git a/pandora_console/include/visual-console-client/vc.main.css b/pandora_console/include/visual-console-client/vc.main.css index 16ecacd33c..22c3cce748 100644 --- a/pandora_console/include/visual-console-client/vc.main.css +++ b/pandora_console/include/visual-console-client/vc.main.css @@ -13,27 +13,27 @@ display: flex; -webkit-box-orient: initial; -webkit-box-direction: initial; - -ms-flex-direction: initial; - flex-direction: initial; + -ms-flex-direction: initial; + flex-direction: initial; justify-items: center; -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; + -ms-flex-align: center; + align-items: center; -webkit-user-select: text; - -moz-user-select: text; - -ms-user-select: text; - user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; } .visual-console-item.is-editing { border: 2px dashed #b2b2b2; -webkit-transform: translateX(-2px) translateY(-2px); - transform: translateX(-2px) translateY(-2px); + transform: translateX(-2px) translateY(-2px); cursor: move; -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; } .visual-console-item.is-editing > .resize-draggable { @@ -60,17 +60,17 @@ display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; - -ms-flex-direction: column; - flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; -webkit-box-pack: center; - -ms-flex-pack: center; - justify-content: center; + -ms-flex-pack: center; + justify-content: center; justify-items: center; -ms-flex-line-pack: center; - align-content: center; + align-content: center; -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; + -ms-flex-align: center; + align-items: center; } .visual-console-item .digital-clock > span { @@ -89,7 +89,7 @@ } .visual-console-item .digital-clock > span.timezone { - font-size: 25px; + font-size: 28px; } /* Analog clock */ @@ -100,18 +100,17 @@ .visual-console-item .analogic-clock .hour-hand { -webkit-animation: rotate-hour 43200s infinite linear; - animation: rotate-hour 43200s infinite linear; + animation: rotate-hour 43200s infinite linear; } .visual-console-item .analogic-clock .minute-hand { -webkit-animation: rotate-minute 3600s infinite linear; - animation: rotate-minute 3600s infinite linear; + animation: rotate-minute 3600s infinite linear; } .visual-console-item .analogic-clock .second-hand { -webkit-animation: rotate-second 60s infinite linear; - animation: rotate-second 60s infinite linear; + animation: rotate-second 60s infinite linear; } - -/*# sourceMappingURL=vc.main.css.map*/ \ No newline at end of file +/*# sourceMappingURL=vc.main.css.map*/ diff --git a/pandora_console/include/web2image.js b/pandora_console/include/web2image.js index bf183a73c4..09f840e45e 100644 --- a/pandora_console/include/web2image.js +++ b/pandora_console/include/web2image.js @@ -61,6 +61,7 @@ page.onConsoleMessage = function(msg) { page.onError = function(msg) { console.log(msg); page.close(); + phantom.exit(); }; page.onCallback = function(st) { @@ -74,4 +75,9 @@ page.onCallback = function(st) { phantom.exit(); }; -page.open(url, "POST", post_data, function(status) {}); +page.open(url, "POST", post_data, function(status) { + if (status == "fail") { + console.out("Failed to generate chart."); + phantom.exit(); + } +}); diff --git a/pandora_console/install.php b/pandora_console/install.php index 99fc5e653e..a06e476f1e 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
0) { + $fields[array_search('instructions', $fields)] = [ + 'text' => 'instructions', + 'class' => 'column-instructions', + ]; + } + $evento_id = array_search('evento', $fields); if ($evento_id !== false) { $fields[$evento_id] = [ @@ -1411,6 +1419,7 @@ try { 'no_sortable_columns' => [ -1, -2, + 'column-instructions', ], 'ajax_postprocess' => 'process_datatables_item(item)', 'drawCallback' => 'process_datatables_callback(this, settings)', diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index e8431ddeb2..0bba865711 100755 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -17,7 +17,6 @@ global $config; check_login(); enterprise_hook('open_meta_frame'); - $id_report = (int) get_parameter('id'); if (! $id_report) { diff --git a/pandora_console/operation/snmpconsole/snmp_statistics.php b/pandora_console/operation/snmpconsole/snmp_statistics.php index afe05be977..076ca806d7 100755 --- a/pandora_console/operation/snmpconsole/snmp_statistics.php +++ b/pandora_console/operation/snmpconsole/snmp_statistics.php @@ -155,7 +155,7 @@ foreach ($traps_generated_by_source as $trap) { $row['source'] = ''.$trap['source'].''; } else { $agent_id = $agent['id_agente']; - $agent_name = ui_print_truncate_text($agent['nombre'], 'agent_medium', true, true, true, '[…]', ''); + $agent_name = ui_print_truncate_text($agent['alias'], 'agent_medium', true, true, true, '[…]', ''); $row['source'] = "'; $row['source'] .= "$agent_name"; } diff --git a/pandora_console/operation/visual_console/legacy_public_view.php b/pandora_console/operation/visual_console/legacy_public_view.php index 7bea2a22c9..ab6def4f70 100644 --- a/pandora_console/operation/visual_console/legacy_public_view.php +++ b/pandora_console/operation/visual_console/legacy_public_view.php @@ -115,6 +115,7 @@ echo ''; // Countdown. echo '
  • '; echo '
    '; +echo '
    '; echo '
    '; echo __('Refresh').':'; echo html_print_select( @@ -187,7 +188,7 @@ $ignored_params['refr'] = ''; var controls = document.getElementById('vc-controls'); autoHideElement(controls, 1000); - $('select#refr').change(function (event) { + $('#vc-controls').change(function (event) { refr = Number.parseInt(event.target.value, 10); startCountDown(refr, false); }); diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 7a54e6069d..573a742276 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.738 -%define release 190905 +%define release 190923 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec index 08a7875cf1..7e44602da4 100644 --- a/pandora_console/pandora_console.rhel7.spec +++ b/pandora_console/pandora_console.rhel7.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.738 -%define release 190905 +%define release 190923 # 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 96873768d8..659938b9aa 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.738 -%define release 190905 +%define release 190923 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index d1de66ab07..3786c4dad3 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1455,6 +1455,7 @@ CREATE TABLE IF NOT EXISTS `treport_content` ( `current_month` TINYINT(1) DEFAULT '1', `failover_mode` tinyint(1) DEFAULT '1', `failover_type` tinyint(1) DEFAULT '1', + `uncompressed_module` TINYINT DEFAULT '0', PRIMARY KEY(`id_rc`), FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`) ON UPDATE CASCADE ON DELETE CASCADE @@ -2438,14 +2439,17 @@ CREATE TABLE IF NOT EXISTS `tdashboard` ( -- Table `tdatabase` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tdatabase` ( - `id` int(10) unsigned NOT NULL auto_increment, - `host` varchar(100) default '', - `os_port` int(4) unsigned default '22', - `os_user` varchar(100) default '', - `db_port` int(4) unsigned default '3306', + `id` INT(10) unsigned NOT NULL auto_increment, + `host` VARCHAR(255) default '', + `label` VARCHAR(255) default '', + `os_port` INT UNSIGNED NOT NULL DEFAULT 22, + `os_user` VARCHAR(255) default '', + `db_port` INT UNSIGNED NOT NULL DEFAULT 3306, `status` tinyint(1) unsigned default '0', `action` tinyint(1) unsigned default '0', - `last_error` varchar(255) default '', + `ssh_key` TEXT, + `ssh_pubkey` TEXT, + `last_error` TEXT, PRIMARY KEY (`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; @@ -2998,6 +3002,7 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` ( `current_month` TINYINT(1) DEFAULT '1', `failover_mode` tinyint(1) DEFAULT '1', `failover_type` tinyint(1) DEFAULT '1', + `uncompressed_module` TINYINT DEFAULT '0', PRIMARY KEY(`id_rc`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index a02f88fe5f..01f069b8b6 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -1317,7 +1317,8 @@ UPDATE `tnotification_source` SET `enabled`=1 WHERE `description` = 'System -- INSERT INTO `tlayout` VALUES - (1, 'Demo visual console', 0, 'fondo.jpg', 1080, 1920, 'white', 0); + (1, 'Demo visual console', 0, 'fondo.jpg', 1080, 1920, 'white', 0), + (2,'Demo visual console 2',0,'fondo-keep-alive.jpg',1080,1920,'#FFF',0); -- -- Dumping data for table `tlayout_data` @@ -1420,5 +1421,20 @@ VALUES (94,1,580,904,0,0,'<p style="text-align: center; overflow: hidden;"><span class="visual_font_size_28pt" style="color: #ffffff; font-family: opensans;"><strong><span class="visual_font_size_28pt" style="color: #ffffff; font-family: opensans;">Office 7 -&nbsp;</span></strong></span><span class="visual_font_size_28pt" style="color: #ffffff; font-family: opensans;">Rack 2</span></p>','white',4,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,0), (95,1,132,907,0,0,'<p style="text-align: center; overflow: hidden;"><span class="visual_font_size_28pt" style="color: #ffffff; font-family: opensans;"><strong><span class="visual_font_size_28pt" style="color: #ffffff; font-family: opensans;">Office 7 -&nbsp;</span></strong></span><span class="visual_font_size_28pt" style="color: #ffffff; font-family: opensans;">Rack 1</span></p>','white',4,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,0), (96,1,733,20,0,0,'<p style="overflow: hidden;"><span class="visual_font_size_48pt"><strong><span style="color: #ffffff; font-family: opensans;">OFFICE RACKS</span></strong></span></p>','white',4,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,0), - (97,1,1479,260,174,29,'','rack_server_rack',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60) -; \ No newline at end of file + (97,1,1479,260,174,29,'','rack_server_rack',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60), + (98,2,709,103,0,400,'','white',19,3600,0,0,0,0,1,0,0,0,0,'line','down','','#FFFFFF',0,0,'default',0,0.000,0.000,0,0,'digital_1','timedate','Europe/Madrid',0,0), + (99,2,178,481,111,111,'','status',0,3600,11556,430,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0), + (100,2,542,481,111,111,'','status',0,3600,13,2,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0), + (101,2,905,481,111,111,'','status',0,3600,114,11,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0), + (102,2,1276,481,111,111,'','status',0,3600,7,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0), + (103,2,1631,482,111,111,'','status',0,3600,11547,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0), + (104,2,157,393,0,0,'

    Backups

    \n

     

    ','white', +4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0), + (105,2,512,382,96,172,'<p style="overflow: hidden;"><span class="visual_font_size_28pt" style="font-family: opensans; color: #ffffff;">DB Status</span></p> <p style="overflow: hidden;">&nbsp;</p>','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0), + (106,2,886,382,0,0,'

    Disk slave

    \n

     

    ','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0), + (107,2,1251,382,0,0,'

    Disk /var

    \n

     

    ','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0), + (108,2,1547,382,0,0,'<p style="line-height: 18px; overflow: hidden;"><span class="visual_font_size_28pt" style="color: #ffffff; font-family: opensans;">Authentification</span></p>','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0), + (109,2,126,820,0,0,'<p style="line-height: 18px; overflow: hidden;"><strong><span class="visual_font_size_36pt" style="font-family: opensans; color: #ffffff;">Processing</span></strong></p>','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0), + (110,2,755,820,0,0,'<p style="line-height: 18px; overflow: hidden;"><strong><span class="visual_font_size_36pt" style="font-family: opensans; color: #ffffff;">Network</span></strong></p>','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0), + (111,2,1281,820,0,0,'<p style="line-height: 18px; overflow: hidden;"><strong><span class="visual_font_size_36pt" style="color: #ffffff; font-family: opensans;">Storage</span></strong></p>','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0) +; diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 17aa3441d9..cdf6610772 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,10 +1,10 @@ package: pandorafms-server -Version: 7.0NG.738-190905 +Version: 7.0NG.738-190923 Architecture: all Priority: optional Section: admin Installed-Size: 640 Maintainer: ÁRTICA ST Homepage: http://pandorafms.org/ -Depends: perl (>= 5.8), libdbi-perl, libdbd-mysql-perl, libtime-format-perl, libnetaddr-ip-perl, libtime-format-perl, libxml-simple-perl, libxml-twig-perl, libhtml-parser-perl, snmp, snmpd, traceroute, xprobe2, nmap, sudo, libwww-perl, libsocket6-perl, libio-socket-inet6-perl, snmp-mibs-downloader, libjson-perl, libnet-telnet-perl, libencode-locale-perl, libgeo-ip-perl +Depends: perl (>= 5.8), libdbi-perl, libdbd-mysql-perl, libtime-format-perl, libnetaddr-ip-perl, libtime-format-perl, libxml-simple-perl, libxml-twig-perl, libhtml-parser-perl, snmp, snmpd, traceroute, xprobe2, nmap, sudo, libwww-perl, libsocket6-perl, libio-socket-inet6-perl, libio-socket-ssl-perl, snmp-mibs-downloader, libjson-perl, libnet-telnet-perl, libencode-locale-perl, libgeo-ip-perl Description: Pandora FMS is a monitoring system for big IT environments. It uses remote tests, or local agents to grab information. Pandora supports all standard OS (Linux, AIX, HP-UX, Solaris and Windows XP,2000/2003), and support multiple setups in HA enviroments. This is the server package. Server makes the remote checks and process information transfer by Pandora FMS agents to the server. diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index fe232eda41..7bb767b956 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.738-190905" +pandora_version="7.0NG.738-190923" package_cpan=0 package_pandora=1 diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index bb177be783..1209922537 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -365,9 +365,11 @@ sub pandora_server_tasks ($) { # COMMON TASKS (master and non-master) # --------------------------------------------------------------- - - # Rotate Log File if (($counter % 30) == 0) { + # Update configuration options from the console. + pandora_get_sharedconfig ($pa_config, $dbh); + + # Rotate the log file. pandora_rotate_logfile($pa_config); # Set event storm protection diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index 33d34082c0..6d92d7417d 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -226,8 +226,9 @@ recon_threads 1 dataserver_threads 1 # mta_address: External Mailer (MTA) IP Address to be used by Pandora FMS internal email capabilities +# If not set, the MTA configuration specified in the Pandora FMS Console will be used. -mta_address localhost +#mta_address localhost # mta_port, this is the mail server port (default 25) @@ -250,6 +251,10 @@ mta_address localhost #mta_from Pandora FMS +# SMTP encryption protocol (none, ssl, starttls) + +#mta_encryption none + # Set 1 if want eMail deliver alert in separate mail (default). # Set 0 if want eMail deliver shared mail by all destination. mail_in_separate 1 diff --git a/pandora_server/conf/pandora_server.conf.windows b/pandora_server/conf/pandora_server.conf.windows index a602f7abc4..c7c5db64b4 100644 --- a/pandora_server/conf/pandora_server.conf.windows +++ b/pandora_server/conf/pandora_server.conf.windows @@ -214,6 +214,7 @@ recon_threads 2 dataserver_threads 2 # mta_address: External Mailer (MTA) IP Address to be used by Pandora FMS internal email capabilities +# If not set, the MTA configuration specified in the Pandora FMS Console will be used. #mta_address localhost @@ -235,6 +236,10 @@ dataserver_threads 2 # probably you need to change it to avoid problems with your antispam #mta_from pandora@sampledomain.com +# SMTP encryption protocol (none, ssl, starttls) + +#mta_encryption none + # xprobe2: Optional package to detect OS types using advanced TCP/IP # fingerprinting tecniques, much more accurates than stadard nmap. # If not provided, nmap is used insted xprobe2 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 9639dc4770..3b77520174 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.738"; -my $pandora_build = "190905"; +my $pandora_build = "190923"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash @@ -187,6 +187,33 @@ sub pandora_get_sharedconfig ($$) { [$dbh] ); $pa_config->{'rb_product_name'} = 'Pandora FMS' unless (defined ($pa_config->{'rb_product_name'}) && $pa_config->{'rb_product_name'} ne ''); + + # Mail transport agent configuration. Local configuration takes precedence. + if ($pa_config->{"mta_local"} eq 0) { + $pa_config->{"mta_address"} = pandora_get_tconfig_token ($dbh, 'email_smtpServer', ''); + $pa_config->{"mta_from"} = '"' . pandora_get_tconfig_token ($dbh, 'email_from_name', 'Pandora FMS') . '" <' . + pandora_get_tconfig_token ($dbh, 'email_from_dir', 'pandora@pandorafms.org') . '>'; + $pa_config->{"mta_pass"} = pandora_get_tconfig_token ($dbh, 'email_password', ''); + $pa_config->{"mta_port"} = pandora_get_tconfig_token ($dbh, 'email_smtpPort', ''); + $pa_config->{"mta_user"} = pandora_get_tconfig_token ($dbh, 'email_username', ''); + $pa_config->{"mta_encryption"} = pandora_get_tconfig_token ($dbh, 'email_encryption', ''); + + # Auto-negotiate the auth mechanism, since it cannot be set from the console. + # Do not include PLAIN, it generates the following error: + # 451 4.5.0 SMTP protocol violation, see RFC 2821 + $pa_config->{"mta_auth"} = 'DIGEST-MD5 CRAM-MD5 LOGIN'; + + # Fix the format of mta_encryption. + if ($pa_config->{"mta_encryption"} eq 'tls') { + $pa_config->{"mta_encryption"} = 'starttls'; + } + elsif ($pa_config->{"mta_encryption"} =~ m/^ssl/) { + $pa_config->{"mta_encryption"} = 'ssl'; + } + else { + $pa_config->{"mta_encryption"} = 'none'; + } + } } ########################################################################## @@ -303,12 +330,14 @@ sub pandora_load_config { $pa_config->{"dynamic_constant"} = 10; # 7.0 # Internal MTA for alerts, each server need its own config. - $pa_config->{"mta_address"} = '127.0.0.1'; # Introduced on 2.0 - $pa_config->{"mta_port"} = '25'; # Introduced on 2.0 + $pa_config->{"mta_address"} = ''; # Introduced on 2.0 + $pa_config->{"mta_port"} = ''; # Introduced on 2.0 $pa_config->{"mta_user"} = ''; # Introduced on 2.0 $pa_config->{"mta_pass"} = ''; # Introduced on 2.0 $pa_config->{"mta_auth"} = 'none'; # Introduced on 2.0 (Support LOGIN PLAIN CRAM-MD5 DIGEST-MD) $pa_config->{"mta_from"} = 'pandora@localhost'; # Introduced on 2.0 + $pa_config->{"mta_encryption"} = 'none'; # 7.0 739 + $pa_config->{"mta_local"} = 0; # 7.0 739 $pa_config->{"mail_in_separate"} = 1; # 1: eMail deliver alert mail in separate mails. # 0: eMail deliver 1 mail with all destination. @@ -582,6 +611,7 @@ sub pandora_load_config { } elsif ($parametro =~ m/^mta_address\s(.*)/i) { $pa_config->{'mta_address'}= clean_blank($1); + $pa_config->{'mta_local'}=1; } elsif ($parametro =~ m/^mta_port\s(.*)/i) { $pa_config->{'mta_port'}= clean_blank($1); @@ -592,6 +622,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^mta_from\s(.*)/i) { $pa_config->{'mta_from'}= clean_blank($1); } + elsif ($parametro =~ m/^mta_encryption\s(.*)/i) { + $pa_config->{'mta_encryption'}= clean_blank($1); + } elsif ($parametro =~ m/^mail_in_separate\s+([0-9]*)/i) { $pa_config->{'mail_in_separate'}= clean_blank($1); } diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index c4bb24d4b1..a45d1108f2 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.738"; -my $pandora_build = "190905"; +my $pandora_build = "190923"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/lib/PandoraFMS/Sendmail.pm b/pandora_server/lib/PandoraFMS/Sendmail.pm index 394add6d1f..08819c78ab 100644 --- a/pandora_server/lib/PandoraFMS/Sendmail.pm +++ b/pandora_server/lib/PandoraFMS/Sendmail.pm @@ -32,7 +32,9 @@ $VERSION = '0.79_16'; 'tz' => '', # only to override automatic detection 'port' => 25, # change it if you always use a non-standard port - 'debug' => 0 # prints stuff to STDERR + 'debug' => 0, # prints stuff to STDERR + 'encryption' => 'none', # no, ssl or starttls + 'timeout' => 5, # timeout for socket reads/writes in seconds ); # ******************************************************************* @@ -54,7 +56,8 @@ use vars qw( $auth_support ); -use Socket; +use IO::Socket::INET; +use IO::Select; use Time::Local; # for automatic time zone detection use Sys::Hostname; # for use of hostname in HELO @@ -62,6 +65,12 @@ use Sys::Hostname; # for use of hostname in HELO $auth_support = 'DIGEST-MD5 CRAM-MD5 PLAIN LOGIN'; +# IO::Socket object. +my $S; + +# IO::Select object. +my $Sel; + # use MIME::QuotedPrint if available and configured in %mailcfg eval("use MIME::QuotedPrint"); $mailcfg{'mime'} &&= (!$@); @@ -178,9 +187,9 @@ sub sendmail { local $_; my (%mail, $k, - $smtp, $server, $port, $connected, $localhost, + $smtp, $server, $port, $localhost, $fromaddr, $recip, @recipients, $to, $header, - %esmtp, @wanted_methods, + %esmtp, @wanted_methods, $encryption ); use vars qw($server_reply); # -------- a few internal subs ---------- @@ -191,7 +200,7 @@ sub sendmail { $error .= "Server said: $server_reply\n"; print STDERR "Server said: $server_reply\n" if $^W; } - close S; + close $S if defined($S); return 0; } @@ -200,31 +209,40 @@ sub sendmail { for $i (0..$#_) { # accept references, so we don't copy potentially big data my $data = ref($_[$i]) ? $_[$i] : \$_[$i]; - if ($mailcfg{'debug'} > 5) { + if ($mailcfg{'debug'} > 9) { if (length($$data) < 500) { - print ">", $$data; + print STDERR ">", $$data; } else { - print "> [...", length($$data), " bytes sent ...]\n"; + print STDERR "> [...", length($$data), " bytes sent ...]\n"; } } - print(S $$data) || return 0; + my @sockets = $Sel->can_write($mailcfg{'timeout'}); + return 0 if (!@sockets); + syswrite($sockets[0], $$data) || return 0; } 1; } sub socket_read { + my $buffer; $server_reply = ""; - do { - $_ = ; - $server_reply .= $_; - #chomp $_; - print "<$_" if $mailcfg{'debug'} > 5; - if (/^[45]/ or !$_) { - chomp $server_reply; - return; # return false - } - } while (/^[\d]+-/); + + while (my @sockets = $Sel->can_read($mailcfg{'timeout'})) { + return if (!@sockets); + # 16kByte is the maximum size of an SSL frame and because sysread + # returns data from only a single SSL frame you can guarantee that + # there are no pending data. + sysread($sockets[0], $buffer, 65535) || return; + $server_reply .= $buffer; + last if ($buffer =~ m/\n$/); + } + + print STDERR "<$server_reply" if $mailcfg{'debug'} > 9; + if ($server_reply =~ /^[45]/) { + chomp $server_reply; + return; # return false + } chomp $server_reply; return $server_reply; } @@ -260,13 +278,15 @@ sub sendmail { } $smtp = $mail{'Smtp'} || $mail{'Server'}; - unshift @{$mailcfg{'smtp'}}, $smtp if ($smtp and $mailcfg{'smtp'}->[0] ne $smtp); + $mailcfg{'smtp'}->[0] = $smtp if ($smtp and $mailcfg{'smtp'}->[0] ne $smtp); + + $encryption = $mail{'Encryption'} || $mail{'Encryption'}; # delete non-header keys, so we don't send them later as mail headers # I like this syntax, but it doesn't seem to work with AS port 5.003_07: # delete @mail{'Smtp', 'Server'}; # so instead: - delete $mail{'Smtp'}; delete $mail{'Server'}; + delete $mail{'Smtp'}; delete $mail{'Server'}; delete $mail{'Encryption'}; $mailcfg{'port'} = $mail{'Port'} || $mailcfg{'port'} || 25; delete $mail{'Port'}; @@ -343,48 +363,36 @@ sub sendmail { $localhost = hostname() || 'localhost'; foreach $server ( @{$mailcfg{'smtp'}} ) { - # open socket needs to be inside this foreach loop on Linux, - # otherwise all servers fail if 1st one fails !??! why? - unless ( socket S, AF_INET, SOCK_STREAM, scalar(getprotobyname 'tcp') ) { - return fail("socket failed ($!)") - } - - print "- trying $server\n" if $mailcfg{'debug'} > 1; + print STDERR "- trying $server\n" if $mailcfg{'debug'} > 9; $server =~ s/\s+//go; # remove spaces just in case of a typo # extract port if server name like "mail.domain.com:2525" $port = ($server =~ s/:(\d+)$//o) ? $1 : $mailcfg{'port'}; $smtp = $server; # save $server for use outside foreach loop - my $smtpaddr = inet_aton $server; - unless ($smtpaddr) { - $error .= "$server not found\n"; - next; # next server + # load IO::Socket SSL if needed + if ($encryption ne 'none') { + eval "require IO::Socket::SSL" || return fail("IO::Socket::SSL is not available"); } - my $retried = 0; # reset retries for each server - while ( ( not $connected = connect S, pack_sockaddr_in($port, $smtpaddr) ) - and ( $retried < $mailcfg{'retries'} ) - ) { - $retried++; - $error .= "connect to $server failed ($!)\n"; - print "- connect to $server failed ($!)\n" if $mailcfg{'debug'} > 1; - print "retrying in $mailcfg{'delay'} seconds...\n" if $mailcfg{'debug'} > 1; - sleep $mailcfg{'delay'}; + if ($encryption ne 'ssl') { + $S = new IO::Socket::INET(PeerPort => $port, PeerAddr => $server, Proto => 'tcp'); } - - if ( $connected ) { - print "- connected to $server\n" if $mailcfg{'debug'} > 3; + else { + $S = new IO::Socket::SSL(PeerPort => $port, PeerAddr => $server, Proto => 'tcp', SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(), Domain => AF_INET); + } + if ( $S ) { + print STDERR "- connected to $server\n" if $mailcfg{'debug'} > 9; last; } else { $error .= "connect to $server failed\n"; - print "- connect to $server failed, next server...\n" if $mailcfg{'debug'} > 1; + print STDERR "- connect to $server failed, next server...\n" if $mailcfg{'debug'} > 9; next; # next server } } - unless ( $connected ) { + unless ( $S ) { return fail("connect to $smtp failed ($!) no (more) retries!") }; @@ -397,8 +405,9 @@ sub sendmail { ; } - my($oldfh) = select(S); $| = 1; select($oldfh); - + $Sel = new IO::Select() || return fail("IO::Select error"); + $Sel->add($S); + socket_read() || return fail("Connection error from $smtp on port $port ($_)"); socket_write("EHLO $localhost$CRLF") @@ -418,8 +427,37 @@ sub sendmail { || return fail("send HELO error (lost connection?)"); } - if ($auth) { - warn "AUTH requested\n" if ($mailcfg{debug} > 4); + # STARTTLS + if ($encryption eq 'starttls') { + defined($esmtp{'STARTTLS'}) + || return fail('STARTTLS not supported'); + socket_write("STARTTLS$CRLF") || return fail("send STARTTLS error"); + socket_read() + || return fail('STARTTLS error'); + IO::Socket::SSL->start_SSL($S, SSL_hostname => $server, SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE()) + || return fail("start_SSL failed"); + + # The client SHOULD send an EHLO command as the + # first command after a successful TLS negotiation. + socket_write("EHLO $localhost$CRLF") + || return fail("send EHLO error (lost connection?)"); + my $ehlo = socket_read(); + if ($ehlo) { + # The server MUST discard any knowledge + # obtained from the client. + %esmtp = (); + + # parse EHLO response + map { + s/^\d+[- ]//; + my ($k, $v) = split /\s+/, $_, 2; + $esmtp{$k} = $v || 1 if $k; + } split(/\n/, $ehlo); + } + } + + if (defined($auth) && $auth->{'user'} ne '') { + warn "AUTH requested\n" if ($mailcfg{debug} > 9); # reduce wanted methods to those supported my @methods = grep {$esmtp{'AUTH'}=~/(^|\s)$_(\s|$)/i} grep {$auth_support =~ /(^|\s)$_(\s|$)/i} @@ -480,9 +518,9 @@ sub sendmail { my $challenge = socket_read() || return fail("AUTH DIGEST-MD5 failed: $server_reply"); $challenge =~ s/^\d+\s+//; $challenge =~ s/[\r\n]+$//; - warn "\nCHALLENGE=", decode_base64($challenge), "\n" if ($mailcfg{debug} > 10); + warn "\nCHALLENGE=", decode_base64($challenge), "\n" if ($mailcfg{debug} > 9); my $response = _digest_md5($auth->{user}, $auth->{password}, decode_base64($challenge), $auth->{realm}); - warn "\nRESPONSE=$response\n" if ($mailcfg{debug} > 10); + warn "\nRESPONSE=$response\n" if ($mailcfg{debug} > 9); socket_write(encode_base64($response, ""), $CRLF) || return fail("AUTH DIGEST-MD5 failed: $server_reply"); my $status = socket_read() @@ -562,7 +600,7 @@ sub sendmail { socket_write("QUIT$CRLF") || return fail("send QUIT error"); socket_read(); - close S; + close $S; return 1; } # end sub sendmail diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 36050e4275..9710913efe 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -140,6 +140,7 @@ our @EXPORT = qw( generate_agent_name_hash long_to_ip ip_to_long + get_enabled_servers ); # ID of the different servers @@ -518,7 +519,14 @@ sub pandora_sendmail { Smtp => $pa_config->{"mta_address"}, Port => $pa_config->{"mta_port"}, From => $pa_config->{"mta_from"}, + Encryption => $pa_config->{"mta_encryption"}, ); + + # Set the timeout. + $PandoraFMS::Sendmail::mailcfg{'timeout'} = $pa_config->{"tcp_timeout"}; + + # Enable debugging. + $PandoraFMS::Sendmail::mailcfg{'debug'} = $pa_config->{"verbosity"}; if (defined($content_type)) { $mail{'Content-Type'} = $content_type; @@ -535,15 +543,12 @@ sub pandora_sendmail { $mail{auth} = {user=>$pa_config->{"mta_user"}, password=>$pa_config->{"mta_pass"}, method=>$pa_config->{"mta_auth"}, required=>1 }; } - if (sendmail %mail) { - return; - } - else { - logger ($pa_config, "[ERROR] Sending email to $to_address with subject $subject", 1); - if (defined($Mail::Sendmail::error)){ - logger ($pa_config, "ERROR Code: $Mail::Sendmail::error", 5); + eval { + if (!sendmail(%mail)) { + logger ($pa_config, "[ERROR] Sending email to $to_address with subject $subject", 1); + logger ($pa_config, "ERROR Code: $Mail::Sendmail::error", 5) if (defined($Mail::Sendmail::error)); } - } + }; } ########################################################################## @@ -2049,6 +2054,25 @@ sub long_to_ip { return inet_ntoa pack("N", ($ip_long)); } +############################################################################### +# Returns a list with enabled servers. +############################################################################### +sub get_enabled_servers { + my $conf = shift; + + if (ref($conf) ne "HASH") { + return (); + } + + my @server_list = map { + if ($_ =~ /server$/i && $conf->{$_} > 0) { + $_ + } else { + } + } keys %{$conf}; + + return @server_list; +} # End of function declaration # End of defined Code diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index ab274c7d02..f2819ac79b 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.738 -%define release 190905 +%define release 190923 Summary: Pandora FMS Server Name: %{name} @@ -27,7 +27,7 @@ Requires: perl(DBI) perl(DBD::mysql) Requires: perl(HTTP::Request::Common) perl(LWP::Simple) perl(LWP::UserAgent) Requires: perl(XML::Simple) perl(XML::Twig) net-snmp-utils Requires: perl(NetAddr::IP) net-snmp net-tools -Requires: perl(IO::Socket::INET6) perl(Net::Telnet) +Requires: perl(IO::Socket::INET6) perl(IO::Socket::SSL) perl(Net::Telnet) Requires: nmap sudo perl(JSON) Requires: perl(Time::HiRes) perl(Encode::Locale) Requires: perl perl(Sys::Syslog) perl(HTML::Entities) perl(Geo::IP) diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 49bd12b3b8..56cbacb03d 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.738 -%define release 190905 +%define release 190923 Summary: Pandora FMS Server Name: %{name} @@ -24,7 +24,7 @@ Provides: %{name}-%{version} Requires: perl-DBI perl-DBD-mysql perl-libwww-perl Requires: perl-NetAddr-IP net-snmp net-tools perl-XML-Twig Requires: nmap sudo perl-HTML-Tree perl-XML-Simple perl-Net-Telnet -Requires: perl-IO-Socket-INET6 perl-Socket6 snmp-mibs perl-JSON +Requires: perl-IO-Socket-INET6 perl-Socket6 perl-IO-Socket-SSL snmp-mibs perl-JSON Requires: perl-Encode-Locale perl-Geo-IP %description diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index ccecb6e6ed..158d1e9deb 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.738" -PI_BUILD="190905" +PI_BUILD="190923" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 9f9b0bd653..427e6817a2 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.738 PS190905"; +my $version = "7.0NG.738 PS190923"; # Pandora server configuration my %conf; @@ -136,7 +136,7 @@ sub pandora_purgedb ($$) { pandora_delete_old_export_data ($dbh, $ulimit_timestamp); # Delete sessions data - pandora_delete_old_session_data ($dbh, $ulimit_timestamp); + pandora_delete_old_session_data (\%conf, $dbh, $ulimit_timestamp); # Delete old inventory data @@ -678,6 +678,7 @@ sub pandora_load_config_pdb ($) { $conf->{'_netflow_nfexpire'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'netflow_nfexpire'"); $conf->{'_netflow_path'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'netflow_path'"); $conf->{'_delete_notinit'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_notinit'"); + $conf->{'_session_timeout'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'session_timeout'"); $conf->{'_big_operation_step_datos_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'big_operation_step_datos_purge'"); $conf->{'_small_operation_step_datos_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'small_operation_step_datos_purge'"); @@ -990,12 +991,28 @@ sub pandora_delete_old_export_data { # Delete old session data. ############################################################################## sub pandora_delete_old_session_data { - my ($dbh, $ulimit_timestamp) = @_; + my ($conf, $dbh, $ulimit_timestamp) = @_; + + my $session_timeout = $conf->{'_session_timeout'}; + + if ($session_timeout ne '') { + if ($session_timeout == -1) { + # The session expires in 10 years + $session_timeout = 315576000; + } else { + $session_timeout *= 60; + } + + $ulimit_timestamp = time() - $session_timeout; + } log_message ('PURGE', "Deleting old session data from tsessions_php\n"); while(db_delete_limit ($dbh, 'tsessions_php', 'last_active < ?', $SMALL_OPERATION_STEP, $ulimit_timestamp) ne '0E0') { usleep (10000); }; + + db_do ($dbh, "DELETE FROM tsessions_php WHERE + data IS NULL OR id_session REGEXP '^cron-'"); } ############################################################################### diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index ab01849bc5..974f7d06c9 100755 --- 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.738 PS190905"; +my $version = "7.0NG.738 PS190923"; # save program name for logging my $progname = basename($0);