From d890d25574910377663212b19f3c0a77d195f75b Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Tue, 26 Mar 2019 15:57:54 +0100 Subject: [PATCH 001/250] Fixed db query bug Former-commit-id: 4eef9808433009c2725956103b4338f70bfe1403 --- .../godmode/reporting/reporting_builder.item_editor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index aef5ac71a2..8fa3b2a219 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -1234,7 +1234,7 @@ $class = 'databox filters'; $all_modules = ''; } else { $all_modules = db_get_all_rows_sql( - 'SELECT DISTINCT nombre, id_agente_modulo FROM + 'SELECT DISTINCT nombre FROM tagente_modulo WHERE id_agente IN ('.implode(',', array_values($id_agents)).')' ); } From 89ff40e2b99451d539a1f2f8aa88446c0a10b871 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Mon, 10 Jun 2019 09:43:27 +0200 Subject: [PATCH 002/250] moved mail server setup to general setup --- .../godmode/setup/setup_general.php | 42 ++++++++++++++ pandora_console/include/functions_config.php | 56 +++++++++---------- 2 files changed, 70 insertions(+), 28 deletions(-) diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 8079aee1e8..eb37a608ea 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -32,6 +32,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 ! switch ($config['dbtype']) { case 'mysql': @@ -296,6 +302,42 @@ 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 dir'); +$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] = __('Server SMTP'); +$table_mail_conf->data[2][1] = html_print_input_text('email_smtpServer', $config['email_smtpServer'], '', 30, 100, true); + +$table_mail_conf->data[3][0] = __('Port SMTP'); +$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); + +html_print_input_hidden('update_config', 1); +html_print_table($table_mail_conf); + echo '
'; echo '
'; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 488d6a28cd..1b5af44a21 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -317,6 +317,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': @@ -407,34 +435,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; From 41d8afaeea8b1b379965e851ac9f3631e2e3c7bf Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Fri, 12 Jul 2019 11:32:56 +0200 Subject: [PATCH 003/250] added summation report uncompressed module cehckbox --- .../reporting_builder.item_editor.php | 20 +++++++++++++++++++ .../godmode/reporting/reporting_builder.php | 9 +++++++++ .../include/functions_reporting.php | 12 ++++++++--- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index ff8ca88e40..9244fd8c27 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -427,6 +427,7 @@ switch ($action) { ); $idAgentModule = $item['id_agent_module']; $period = $item['period']; + $uncompressed_module = $item['uncompressed_module']; break; case 'historical_data': @@ -2769,6 +2770,23 @@ $class = 'databox filters'; ?> + + + + + + + + + + @@ -4498,6 +4516,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(); @@ -4706,6 +4725,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 1e552b112a..43f5c1510b 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1862,6 +1862,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'); @@ -2400,6 +2405,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/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 97766305a2..5861849f1e 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -10654,7 +10654,8 @@ function reporting_get_agentmodule_data_min($id_agent_module, $period=0, $date=0 function reporting_get_agentmodule_data_sum( $id_agent_module, $period=0, - $date=0 + $date=0, + $uncompressed_module=true ) { global $config; @@ -10680,7 +10681,10 @@ 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)) { @@ -10735,7 +10739,9 @@ function reporting_get_agentmodule_data_sum( 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']; From ef9502a552372051f72ce07851503e297e88000e Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Mon, 15 Jul 2019 11:56:57 +0200 Subject: [PATCH 004/250] Fixed errors on sum report uncompressed checkbox --- .../godmode/reporting/reporting_builder.item_editor.php | 4 ++-- pandora_console/include/functions_db.php | 1 + pandora_console/include/functions_reporting.php | 8 +++++--- pandora_console/operation/reporting/reporting_viewer.php | 2 +- pandora_console/pandoradb.sql | 1 + 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 9244fd8c27..52a4852d2d 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': @@ -811,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 '
'; @@ -2782,7 +2782,7 @@ $class = 'databox filters'; diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 3efbf59628..6bec03c9c2 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -520,6 +520,7 @@ function db_get_sql($sql, $field=0, $search_history_db=false) * Get all the result rows using an SQL statement. * * @param string SQL statement to execute. + global $config; * @param bool If want to search in history database also * @param bool If want to use cache (true by default) * diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 5861849f1e..9382cfb938 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -4879,7 +4879,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; @@ -10648,6 +10649,7 @@ 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. */ @@ -10694,7 +10696,7 @@ function reporting_get_agentmodule_data_sum( // Incremental modules are treated differently $module_inc = is_module_inc($module_name); - if ($uncompressed_module) { + if (!$uncompressed_module) { // Get module data $interval_data = db_get_all_rows_sql( ' @@ -10739,7 +10741,7 @@ function reporting_get_agentmodule_data_sum( break; } - if ($uncompressed_module) { + if (!$uncompressed_module) { $total += $data['datos']; } else if (!$module_inc) { foreach ($data['data'] as $val) { diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index e8431ddeb2..96431e9791 100755 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -17,7 +17,7 @@ global $config; check_login(); enterprise_hook('open_meta_frame'); - +hd($_POST); $id_report = (int) get_parameter('id'); if (! $id_report) { diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 95d6caadfd..9f9020990e 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 '1', PRIMARY KEY(`id_rc`), FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`) ON UPDATE CASCADE ON DELETE CASCADE From 53c239f55833c05f5544ce0f30f00a25bd135f5c Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Wed, 17 Jul 2019 10:34:56 +0200 Subject: [PATCH 005/250] fixed minor errors --- pandora_console/include/functions_db.php | 1 - pandora_console/operation/reporting/reporting_viewer.php | 1 - 2 files changed, 2 deletions(-) diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 6bec03c9c2..3efbf59628 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -520,7 +520,6 @@ function db_get_sql($sql, $field=0, $search_history_db=false) * Get all the result rows using an SQL statement. * * @param string SQL statement to execute. - global $config; * @param bool If want to search in history database also * @param bool If want to use cache (true by default) * diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index 96431e9791..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'); -hd($_POST); $id_report = (int) get_parameter('id'); if (! $id_report) { From 4e927e1ee59750b6685123a7991135f7d8e5c45c Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Thu, 1 Aug 2019 10:36:15 +0200 Subject: [PATCH 006/250] Fixed bad image for warning status - #4454 --- pandora_console/include/class/TreeService.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php index 2316714031..ffa542d995 100644 --- a/pandora_console/include/class/TreeService.class.php +++ b/pandora_console/include/class/TreeService.class.php @@ -104,7 +104,7 @@ class TreeService extends Tree break; case SERVICE_STATUS_WARNING: - $processed_items[$row['id']][$key]['statusImageHTML'] = 'WARNING status.'; + $processed_items[$row['id']]['statusImageHTML'] = 'WARNING status.'; break; case SERVICE_STATUS_UNKNOWN: From 9b8e3c540cbf86f0eb295b250c5a1f6738122990 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Mon, 5 Aug 2019 13:42:01 +0200 Subject: [PATCH 007/250] created integria integration setup --- pandora_console/godmode/setup/setup.php | 4 + .../godmode/setup/setup_integria.php | 262 ++++++++++++++++++ pandora_console/include/functions_config.php | 35 +++ 3 files changed, 301 insertions(+) create mode 100644 pandora_console/godmode/setup/setup_integria.php diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index c32f128ddd..595cfb1d14 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -228,6 +228,10 @@ switch ($section) { include_once $config['homedir'].'/godmode/setup/setup_ehorus.php'; break; + case 'integria': + include_once $config['homedir'].'/godmode/setup/setup_integria.php'; + break; + case 'notifications': include_once $config['homedir'].'/godmode/setup/setup_notifications.php'; break; diff --git a/pandora_console/godmode/setup/setup_integria.php b/pandora_console/godmode/setup/setup_integria.php new file mode 100644 index 0000000000..42f4f7fd57 --- /dev/null +++ b/pandora_console/godmode/setup/setup_integria.php @@ -0,0 +1,262 @@ +data = []; +$table_enable->width = '100%'; +$table_enable->id = 'integria-enable-setup'; +$table_enable->class = 'databox filters'; +$table_enable->size['name'] = '30%'; +$table_enable->style['name'] = 'font-weight: bold'; + +// Enable Integria. +$row = []; +$row['name'] = __('Enable Integria'); +$row['control'] = html_print_checkbox_switch('integria_enabled', 1, $config['integria_enabled'], true); +$table_enable->data['integria_enabled'] = $row; + +// Remote config table. +$table_remote = new StdClass(); +$table_remote->data = []; +$table_remote->width = '100%'; +$table_remote->styleTable = 'margin-bottom: 10px;'; +$table_remote->id = 'integria-remote-setup'; +$table_remote->class = 'databox filters'; +$table_remote->size['name'] = '30%'; +$table_remote->style['name'] = 'font-weight: bold'; + +// User. +$row = []; +$row['name'] = __('User'); +$row['control'] = html_print_input_text('integria_user', $config['integria_user'], '', 30, 100, true); +$table_remote->data['integria_user'] = $row; + +// Pass. +$row = []; +$row['name'] = __('Password'); +$row['control'] = html_print_input_password('integria_pass', io_output_password($config['integria_pass']), '', 30, 100, true); +$table_remote->data['integria_pass'] = $row; + +// Directory hostname. +$row = []; +$row['name'] = __('API Hostname'); +$row['control'] = html_print_input_text('integria_hostname', $config['integria_hostname'], '', 30, 100, true); +$row['control'] .= ui_print_help_tip(__('Hostname of the Integria API')); +$table_remote->data['integria_hostname'] = $row; + +// Request timeout. +$row = []; +$row['name'] = __('Request timeout'); +$row['control'] = html_print_input_text('integria_req_timeout', $config['integria_req_timeout'], '', 3, 10, true); +$row['control'] .= ui_print_help_tip(__('Time in seconds to set the maximum time of the requests to the Integria API').'. '.__('0 to disable'), true); +$table_remote->data['integria_req_timeout'] = $row; + +// Test. +$row = []; +$row['name'] = __('Test'); +$row['control'] = html_print_button(__('Start'), 'test-integria', false, '', 'class="sub next"', true); +$row['control'] .= ''; +$row['control'] .= ''; +$row['control'] .= ''; +$row['control'] .= ' '; +$table_remote->data['integria_test'] = $row; + +hd($config['integria_enabled']); +hd($config['integria_user']); +hd($config['integria_user']); +hd($config['integria_pass']); +hd($config['integria_hostname']); +hd($config['integria_req_timeout']); + +// Print. +echo '
'; +echo ''; +html_print_image('include/ehorus/images/ehorus-logo-grey.png'); +echo ''; +echo '
'; +echo '
'; +echo __('Remote Management System'); +echo '
'; +echo ''; +echo 'https://ehorus.com'; +echo ''; +echo '
'; + +echo ""; +// Form enable. +echo '
'; +html_print_input_hidden('update_config', 1); +html_print_table($table_enable); +echo '
'; + +// Form remote. + echo '
'; + echo '
'; + echo ''.__('Integria API').''; + html_print_input_hidden('update_config', 1); + html_print_table($table_remote); + + echo '
'; + echo '
'; + echo '
'; + html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"'); + echo '
'; + echo ''; + +?> + + diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index f59061a03c..544f08abc6 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1434,6 +1434,28 @@ function config_update_config() } break; + case 'integria': + if (!config_update_value('integria_enabled', (int) get_parameter('integria_enabled', 0))) { + $error_update[] = __('Enable Integria'); + } + + if (!config_update_value('integria_user', (string) get_parameter('integria_user', $config['integria_user']))) { + $error_update[] = __('Integria user'); + } + + if (!config_update_value('integria_pass', io_input_password((string) get_parameter('integria_pass', $config['integria_pass'])))) { + $error_update[] = __('Integria password'); + } + + if (!config_update_value('integria_hostname', (string) get_parameter('integria_hostname', $config['integria_hostname']))) { + $error_update[] = __('integria API hostname'); + } + + if (!config_update_value('integria_req_timeout', (int) get_parameter('integria_req_timeout', $config['integria_req_timeout']))) { + $error_update[] = __('Integria request timeout'); + } + break; + default: // Ignore. break; @@ -2820,6 +2842,19 @@ function config_process_config() } } + // Integria + if (!isset($config['integria_enabled'])) { + config_update_value('integria_enabled', 0); + } + + if (!isset($config['integria_req_timeout'])) { + config_update_value('integria_req_timeout', 5); + } + + if (!isset($config['integria_hostname'])) { + config_update_value('integria_hostname', ''); + } + // Finally, check if any value was overwritten in a form. config_update_config(); } From 28cf43498e2d42b087576c6dc873a892a907bcbd Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Mon, 5 Aug 2019 14:18:23 +0200 Subject: [PATCH 008/250] lint change --- pandora_console/include/functions_config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 544f08abc6..21267f3dac 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -2842,7 +2842,7 @@ function config_process_config() } } - // Integria + // Integria. if (!isset($config['integria_enabled'])) { config_update_value('integria_enabled', 0); } From 97353bbfed2ad53a37cc65ec0f4c8ff677fec48b Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Thu, 8 Aug 2019 13:36:12 +0200 Subject: [PATCH 009/250] backup changes --- .../godmode/setup/setup_integria.php | 30 +- .../configure_integriaims_incident.php | 435 ++++++++++++++++++ pandora_console/operation/menu.php | 1 + 3 files changed, 458 insertions(+), 8 deletions(-) create mode 100644 pandora_console/operation/incidents/configure_integriaims_incident.php diff --git a/pandora_console/godmode/setup/setup_integria.php b/pandora_console/godmode/setup/setup_integria.php index 42f4f7fd57..29a1b199f7 100644 --- a/pandora_console/godmode/setup/setup_integria.php +++ b/pandora_console/godmode/setup/setup_integria.php @@ -28,6 +28,25 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user return; } +hd(get_parameter('update_config', 0)); + +if (get_parameter('update_config', 0) == 1) { + // Try to retrieve event response 'Create incident in IntegriaIMS from event' to check if it exists. + $row = db_get_row_filter('tevent_response', ['name' => 'Create incident in IntegriaIMS from event']); + + if ($config['integria_enabled'] == 1) { + if ($row === false) { + // Create 'Create incident in IntegriaIMS from event' event response only when user enables IntegriaIMS integration and it does not exist in database. + db_process_sql_insert('tevent_response', ['name' => 'Create incident in IntegriaIMS from event', 'description' => 'Create an incident in IntegriaIMS from an event', 'target' => 'index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&from_event=_event_id_', 'type' => 'url', 'id_group' => '0', 'modal_width' => '0', 'modal_height' => '0', 'new_window' => '1', 'params' => '', 'server_to_exec' => '0']); + } + } else { + if ($row != false) { + // Delete 'Create incident in IntegriaIMS from event' event response if it does exist and IntegriaIMS integration is disabled + db_process_sql_delete('tevent_response', ['name' => 'Create incident in IntegriaIMS from event']); + } + } +} + // Enable table. $table_enable = new StdClass(); $table_enable->data = []; @@ -173,7 +192,6 @@ if(!$('input:checkbox[name="integria_enabled"]').is(':checked')) $('input:checkbox[name="integria_enabled"]').change(handleEnable); -//aqui var handleTest = function (event) { var user = $('input#text-integria_user').val(); var pass = $('input#password-integria_pass').val(); @@ -217,16 +235,12 @@ if(!$('input:checkbox[name="integria_enabled"]').is(':checked')) hideFailureImage(); hideMessage(); showLoadingImage(); - + console.log(host); $.ajax({ - url: 'https://' + host + '/login', + url: 'http://' + host, type: 'POST', dataType: 'json', - timeout: timeout ? timeout * 1000 : 0, - data: { - user: user, - pass: pass - } + timeout: timeout ? timeout * 1000 : 0 }) .done(function(data, textStatus, xhr) { showSuccessImage(); diff --git a/pandora_console/operation/incidents/configure_integriaims_incident.php b/pandora_console/operation/incidents/configure_integriaims_incident.php new file mode 100644 index 0000000000..8d103b0926 --- /dev/null +++ b/pandora_console/operation/incidents/configure_integriaims_incident.php @@ -0,0 +1,435 @@ +width = '100%'; +$table->id = 'add_alert_table'; +$table->class = 'databox filters'; +$table->head = []; + +$table->data = []; +$table->size = []; +$table->size = []; +$table->size[0] = '15%'; +$table->size[1] = '90%'; + +$table->data[0][0] = __('Group'); +$table->data[0][1] = html_print_select( + $templates, + 'group', + '', + '', + __('Select'), + 0, + true, + false, + true, + '', + false +); + +$table->data[1][0] = __('Default Criticity'); +$table->data[1][1] = html_print_select( + $templates, + 'default_criticity', + '', + '', + __('Select'), + 0, + true, + false, + true, + '', + false +); + +$table->data[2][0] = __('Default Owner'); +$table->data[2][1] = html_print_select( + $templates, + 'default_owner', + '', + '', + __('Select'), + 0, + true, + false, + true, + '', + false +); + +$table->data[0][2] = __('Incident Type'); +$table->data[0][3] = html_print_select( + $templates, + 'incident_type', + '', + '', + __('Select'), + 0, + true, + false, + true, + '', + false +); + +$table->data[1][2] = __('Incident title'); +$table->data[1][3] = html_print_input_text( + 'incident_title', + $reportName, + __('Name'), + 50, + 100, + true, + false, + true +); + +$table->data[2][2] = __('Incident content'); +$table->data[2][3] = html_print_input_text( + 'incident_content', + $reportName, + '', + 50, + 100, + true, + false, + true +); + +echo '
'; +html_print_table($table); +html_print_submit_button(__('Create'), 'accion', false, 'class="sub wand"'); +echo '
'; + + +function integria_api_call($api_url, $user, $user_pass, $api_pass, $operation, $params_array) +{ + $params_string = implode(',', $params_array); + + $url_data = [ + 'user' => $user, + 'user_pass' => $user_pass, + 'pass' => $api_pass, + 'op' => $operation, + 'params' => $params_string, + ]; + + $url = sprintf( + "$api_url%s", + http_build_query($url_data, '', '&') + ); + + hd($url); + // ob_start(); + // $out = fopen('php://output', 'w'); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + // curl_setopt($ch, CURLOPT_VERBOSE, true); + // curl_setopt($ch, CURLOPT_STDERR, $out); + $result = curl_exec($ch); + + // fclose($out); + // $debug = ob_get_clean(); + // hd($debug); + $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE); + + hd('http status: '.$http_status); + + $error = false; + + if ($result === false) { + $error = curl_error($ch); + } + + curl_close($ch); + + if ($error !== false || $http_status !== 200) { + if ($error !== false) { + ui_print_error_message(__('API request failed. Please check Integria\'s access credentials in Pandora setup.')); + } else { + // MOSTRAR MENSAJE DE EXITO EN LA PAGINA + } + + return; + } +} + + +/** + * Replace macros. + * If server_id > 0, it's a metaconsole query. + * + * @param integer $event_id Event identifier. + * @param integer $response_id Event response identifier. + * @param integer $server_id Node identifier (for metaconsole). + * @param boolean $history Use the history database or not. + * + * @return string The response text with the macros applied. + */ +function event_response_get_macro( + int $event_id, + $value +) { + include_once 'include/functions_events.php'; + + global $config; + + // If server_id > 0, it's a metaconsole query. + // $meta = $server_id > 0 || is_metaconsole(); + $meta = false; + $event = db_get_row('tevento', 'id_evento', $event_id); + + // $event_response = db_get_row('tevent_response', 'id', $response_id); + $target = io_safe_output($event_response['target']); + + // Substitute each macro. + if (strpos($target, '_agent_address_') !== false) { + if ($meta) { + $agente_table_name = 'tmetaconsole_agent'; + $filter = [ + 'id_tagente' => $event['id_agente'], + 'id_tmetaconsole_setup' => $server_id, + ]; + } else { + $agente_table_name = 'tagente'; + $filter = ['id_agente' => $event['id_agente']]; + } + + $ip = db_get_value_filter('direccion', $agente_table_name, $filter); + // If agent has not an IP, display N/A. + if ($ip === false) { + $ip = __('N/A'); + } + + $return = str_replace('_agent_address_', $ip, $value); + } + + if (strpos($target, '_agent_id_') !== false) { + $target = str_replace('_agent_id_', $event['id_agente'], $target); + } + + if ((strpos($target, '_module_address_') !== false) + || (strpos($target, '_module_name_') !== false) + ) { + if ($event['id_agentmodule'] !== 0) { + if ($meta) { + $server = metaconsole_get_connection_by_id($server_id); + metaconsole_connect($server); + } + + $module = db_get_row('tagente_modulo', 'id_agente_modulo', $event['id_agentmodule']); + if (empty($module['ip_target'])) { + $module['ip_target'] = __('N/A'); + } + + $target = str_replace('_module_address_', $module['ip_target'], $target); + if (empty($module['nombre'])) { + $module['nombre'] = __('N/A'); + } + + $target = str_replace( + '_module_name_', + io_safe_output($module['nombre']), + $target + ); + + if ($meta) { + metaconsole_restore_db(); + } + } else { + $target = str_replace('_module_address_', __('N/A'), $target); + $target = str_replace('_module_name_', __('N/A'), $target); + } + } + + if (strpos($target, '_event_id_') !== false) { + $target = str_replace('_event_id_', $event['id_evento'], $target); + } + + if (strpos($target, '_user_id_') !== false) { + if (!empty($event['id_usuario'])) { + $target = str_replace('_user_id_', $event['id_usuario'], $target); + } else { + $target = str_replace('_user_id_', __('N/A'), $target); + } + } + + if (strpos($target, '_group_id_') !== false) { + $target = str_replace('_group_id_', $event['id_grupo'], $target); + } + + if (strpos($target, '_group_name_') !== false) { + $target = str_replace( + '_group_name_', + groups_get_name($event['id_grupo'], true), + $target + ); + } + + if (strpos($target, '_event_utimestamp_') !== false) { + $target = str_replace( + '_event_utimestamp_', + $event['utimestamp'], + $target + ); + } + + if (strpos($target, '_event_date_') !== false) { + $target = str_replace( + '_event_date_', + date($config['date_format'], $event['utimestamp']), + $target + ); + } + + if (strpos($target, '_event_text_') !== false) { + $target = str_replace( + '_event_text_', + events_display_name($event['evento']), + $target + ); + } + + if (strpos($target, '_event_type_') !== false) { + $target = str_replace( + '_event_type_', + events_print_type_description($event['event_type'], true), + $target + ); + } + + if (strpos($target, '_alert_id_') !== false) { + $target = str_replace( + '_alert_id_', + empty($event['is_alert_am']) ? __('N/A') : $event['is_alert_am'], + $target + ); + } + + if (strpos($target, '_event_severity_id_') !== false) { + $target = str_replace('_event_severity_id_', $event['criticity'], $target); + } + + if (strpos($target, '_event_severity_text_') !== false) { + $target = str_replace( + '_event_severity_text_', + get_priority_name($event['criticity']), + $target + ); + } + + if (strpos($target, '_module_id_') !== false) { + $target = str_replace('_module_id_', $event['id_agentmodule'], $target); + } + + if (strpos($target, '_event_tags_') !== false) { + $target = str_replace('_event_tags_', $event['tags'], $target); + } + + if (strpos($target, '_event_extra_id_') !== false) { + if (empty($event['id_extra'])) { + $target = str_replace('_event_extra_id_', __('N/A'), $target); + } else { + $target = str_replace('_event_extra_id_', $event['id_extra'], $target); + } + } + + if (strpos($target, '_event_source_') !== false) { + $target = str_replace('_event_source_', $event['source'], $target); + } + + if (strpos($target, '_event_instruction_') !== false) { + $target = str_replace( + '_event_instruction_', + events_display_instructions($event['event_type'], $event, false), + $target + ); + } + + if (strpos($target, '_owner_user_') !== false) { + if (empty($event['owner_user'])) { + $target = str_replace('_owner_user_', __('N/A'), $target); + } else { + $target = str_replace('_owner_user_', $event['owner_user'], $target); + } + } + + if (strpos($target, '_event_status_') !== false) { + $event_st = events_display_status($event['estado']); + $target = str_replace('_event_status_', $event_st['title'], $target); + } + + if (strpos($target, '_group_custom_id_') !== false) { + $group_custom_id = db_get_value_sql( + sprintf( + 'SELECT custom_id FROM tgrupo WHERE id_grupo=%s', + $event['id_grupo'] + ) + ); + $event_st = events_display_status($event['estado']); + $target = str_replace('_group_custom_id_', $group_custom_id, $target); + } + + // Parse the event custom data. + if (!empty($event['custom_data'])) { + $custom_data = json_decode(base64_decode($event['custom_data'])); + foreach ($custom_data as $key => $value) { + $target = str_replace('_customdata_'.$key.'_', $value, $target); + } + } + + // This will replace the macro with the current logged user. + if (strpos($target, '_current_user_') !== false) { + $target = str_replace('_current_user_', $config['id_user'], $target); + } + + return $target; +} diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 936cb6a814..194b594e8d 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -479,6 +479,7 @@ if (check_acl($config['id_user'], 0, 'IR') $sub2 = []; $sub2['operation/incidents/incident']['text'] = __('List of Incidents'); $sub2[$sec2sub]['text'] = __('Statistics'); + $sub2['operation/incidents/configure_integriaims_incident']['text'] = __('Create Integria IMS Incident'); $sub[$sec2]['sub2'] = $sub2; $sec2 = $temp_sec2; From adbb48ab87d45adb85eae88da47e8e56511ba1c6 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Sat, 10 Aug 2019 02:13:01 +0200 Subject: [PATCH 010/250] pandora HA review --- pandora_console/extras/mr/31.sql | 9 +++ .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 15 ++-- .../general/firts_task/HA_cluster_builder.php | 69 +++++++------------ pandora_console/include/constants.php | 18 +++++ pandora_console/include/functions_agents.php | 51 ++++++++++++++ pandora_console/include/functions_db.php | 19 +++++ pandora_console/include/functions_html.php | 4 +- pandora_console/include/functions_ui.php | 1 + pandora_console/include/javascript/pandora.js | 4 +- pandora_console/include/styles/pandora.css | 3 + pandora_console/pandoradb.sql | 15 ++-- 11 files changed, 148 insertions(+), 60 deletions(-) diff --git a/pandora_console/extras/mr/31.sql b/pandora_console/extras/mr/31.sql index 3e527bff53..6a743c38fc 100644 --- a/pandora_console/extras/mr/31.sql +++ b/pandora_console/extras/mr/31.sql @@ -9,4 +9,13 @@ DELETE FROM `tconfig` WHERE `token` LIKE 'integria_api_password'; DELETE FROM `tconfig` WHERE `token` LIKE 'integria_inventory'; DELETE FROM `tconfig` WHERE `token` LIKE 'integria_url'; +ALTER TABLE `tdatabase` MODIFY `last_error` text; +ALTER TABLE `tdatabase` MODIFY `host` VARCHAR(255); +ALTER TABLE `tdatabase` ADD COLUMN `label` VARCHAR(255); +ALTER TABLE `tdatabase` MODIFY `os_user` VARCHAR(255); +ALTER TABLE `tdatabase` MODIFY `db_port` INT UNSIGNED NOT NULL; +ALTER TABLE `tdatabase` MODIFY `os_port` INT UNSIGNED NOT NULL; +ALTER TABLE `tdatabase` ADD COLUMN `ssh_key` TEXT; +ALTER TABLE `tdatabase` ADD COLUMN `ssh_pubkey` TEXT; + COMMIT; \ No newline at end of file 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 964441c6c1..a588b7809b 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 default 22, + `os_user` VARCHAR(255) default '', + `db_port` int unsigned 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 ; 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/include/constants.php b/pandora_console/include/constants.php index 899b5b609b..da6c9b23f2 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -624,3 +624,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_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 fc704e2d46..b5955630b8 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1570,6 +1570,7 @@ function html_print_input_image($name, $src, $value, $style='', $return=false, $ 'onkeypress', 'onkeydown', 'onkeyup', + 'class', ]; foreach ($attrs as $attribute) { @@ -3152,7 +3153,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_ui.php b/pandora_console/include/functions_ui.php index b511481dc6..92bf680a4d 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -2678,6 +2678,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/styles/pandora.css b/pandora_console/include/styles/pandora.css index 8c12d11d04..5aacc90075 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; } diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index d1de66ab07..8436624366 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -2438,14 +2438,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 default 22, + `os_user` VARCHAR(255) default '', + `db_port` int unsigned 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 ; From 62ec37cf59c8e717b14c8b480f0e22db9ade4e16 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Sat, 10 Aug 2019 03:18:45 +0200 Subject: [PATCH 011/250] propagate tdatabase updates --- pandora_console/extras/mr/31.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/extras/mr/31.sql b/pandora_console/extras/mr/31.sql index 6a743c38fc..23076c9daa 100644 --- a/pandora_console/extras/mr/31.sql +++ b/pandora_console/extras/mr/31.sql @@ -18,4 +18,6 @@ ALTER TABLE `tdatabase` MODIFY `os_port` INT UNSIGNED NOT NULL; ALTER TABLE `tdatabase` ADD COLUMN `ssh_key` TEXT; ALTER TABLE `tdatabase` ADD COLUMN `ssh_pubkey` TEXT; +UPDATE `tdatabase` set `label`=`host`; + COMMIT; \ No newline at end of file From bdee45c2dd20816e5e649848f4e79fb506973e05 Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Mon, 12 Aug 2019 14:24:26 +0200 Subject: [PATCH 012/250] Fixed duplicated names - #4280 --- pandora_console/include/functions_menu.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index 98191d231f..a6af269e53 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -544,9 +544,9 @@ function menu_add_extras(&$menu) $menu_extra['estado']['sub']['godmode/snmpconsole/snmp_alert']['text'] = __('SNMP alerts'); $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']['godmode/snmpconsole/snmp_trap_generator']['text'] = __('SNMP trap generator'); - $menu_extra['estado']['sub']['snmpconsole']['sub2']['operation/snmpconsole/snmp_view']['text'] = __('SNMP console'); + $menu_extra['estado']['sub']['operation/snmpconsole/snmp_view']['text'] = __('SNMP console'); $menu_extra['workspace']['sub']['operation/incidents/incident_detail']['text'] = __('Manage incident'); From d46e013567680d9891e03c6175eb9b8ad70a665c Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Mon, 19 Aug 2019 14:29:04 +0200 Subject: [PATCH 013/250] =?UTF-8?q?fixed=20visual=20error!=20=C3=A72?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../godmode/agentes/agent_wizard.wmi_explorer.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 From e71bb2a791470ea7bd3940da2593c1741409b4f3 Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Tue, 27 Aug 2019 16:01:18 +0200 Subject: [PATCH 014/250] Long custom fields urls and text truncated --- pandora_console/include/functions_ui.php | 26 +++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 008c05b8d7..b9af85318c 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -39,7 +39,7 @@ if (isset($config['homedir'])) { /** - * Transform bbcode to HTML. + * Transform bbcode to HTML and truncate log. * * @param string $text Text. * @param array $allowed_tags Allowed_tags. @@ -48,16 +48,22 @@ if (isset($config['homedir'])) { */ function ui_bbcode_to_html($text, $allowed_tags=['[url]']) { - if (array_search('[url]', $allowed_tags) !== false) { - // If link hasn't http, add it. - if (preg_match('/https?:\/\//', $text)) { - $html_bbcode = '$2'; - } else { - $html_bbcode = '$2'; - } - + if (array_search('[url]', $allowed_tags) !== false || a) { // Replace bbcode format [url=www.example.org] String [/url] with or without http and slashes - $return = preg_replace('/\[url(?|](((?:https?:\/\/)?[^[]+))|(?:=[\'"]?((?:https?:\/\/)?[^]]+?)[\'"]?)](.+?))\[\/url]/', $html_bbcode, $text); + preg_match('/\[url(?|](((?:https?:\/\/)?[^[]+))|(?:=[\'"]?((?:https?:\/\/)?[^]]+?)[\'"]?)](.+?))\[\/url]/', $text, $matches); + if ($matches) { + $url = $matches[1]; + // Truncate text + $t_text = ui_print_truncate_text($matches[2]); + // If link hasn't http, add it. + if (preg_match('/https?:\/\//', $text)) { + $return = ''.$t_text.''; + } else { + $return = ''.$t_text.''; + } + } else { + $return = ui_print_truncate_text($text); + } } return $return; From a9e02bbb41a095fb92d32c52d46ef4039621a3c7 Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Thu, 29 Aug 2019 12:40:13 +0200 Subject: [PATCH 015/250] Changed permissions to delete traps to IM - #4567 --- pandora_console/operation/snmpconsole/snmp_view.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/operation/snmpconsole/snmp_view.php b/pandora_console/operation/snmpconsole/snmp_view.php index c7f69b4109..7068e296d9 100755 --- a/pandora_console/operation/snmpconsole/snmp_view.php +++ b/pandora_console/operation/snmpconsole/snmp_view.php @@ -921,7 +921,7 @@ if ($traps !== false) { } } else { $agent_trap_group = db_get_value('id_grupo', 'tagente', 'nombre', $trap['source']); - if ((check_acl($config['id_user'], $agent_trap_group, 'AW'))) { + if ((check_acl($config['id_user'], $agent_trap_group, 'IM'))) { $data[8] .= ''.html_print_image('images/cross.png', true, ['border' => '0', 'title' => __('Delete')]).' '; } } From e4a69dc849e97ee2104fe6092776611a25417f11 Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Fri, 30 Aug 2019 15:28:06 +0200 Subject: [PATCH 016/250] Fixed CSV custom graphs export --- .../include/graphs/flot/jquery.flot.exportdata.pandora.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/graphs/flot/jquery.flot.exportdata.pandora.js b/pandora_console/include/graphs/flot/jquery.flot.exportdata.pandora.js index 5bc3ef32b1..0b745d8ff5 100644 --- a/pandora_console/include/graphs/flot/jquery.flot.exportdata.pandora.js +++ b/pandora_console/include/graphs/flot/jquery.flot.exportdata.pandora.js @@ -159,10 +159,9 @@ if (custom_graph) { dataObject = retrieveDataOject(dataObjects,0); - //dataObjects.forEach(function (element) { - //elements.push(processDataObject(element)); - //}); - elements.push(processDataObject(dataObject)); + dataObjects.forEach(function (element) { + elements.push(processDataObject(element)); + }); graphData = elements; } else { From 33da6fd153c3f732177034c3cfb6de5e21f7a235 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 2 Sep 2019 12:33:49 +0200 Subject: [PATCH 017/250] Available in metaconsole sql charts in reports for metaconsole server --- pandora_console/include/functions_graph.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index d0e844c3bf..5ee7ee2a93 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -3596,7 +3596,7 @@ function graph_custom_sql_graph( $sql = io_safe_output($sql['sql']); } - if (($config['metaconsole'] == 1) && defined('METACONSOLE')) { + if (($config['metaconsole'] == 1) && defined('METACONSOLE') && $report_content['server_name'] != '' && $report_content['server_name'] != '0') { $metaconsole_connection = enterprise_hook('metaconsole_get_connection', [$report_content['server_name']]); if ($metaconsole_connection === false) { @@ -3611,7 +3611,7 @@ function graph_custom_sql_graph( $data_result = db_get_all_rows_sql($sql, $historical_db); - if (($config['metaconsole'] == 1) && defined('METACONSOLE')) { + if (($config['metaconsole'] == 1) && defined('METACONSOLE') && $report_content['server_name'] != '' && $report_content['server_name'] != '0') { enterprise_hook('metaconsole_restore_db'); } From 5c535514e16b2cdcf12c1394d3f2a0d3fdfdfdbc Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 2 Sep 2019 15:44:48 +0200 Subject: [PATCH 018/250] Updated MR reference --- pandora_console/extras/mr/31.sql | 11 ----------- pandora_console/extras/mr/32.sql | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 pandora_console/extras/mr/32.sql diff --git a/pandora_console/extras/mr/31.sql b/pandora_console/extras/mr/31.sql index 23076c9daa..3e527bff53 100644 --- a/pandora_console/extras/mr/31.sql +++ b/pandora_console/extras/mr/31.sql @@ -9,15 +9,4 @@ DELETE FROM `tconfig` WHERE `token` LIKE 'integria_api_password'; DELETE FROM `tconfig` WHERE `token` LIKE 'integria_inventory'; DELETE FROM `tconfig` WHERE `token` LIKE 'integria_url'; -ALTER TABLE `tdatabase` MODIFY `last_error` text; -ALTER TABLE `tdatabase` MODIFY `host` VARCHAR(255); -ALTER TABLE `tdatabase` ADD COLUMN `label` VARCHAR(255); -ALTER TABLE `tdatabase` MODIFY `os_user` VARCHAR(255); -ALTER TABLE `tdatabase` MODIFY `db_port` INT UNSIGNED NOT NULL; -ALTER TABLE `tdatabase` MODIFY `os_port` INT UNSIGNED NOT NULL; -ALTER TABLE `tdatabase` ADD COLUMN `ssh_key` TEXT; -ALTER TABLE `tdatabase` ADD COLUMN `ssh_pubkey` TEXT; - -UPDATE `tdatabase` set `label`=`host`; - COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/mr/32.sql b/pandora_console/extras/mr/32.sql new file mode 100644 index 0000000000..dd99e7b9d9 --- /dev/null +++ b/pandora_console/extras/mr/32.sql @@ -0,0 +1,14 @@ +START TRANSACTION + +ALTER TABLE `tdatabase` MODIFY `last_error` text; +ALTER TABLE `tdatabase` MODIFY `host` VARCHAR(255); +ALTER TABLE `tdatabase` ADD COLUMN `label` VARCHAR(255); +ALTER TABLE `tdatabase` MODIFY `os_user` VARCHAR(255); +ALTER TABLE `tdatabase` MODIFY `db_port` INT UNSIGNED NOT NULL; +ALTER TABLE `tdatabase` MODIFY `os_port` INT UNSIGNED NOT NULL; +ALTER TABLE `tdatabase` ADD COLUMN `ssh_key` TEXT; +ALTER TABLE `tdatabase` ADD COLUMN `ssh_pubkey` TEXT; + +UPDATE `tdatabase` set `label`=`host`; + +COMMIT \ No newline at end of file From 11cb53582cbac3dfa95e23f3f96cd01e841aa895 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Mon, 2 Sep 2019 17:01:41 +0200 Subject: [PATCH 019/250] backup changes --- pandora_console/godmode/menu.php | 3 + pandora_console/godmode/setup/setup.php | 11 + .../godmode/setup/setup_integria.php | 367 ++++++++++++++--- pandora_console/images/integria_logo.png | Bin 0 -> 4614 bytes pandora_console/include/functions.php | 83 +++- pandora_console/include/functions_config.php | 28 ++ pandora_console/include/functions_events.php | 246 ++++++++++++ .../configure_integriaims_incident.php | 377 ++++-------------- pandora_server/util/integria_rticket.pl | 6 + 9 files changed, 754 insertions(+), 367 deletions(-) create mode 100644 pandora_console/images/integria_logo.png diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 000a105257..1ab91f25f3 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -295,6 +295,9 @@ if (check_acl($config['id_user'], 0, 'PM')) { $sub2['godmode/setup/setup&section=ehorus']['text'] = __('eHorus'); $sub2['godmode/setup/setup&section=ehorus']['refr'] = 0; + $sub2['godmode/setup/setup&section=integria']['text'] = __('Integria IMS'); + $sub2['godmode/setup/setup&section=ehorus']['refr'] = 0; + $sub2['godmode/setup/setup&section=notifications']['text'] = __('Notifications'); $sub2['godmode/setup/setup&section=notifications']['refr'] = 0; diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 595cfb1d14..bf34da4a61 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -117,6 +117,11 @@ if (check_acl($config['id_user'], 0, 'AW')) { } } +$buttons['integria'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('Integria IMS')]).'', +]; + $buttons['ehorus'] = [ 'active' => false, 'text' => ''.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('eHorus')]).'', @@ -167,6 +172,12 @@ switch ($section) { $help_header = 'setup_ehorus_tab'; break; + case 'integria': + $buttons['integria']['active'] = true; + $subpage = ' » '.__('Integria IMS'); + $help_header = 'setup_integria_tab'; + break; + case 'notifications': $buttons['notifications']['active'] = true; $subpage = ' » '.__('Notifications'); diff --git a/pandora_console/godmode/setup/setup_integria.php b/pandora_console/godmode/setup/setup_integria.php index 29a1b199f7..a3b25b7e07 100644 --- a/pandora_console/godmode/setup/setup_integria.php +++ b/pandora_console/godmode/setup/setup_integria.php @@ -28,25 +28,136 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user return; } -hd(get_parameter('update_config', 0)); +if (is_ajax()) { + $integria_user = get_parameter('integria_user', ''); + $integria_pass = get_parameter('integria_pass', ''); + $integria_api_hostname = get_parameter('api_hostname', ''); + $integria_api_pass = get_parameter('api_pass', ''); + + $login_result = integria_api_call($integria_api_hostname, $integria_user, $integria_pass, $integria_api_pass, 'get_login', []); + + if ($login_result != false) { + echo json_encode(['login' => 1]); + } else { + echo json_encode(['login' => 0]); + } + + return; +} + +$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []); + +if ($has_connection === false) { + ui_print_error_message(__('Integria IMS API is not reachable')); +} if (get_parameter('update_config', 0) == 1) { // Try to retrieve event response 'Create incident in IntegriaIMS from event' to check if it exists. - $row = db_get_row_filter('tevent_response', ['name' => 'Create incident in IntegriaIMS from event']); + $event_response_exists = db_get_row_filter('tevent_response', ['name' => io_safe_input('Create incident in IntegriaIMS from event')]); + + // Try to retrieve command 'Integia IMS Ticket' to check if it exists. + $command_exists = db_get_row_filter('talert_commands', ['name' => io_safe_input('Integria IMS Ticket')]); if ($config['integria_enabled'] == 1) { - if ($row === false) { + if ($event_response_exists === false) { // Create 'Create incident in IntegriaIMS from event' event response only when user enables IntegriaIMS integration and it does not exist in database. - db_process_sql_insert('tevent_response', ['name' => 'Create incident in IntegriaIMS from event', 'description' => 'Create an incident in IntegriaIMS from an event', 'target' => 'index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&from_event=_event_id_', 'type' => 'url', 'id_group' => '0', 'modal_width' => '0', 'modal_height' => '0', 'new_window' => '1', 'params' => '', 'server_to_exec' => '0']); + db_process_sql_insert('tevent_response', ['name' => io_safe_input('Create incident in IntegriaIMS from event'), 'description' => io_safe_input('Create an incident in Integria IMS from an event'), 'target' => io_safe_input('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&from_event=_event_id_'), 'type' => 'url', 'id_group' => '0', 'modal_width' => '0', 'modal_height' => '0', 'new_window' => '1', 'params' => '', 'server_to_exec' => '0']); + } + + if ($command_exists === false) { + // Create 'Integria IMS Ticket' command only when user enables IntegriaIMS integration and it does not exist in database. + $id_command_inserted = db_process_sql_insert('talert_commands', ['name' => io_safe_input('Integria IMS Ticket'), 'command' => io_safe_input('perl /usr/share/pandora_server/util/integria_rticket.pl -p '.$config['integria_hostname'].'/integria/include/api.php -u '.$config['integria_api_pass'].','.$config['integria_user'].','.$config['integria_pass'].' -create_ticket -name "_field1_" -desc "_field2_" -group _field3_ -priority _field4_ -owner _field5_ -type _field6_'), 'description' => io_safe_input('Create an incident in Integria IMS'), 'fields_descriptions' => '["'.io_safe_input('Ticket title').'","'.io_safe_input('Ticket description').'","'.io_safe_input('Ticket group ID').'","'.io_safe_input('Ticket priority').'","'.io_safe_input('Ticket owner').'","'.io_safe_input('Ticket type').'"]', 'fields_values' => '["'.io_safe_input($config['incident_title']).'", "'.io_safe_input($config['incident_content']).'", "'.io_safe_input($config['default_group']).'", "'.io_safe_input($config['default_criticity']).'", "'.io_safe_input($config['default_owner']).'", "'.io_safe_input($config['incident_type']).'"]', 'fields_hidden' => '["","","","","","","","","",""]']); + + // Create 'Create Integria IMS Ticket' action only when user enables IntegriaIMS integration and command exists in database. + $action_values = [ + 'field1' => io_safe_input($config['incident_title']), + 'field1_recovery' => io_safe_input($config['incident_title']), + 'field2' => io_safe_input($config['incident_content']), + 'field2_recovery' => io_safe_input($config['incident_content']), + 'field3' => io_safe_input($config['default_group']), + 'field3_recovery' => io_safe_input($config['default_group']), + 'field4' => io_safe_input($config['default_criticity']), + 'field4_recovery' => io_safe_input($config['default_criticity']), + 'field5' => io_safe_input($config['default_owner']), + 'field5_recovery' => io_safe_input($config['default_owner']), + 'id_group' => 0, + 'action_threshold' => 0, + ]; + + alerts_create_alert_action(io_safe_input('Create Integria IMS ticket'), $id_command_inserted, $action_values); + } else { + // Update 'Integria IMS Ticket' command setup when setup data is updated, user enables IntegriaIMS integration and it does exist in database. + db_process_sql_update( + 'talert_commands', + [ + 'command' => io_safe_input('perl /usr/share/pandora_server/util/integria_rticket.pl -p '.$config['integria_hostname'].'/integria/include/api.php -u '.$config['integria_api_pass'].','.$config['integria_user'].','.$config['integria_pass'].' -create_ticket -name "_field1_" -desc "_field2_" -group _field3_ -priority _field4_ -owner _field5_ -type _field6_'), + 'fields_values' => '["'.io_safe_input($config['incident_title']).'", "'.io_safe_input($config['incident_content']).'", "'.io_safe_input($config['default_group']).'", "'.io_safe_input($config['default_criticity']).'", "'.io_safe_input($config['default_owner']).'", "'.io_safe_input($config['incident_type']).'"]', + ], + ['name' => io_safe_input('Integria IMS Ticket')] + ); + + // Update 'Create Integria IMS Ticket' action when setup data is updated, user enables IntegriaIMS integration and command does exist in database. + db_process_sql_update( + 'talert_actions', + [ + 'field1' => io_safe_input($config['incident_title']), + 'field1_recovery' => io_safe_input($config['incident_title']), + 'field2' => io_safe_input($config['incident_content']), + 'field2_recovery' => io_safe_input($config['incident_content']), + 'field3' => io_safe_input($config['default_group']), + 'field3_recovery' => io_safe_input($config['default_group']), + 'field4' => io_safe_input($config['default_criticity']), + 'field4_recovery' => io_safe_input($config['default_criticity']), + 'field5' => io_safe_input($config['default_owner']), + 'field5_recovery' => io_safe_input($config['default_owner']), + ], + ['name' => io_safe_input('Create Integria IMS ticket')] + ); } } else { - if ($row != false) { - // Delete 'Create incident in IntegriaIMS from event' event response if it does exist and IntegriaIMS integration is disabled - db_process_sql_delete('tevent_response', ['name' => 'Create incident in IntegriaIMS from event']); + if ($event_response_exists != false) { + // Delete 'Create incident in IntegriaIMS from event' event response if it does exist and IntegriaIMS integration is disabled. + db_process_sql_delete('tevent_response', ['name' => io_safe_input('Create incident in IntegriaIMS from event')]); + } + + if ($command_exists != false) { + // Delete 'Integria IMS Ticket' command if it does exist and IntegriaIMS integration is disabled. + db_process_sql_delete('talert_commands', ['name' => io_safe_input('Integria IMS Ticket')]); + + // Delete 'Create Integria IMS Ticket' action if command exists and IntegriaIMS integration is disabled. + db_process_sql_delete('talert_actions', ['name' => io_safe_input('Create Integria IMS ticket')]); } } } +// Get parameters from Integria IMS API. +$group_values = []; +$integria_criticity_values = []; +$integria_users_values = []; +$integria_types_values = []; + +$integria_groups_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups', []); + +get_array_from_csv_data($integria_groups_csv, $group_values); + +$integria_criticity_levels_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities', []); + +get_array_from_csv_data($integria_criticity_levels_csv, $integria_criticity_values); + +$integria_users_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_users', []); + +$csv_array = explode("\n", $integria_users_csv); + +foreach ($csv_array as $csv_line) { + if (!empty($csv_line)) { + $integria_users_values[$csv_line] = $csv_line; + } +} + +$integria_types_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types', []); + +get_array_from_csv_data($integria_types_csv, $integria_types_values); + // Enable table. $table_enable = new StdClass(); $table_enable->data = []; @@ -72,25 +183,32 @@ $table_remote->class = 'databox filters'; $table_remote->size['name'] = '30%'; $table_remote->style['name'] = 'font-weight: bold'; -// User. +// Integria user. $row = []; $row['name'] = __('User'); $row['control'] = html_print_input_text('integria_user', $config['integria_user'], '', 30, 100, true); $table_remote->data['integria_user'] = $row; -// Pass. +// Integria password. $row = []; $row['name'] = __('Password'); $row['control'] = html_print_input_password('integria_pass', io_output_password($config['integria_pass']), '', 30, 100, true); $table_remote->data['integria_pass'] = $row; -// Directory hostname. +// Integria hostname. $row = []; $row['name'] = __('API Hostname'); $row['control'] = html_print_input_text('integria_hostname', $config['integria_hostname'], '', 30, 100, true); -$row['control'] .= ui_print_help_tip(__('Hostname of the Integria API')); +$row['control'] .= ui_print_help_tip(__('Hostname of Integria IMS\' API (scheme must be specified. Example: http://192.168.0.0)'), true); $table_remote->data['integria_hostname'] = $row; +// API password. +$row = []; +$row['name'] = __('API Password'); +$row['control'] = html_print_input_text('integria_api_pass', $config['integria_api_pass'], '', 30, 100, true); +$row['control'] .= ui_print_help_tip(__('Password of Integria IMS\' API'), true); +$table_remote->data['integria_api_pass'] = $row; + // Request timeout. $row = []; $row['name'] = __('Request timeout'); @@ -98,6 +216,118 @@ $row['control'] = html_print_input_text('integria_req_timeout', $config['integri $row['control'] .= ui_print_help_tip(__('Time in seconds to set the maximum time of the requests to the Integria API').'. '.__('0 to disable'), true); $table_remote->data['integria_req_timeout'] = $row; +// Custom response settings. +$table_cr_settings = new StdClass(); +$table_cr_settings->data = []; +$table_cr_settings->width = '100%'; +$table_cr_settings->styleTable = 'margin-bottom: 10px;'; +$table_cr_settings->id = 'integria-cr-settings-setup'; +$table_cr_settings->class = 'databox filters'; +$table_cr_settings->size['name'] = '30%'; +$table_cr_settings->style['name'] = 'font-weight: bold'; + +// Custom response default group. +$row = []; +$row['name'] = __('Default group'); +$row['control'] = html_print_select( + $group_values, + 'default_group', + $config['default_group'], + '', + __('Select'), + 0, + true, + false, + true, + '', + false +); +$table_cr_settings->data['custom_response_def_group'] = $row; + +// Custom response default criticity. +$row = []; +$row['name'] = __('Default criticity'); +$row['control'] = html_print_select( + $integria_criticity_values, + 'default_criticity', + $config['default_criticity'], + '', + __('Select'), + 0, + true, + false, + true, + '', + false +); +$table_cr_settings->data['custom_response_def_criticity'] = $row; + +// Custom response default owner. +$row = []; +$row['name'] = __('Default owner'); +$row['control'] = html_print_select( + $integria_users_values, + 'default_owner', + $config['default_owner'], + '', + __('Select'), + 0, + true, + false, + true, + '', + false +); +$table_cr_settings->data['custom_response_def_owner'] = $row; + +// Custom response default incident type. +$row = []; +$row['name'] = __('Incident type'); +$row['control'] = html_print_select( + $integria_types_values, + 'incident_type', + $config['incident_type'], + '', + __('Select'), + 0, + true, + false, + true, + '', + false +); +$table_cr_settings->data['custom_response_incident_type'] = $row; + +// Custom response incident title. +$row = []; +$row['name'] = __('Incident title'); +$row['control'] = html_print_input_text( + 'incident_title', + $config['incident_title'], + __('Name'), + 50, + 100, + true, + false, + false +).ui_print_help_icon('response_macros', true); +$table_cr_settings->data['custom_response_incident_title'] = $row; + +// Custom response incident content. +$row = []; +$row['name'] = __('Incident content'); +$row['control'] = html_print_input_text( + 'incident_content', + $config['incident_content'], + '', + 50, + 100, + true, + false, + false +).ui_print_help_icon('response_macros', true); +$table_cr_settings->data['custom_response_incident_content'] = $row; + // Test. $row = []; $row['name'] = __('Test'); @@ -108,68 +338,86 @@ $row['control'] .= '