From 47cc0d9d6e64e4e439352e8b3f693a9097d75c17 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 10 Jul 2019 23:59:09 +0200 Subject: [PATCH 01/15] WIP: Agent deployment center --- pandora_console/extras/mr/30.sql | 29 +++ .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 35 +++ .../godmode/agentes/agent_manager.php | 6 +- .../godmode/groups/credential_store.php | 8 +- .../godmode/wizards/HostDevices.class.php | 15 ++ .../godmode/wizards/Wizard.main.php | 243 +----------------- pandora_console/include/constants.php | 1 + .../include/functions_credential_store.php | 8 +- pandora_console/include/functions_html.php | 48 ++-- pandora_console/include/functions_ui.php | 33 +-- .../include/styles/deployment_list.css | 12 + pandora_console/pandoradb.sql | 35 +++ pandora_server/lib/PandoraFMS/Recon/Base.pm | 4 +- 13 files changed, 180 insertions(+), 297 deletions(-) create mode 100644 pandora_console/include/styles/deployment_list.css diff --git a/pandora_console/extras/mr/30.sql b/pandora_console/extras/mr/30.sql index eeb3b8d797..fcb157f964 100644 --- a/pandora_console/extras/mr/30.sql +++ b/pandora_console/extras/mr/30.sql @@ -10,4 +10,33 @@ ALTER TABLE `treport_content_template` ADD COLUMN `failover_type` tinyint(1) DEF ALTER TABLE `tmodule_relationship` ADD COLUMN `type` ENUM('direct', 'failover') DEFAULT 'direct'; +CREATE TABLE `ttask_credentials` ( + `id_rt` int(10) unsigned NOT NULL, + `identifier` varchar(100) NOT NULL, + PRIMARY KEY (`id_rt`,`identifier`), + KEY `identifier` (`identifier`), + FOREIGN KEY (`id_rt`) REFERENCES `trecon_task` (`id_rt`) + ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`identifier`) REFERENCES `tcredential_store` (`identifier`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `tdeployment_hosts` ( + `id` SERIAL, + `id_cs` VARCHAR(100), + `ip` VARCHAR(100) NOT NULL, + `id_os` INT(10) UNSIGNED DEFAULT 0, + `os_version` VARCHAR(100) DEFAULT '' COMMENT "OS version in STR format", + `arch` ENUM('x64', 'x86') DEFAULT 'x64', + `current_agent_version` VARCHAR(100) DEFAULT '', + `desired_agent_version` VARCHAR(100) DEFAULT '', + `deployed` bigint(20) unsigned COMMENT "When it was deployed", + `last_err` text, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`) + ON UPDATE CASCADE ON DELETE SET NULL, + FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + 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 60e19998e8..fa3cc03741 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 @@ -2219,3 +2219,38 @@ CREATE TABLE IF NOT EXISTS `tcredential_store` ( -- Table `treport_content_sla_combined` -- --------------------------------------------------------------------- ALTER TABLE `treport_content_sla_combined` ADD `id_agent_module_failover` int(10) unsigned NOT NULL; + +-- ---------------------------------------------------------------------- +-- Table `ttask_credentials` +-- ---------------------------------------------------------------------- +CREATE TABLE `ttask_credentials` ( + `id_rt` int(10) unsigned NOT NULL, + `identifier` varchar(100) NOT NULL, + PRIMARY KEY (`id_rt`,`identifier`), + KEY `identifier` (`identifier`), + FOREIGN KEY (`id_rt`) REFERENCES `trecon_task` (`id_rt`) + ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`identifier`) REFERENCES `tcredential_store` (`identifier`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tdeployment_hosts` +-- ---------------------------------------------------------------------- +CREATE TABLE `tdeployment_hosts` ( + `id` SERIAL, + `id_cs` VARCHAR(100), + `ip` VARCHAR(100) NOT NULL, + `id_os` INT(10) UNSIGNED DEFAULT 0, + `os_version` VARCHAR(100) DEFAULT '' COMMENT "OS version in STR format", + `arch` ENUM('x64', 'x86') DEFAULT 'x64', + `current_agent_version` VARCHAR(100) DEFAULT '', + `desired_agent_version` VARCHAR(100) DEFAULT '', + `deployed` bigint(20) unsigned COMMENT "When it was deployed", + `last_err` text, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`) + ON UPDATE CASCADE ON DELETE SET NULL, + FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 3ea3a7f0c2..d7c783c5d4 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -514,8 +514,10 @@ if (enterprise_installed()) { ); $safe_mode_modules = []; $safe_mode_modules[0] = __('Any'); - foreach ($sql_modules as $m) { - $safe_mode_modules[$m['id_module']] = $m['name']; + if (is_array($sql_modules)) { + foreach ($sql_modules as $m) { + $safe_mode_modules[$m['id_module']] = $m['name']; + } } $table_adv_safe = '

'.__('Safe operation mode').': '.ui_print_help_tip( diff --git a/pandora_console/godmode/groups/credential_store.php b/pandora_console/godmode/groups/credential_store.php index 8c9540d581..9334cd6065 100644 --- a/pandora_console/godmode/groups/credential_store.php +++ b/pandora_console/godmode/groups/credential_store.php @@ -522,12 +522,10 @@ echo '

'; function calculate_inputs() { if ($('#product :selected').val() == "CUSTOM") { - $('#div-username label').text(''); + $('#div-username label').text(''); $('#div-password label').text(''); - $('#div-extra_1 label').text(''); - $('#div-extra_2 label').text(''); - $('#div-extra_1').show(); - $('#div-extra_2').show(); + $('#div-extra_1').hide(); + $('#div-extra_2').hide(); } else if ($('#product :selected').val() == "AWS") { $('#div-username label').text(''); $('#div-password label').text(''); diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 3cc2e3f71d..8982d76d4b 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -32,6 +32,7 @@ require_once $config['homedir'].'/include/class/CustomNetScan.class.php'; require_once $config['homedir'].'/include/class/ManageNetScanScripts.class.php'; enterprise_include_once('include/class/CSVImportAgents.class.php'); +enterprise_include_once('include/class/DeploymentCenter.class.php'); enterprise_include_once('include/functions_hostdevices.php'); /** @@ -127,6 +128,12 @@ class HostDevices extends Wizard 'icon' => ENTERPRISE_DIR.'/images/wizard/csv.png', 'label' => __('Import CSV'), ]; + + $buttons[] = [ + 'url' => $this->url.'&mode=deploy', + 'icon' => ENTERPRISE_DIR.'/images/wizard/deployment.png', + 'label' => __('Agent deployment'), + ]; } $buttons[] = [ @@ -167,6 +174,14 @@ class HostDevices extends Wizard ); return $csv_importer->runCSV(); } + + if ($mode === 'deploy') { + $deployObject = new DeploymentCenter( + $this->page, + $this->breadcrum + ); + return $deployObject->run(); + } } if ($mode === 'customnetscan') { diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 2524f6d93c..d6bd9eaee3 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -296,241 +296,20 @@ class Wizard */ public function printInput($data) { + global $config; + + include_once $config['homedir'].'/include/functions_html.php'; + if (is_array($data) === false) { return ''; } - switch ($data['type']) { - case 'text': - return html_print_input_text( - $data['name'], - $data['value'], - ((isset($data['alt']) === true) ? $data['alt'] : ''), - ((isset($data['size']) === true) ? $data['size'] : 50), - ((isset($data['maxlength']) === true) ? $data['maxlength'] : 255), - ((isset($data['return']) === true) ? $data['return'] : true), - ((isset($data['disabled']) === true) ? $data['disabled'] : false), - ((isset($data['required']) === true) ? $data['required'] : false), - ((isset($data['function']) === true) ? $data['function'] : ''), - ((isset($data['class']) === true) ? $data['class'] : ''), - ((isset($data['onChange']) === true) ? $data['onChange'] : ''), - ((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '') - ); - - case 'image': - return html_print_input_image( - $data['name'], - $data['src'], - $data['value'], - ((isset($data['style']) === true) ? $data['style'] : ''), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['options']) === true) ? $data['options'] : false) - ); - - case 'text_extended': - return html_print_input_text_extended( - $data['name'], - $data['value'], - $data['id'], - $data['alt'], - $data['size'], - $data['maxlength'], - $data['disabled'], - $data['script'], - $data['attributes'], - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['password']) === true) ? $data['password'] : false), - ((isset($data['function']) === true) ? $data['function'] : '') - ); - - case 'password': - return html_print_input_password( - $data['name'], - $data['value'], - ((isset($data['alt']) === true) ? $data['alt'] : ''), - ((isset($data['size']) === true) ? $data['size'] : 50), - ((isset($data['maxlength']) === true) ? $data['maxlength'] : 255), - ((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'] : '') - ); - - case 'text': - return html_print_input_text( - $data['name'], - $data['value'], - ((isset($data['alt']) === true) ? $data['alt'] : ''), - ((isset($data['size']) === true) ? $data['size'] : 50), - ((isset($data['maxlength']) === true) ? $data['maxlength'] : 255), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['disabled']) === true) ? $data['disabled'] : false), - ((isset($data['required']) === true) ? $data['required'] : false), - ((isset($data['function']) === true) ? $data['function'] : ''), - ((isset($data['class']) === true) ? $data['class'] : ''), - ((isset($data['onChange']) === true) ? $data['onChange'] : ''), - ((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '') - ); - - case 'image': - return html_print_input_image( - $data['name'], - $data['src'], - $data['value'], - ((isset($data['style']) === true) ? $data['style'] : ''), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['options']) === true) ? $data['options'] : false) - ); - - case 'hidden': - return html_print_input_hidden( - $data['name'], - $data['value'], - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['class']) === true) ? $data['class'] : false) - ); - - case 'hidden_extended': - return html_print_input_hidden_extended( - $data['name'], - $data['value'], - $data['id'], - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['class']) === true) ? $data['class'] : false) - ); - - case 'color': - return html_print_input_color( - $data['name'], - $data['value'], - ((isset($data['class']) === true) ? $data['class'] : false), - ((isset($data['return']) === true) ? $data['return'] : false) - ); - - case 'file': - return html_print_input_file( - $data['name'], - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['options']) === true) ? $data['options'] : false) - ); - - case 'select': - return html_print_select( - $data['fields'], - $data['name'], - ((isset($data['selected']) === true) ? $data['selected'] : ''), - ((isset($data['script']) === true) ? $data['script'] : ''), - ((isset($data['nothing']) === true) ? $data['nothing'] : ''), - ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['multiple']) === true) ? $data['multiple'] : false), - ((isset($data['sort']) === true) ? $data['sort'] : true), - ((isset($data['class']) === true) ? $data['class'] : ''), - ((isset($data['disabled']) === true) ? $data['disabled'] : false), - ((isset($data['style']) === true) ? $data['style'] : false), - ((isset($data['option_style']) === true) ? $data['option_style'] : false), - ((isset($data['size']) === true) ? $data['size'] : false), - ((isset($data['modal']) === true) ? $data['modal'] : false), - ((isset($data['message']) === true) ? $data['message'] : ''), - ((isset($data['select_all']) === true) ? $data['select_all'] : false) - ); - - case 'select_from_sql': - return html_print_select_from_sql( - $data['sql'], - $data['name'], - ((isset($data['selected']) === true) ? $data['selected'] : ''), - ((isset($data['script']) === true) ? $data['script'] : ''), - ((isset($data['nothing']) === true) ? $data['nothing'] : ''), - ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : '0'), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['multiple']) === true) ? $data['multiple'] : false), - ((isset($data['sort']) === true) ? $data['sort'] : true), - ((isset($data['disabled']) === true) ? $data['disabled'] : false), - ((isset($data['style']) === true) ? $data['style'] : false), - ((isset($data['size']) === true) ? $data['size'] : false), - ((isset($data['trucate_size']) === true) ? $data['trucate_size'] : GENERIC_SIZE_TEXT) - ); - - case 'select_groups': - return html_print_select_groups( - ((isset($data['id_user']) === true) ? $data['id_user'] : false), - ((isset($data['privilege']) === true) ? $data['privilege'] : 'AR'), - ((isset($data['returnAllGroup']) === true) ? $data['returnAllGroup'] : true), - $data['name'], - ((isset($data['selected']) === true) ? $data['selected'] : ''), - ((isset($data['script']) === true) ? $data['script'] : ''), - ((isset($data['nothing']) === true) ? $data['nothing'] : ''), - ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['multiple']) === true) ? $data['multiple'] : false), - ((isset($data['sort']) === true) ? $data['sort'] : true), - ((isset($data['class']) === true) ? $data['class'] : ''), - ((isset($data['disabled']) === true) ? $data['disabled'] : false), - ((isset($data['style']) === true) ? $data['style'] : false), - ((isset($data['option_style']) === true) ? $data['option_style'] : false), - ((isset($data['id_group']) === true) ? $data['id_group'] : false), - ((isset($data['keys_field']) === true) ? $data['keys_field'] : 'id_grupo'), - ((isset($data['strict_user']) === true) ? $data['strict_user'] : false), - ((isset($data['delete_groups']) === true) ? $data['delete_groups'] : false), - ((isset($data['include_groups']) === true) ? $data['include_groups'] : false), - ((isset($data['size']) === true) ? $data['size'] : false), - ((isset($data['simple_multiple_options']) === true) ? $data['simple_multiple_options'] : false) - ); - - case 'submit': - return '
'.html_print_submit_button( - ((isset($data['label']) === true) ? $data['label'] : 'OK'), - ((isset($data['name']) === true) ? $data['name'] : ''), - ((isset($data['disabled']) === true) ? $data['disabled'] : false), - ((isset($data['attributes']) === true) ? $data['attributes'] : ''), - ((isset($data['return']) === true) ? $data['return'] : false) - ).'
'; - - case 'checkbox': - return html_print_checkbox( - $data['name'], - $data['value'], - ((isset($data['checked']) === true) ? $data['checked'] : false), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['disabled']) === true) ? $data['disabled'] : false), - ((isset($data['script']) === true) ? $data['script'] : ''), - ((isset($data['disabled_hidden']) === true) ? $data['disabled_hidden'] : false) - ); - - case 'switch': - return html_print_switch($data); - - case 'interval': - return html_print_extended_select_for_time( - $data['name'], - $data['value'], - ((isset($data['script']) === true) ? $data['script'] : ''), - ((isset($data['nothing']) === true) ? $data['nothing'] : ''), - ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0), - ((isset($data['size']) === true) ? $data['size'] : false), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['style']) === true) ? $data['selected'] : false), - ((isset($data['unique']) === true) ? $data['unique'] : false) - ); - - case 'textarea': - return html_print_textarea( - $data['name'], - $data['rows'], - $data['columns'], - ((isset($data['value']) === true) ? $data['value'] : ''), - ((isset($data['attributes']) === true) ? $data['attributes'] : ''), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['class']) === true) ? $data['class'] : '') - ); - - default: - // Ignore. - break; + $input = html_print_input(($data + ['return' => true]), 'div', true); + if ($input === false) { + return ''; } - return ''; + return $input; } @@ -800,7 +579,7 @@ class Wizard $cb_function = $data['cb_function']; $cb_args = $data['cb_args']; - $output_head = '
'; if ($return === false) { @@ -872,7 +651,7 @@ class Wizard $cb_function = $data['cb_function']; $cb_args = $data['cb_args']; - $output_head = ''; if ($return === false) { @@ -967,7 +746,7 @@ class Wizard $cb_function = $data['cb_function']; $cb_args = $data['cb_args']; - $output_head = ''; if ($return === false) { diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index c0a03ea34d..899b5b609b 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -583,6 +583,7 @@ define('DISCOVERY_APP_ORACLE', 5); define('DISCOVERY_CLOUD_AWS_EC2', 6); define('DISCOVERY_CLOUD_AWS_RDS', 7); define('DISCOVERY_CLOUD_AZURE_COMPUTE', 8); +define('DISCOVERY_DEPLOY_AGENTS', 9); // Discovery types matching definition. diff --git a/pandora_console/include/functions_credential_store.php b/pandora_console/include/functions_credential_store.php index eaf756f7b1..ea7b3d5c72 100644 --- a/pandora_console/include/functions_credential_store.php +++ b/pandora_console/include/functions_credential_store.php @@ -295,9 +295,9 @@ function print_inputs($values=null) 'type' => 'select', 'script' => 'calculate_inputs()', 'fields' => [ - // 'CUSTOM' => __('Custom'), - 'AWS' => __('Aws'), - 'AZURE' => __('Azure'), + 'CUSTOM' => __('Custom'), + 'AWS' => __('Aws'), + 'AZURE' => __('Azure'), // 'GOOGLE' => __('Google'), ], 'selected' => $values['product'], @@ -331,6 +331,8 @@ function print_inputs($values=null) case 'GOOGLE': // Need further investigation. case 'CUSTOM': + $user_label = __('Account ID'); + $pass_label = __('Password'); default: // Use defaults. break; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 533822f069..18ee4d3940 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -3071,11 +3071,13 @@ function html_print_link_with_params($text, $params=[], $type='text', $style='') /** * Print input using functions html lib. * - * @param array $data Input definition. + * @param array $data Input definition. + * @param string $wrapper Wrapper 'div' or 'li'. + * @param boolean $input_only Return or print only input or also label. * * @return string HTML code for desired input. */ -function html_print_input($data) +function html_print_input($data, $wrapper='div', $input_only=false) { if (is_array($data) === false) { return ''; @@ -3083,8 +3085,8 @@ function html_print_input($data) $output = ''; - if ($data['label']) { - $output = '
'; $output .= '
'; + if ($data['label'] && $input_only === false) { + $output .= ''; if (!$data['return']) { - echo ''; + echo ''; } } return $output; } - - diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 0050ccdf9d..6a9620f3e8 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3094,38 +3094,7 @@ function ui_print_datatable(array $parameters) $filter .= ''; + } else { + $output .= ''; + } } else { if ($input['arguments']['type'] != 'hidden') { $output .= '
  • '; @@ -577,6 +588,7 @@ class Wizard $form = $data['form']; $inputs = $data['inputs']; $js = $data['js']; + $rawjs = $data['js_block']; $cb_function = $data['cb_function']; $cb_args = $data['cb_args']; @@ -624,6 +636,9 @@ class Wizard $output .= '
      '.$output_submit.'
    '; $output .= '
  • '; $output .= ''; + if ($rawjs) { + $output .= $rawjs; + } if ($return === false) { echo $output; @@ -649,6 +664,7 @@ class Wizard $rows = $data['rows']; $js = $data['js']; + $rawjs = $data['js_block']; $cb_function = $data['cb_function']; $cb_args = $data['cb_args']; @@ -675,45 +691,47 @@ class Wizard $first_block_printed = false; - foreach ($rows as $row) { - if ($row['new_form_block'] == true) { - if ($first_block_printed === true) { - // If first form block has been placed, then close it before starting a new one. - $output .= ''; - $output .= '
    '; - } else { - $output .= '
    '; + if (is_array($rows)) { + foreach ($rows as $row) { + if ($row['new_form_block'] == true) { + if ($first_block_printed === true) { + // If first form block has been placed, then close it before starting a new one. + $output .= '
    '; + $output .= '
    '; + } else { + $output .= '
    '; + } + + $first_block_printed = true; } - $first_block_printed = true; - } + $output .= '
    '; - $output .= '
    '; + foreach ($row['columns'] as $column) { + $width = isset($column['width']) ? 'width: '.$column['width'].';' : 'width: 100%;'; + $padding_left = isset($column['padding-left']) ? 'padding-left: '.$column['padding-left'].';' : 'padding-left: 0;'; + $padding_right = isset($column['padding-right']) ? 'padding-right: '.$column['padding-right'].';' : 'padding-right: 0;'; + $extra_styles = isset($column['style']) ? $column['style'] : ''; - foreach ($row['columns'] as $column) { - $width = isset($column['width']) ? 'width: '.$column['width'].';' : 'width: 100%;'; - $padding_left = isset($column['padding-left']) ? 'padding-left: '.$column['padding-left'].';' : 'padding-left: 0;'; - $padding_right = isset($column['padding-right']) ? 'padding-right: '.$column['padding-right'].';' : 'padding-right: 0;'; - $extra_styles = isset($column['style']) ? $column['style'] : ''; + $output .= '
    '; - $output .= '
    '; - - foreach ($column['inputs'] as $input) { - if (is_array($input)) { - if ($input['arguments']['type'] != 'submit') { - $output .= $this->printBlockAsGrid($input, true); + foreach ($column['inputs'] as $input) { + if (is_array($input)) { + if ($input['arguments']['type'] != 'submit') { + $output .= $this->printBlockAsGrid($input, true); + } else { + $output_submit .= $this->printBlockAsGrid($input, true); + } } else { - $output_submit .= $this->printBlockAsGrid($input, true); + $output .= $input; } - } else { - $output .= $input; } + + $output .= '
    '; } $output .= '
    '; } - - $output .= '
    '; } $output .= '
    '; @@ -721,6 +739,9 @@ class Wizard $output .= '
      '.$output_submit.'
    '; $output .= ''; $output .= ''; + if ($rawjs) { + $output .= $rawjs; + } if ($return === false) { echo $output; @@ -744,6 +765,7 @@ class Wizard $form = $data['form']; $inputs = $data['inputs']; $js = $data['js']; + $rawjs = $data['js_block']; $cb_function = $data['cb_function']; $cb_args = $data['cb_args']; @@ -781,6 +803,9 @@ class Wizard $output .= '
      '.$output_submit.'
    '; $output .= ''; $output .= ''; + if ($rawjs) { + $output .= $rawjs; + } if ($return === false) { echo $output; From 9fb32c46991d1f132b72fa50ffbe16efcf390a84 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 12 Jul 2019 18:29:58 +0200 Subject: [PATCH 05/15] Deployment area single targets --- .../godmode/groups/credential_store.php | 2 +- pandora_console/godmode/wizards/Wizard.main.php | 2 +- .../include/functions_credential_store.php | 2 -- pandora_console/include/styles/deployment_list.css | 14 +++++++++++++- pandora_console/include/styles/tables.css | 6 ++++++ 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pandora_console/godmode/groups/credential_store.php b/pandora_console/godmode/groups/credential_store.php index 9334cd6065..dd7cc5affb 100644 --- a/pandora_console/godmode/groups/credential_store.php +++ b/pandora_console/godmode/groups/credential_store.php @@ -369,7 +369,7 @@ echo '
    '; text = err.message; failed = 1; } - if (!failed && data['error']) { + if (!failed && data['error'] != undefined) { title = ""; text = data['error']; failed = 1; diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 8f0bb0bbd8..3292a88ef6 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -592,7 +592,7 @@ class Wizard $cb_function = $data['cb_function']; $cb_args = $data['cb_args']; - $output_head = '
    '; if ($return === false) { diff --git a/pandora_console/include/functions_credential_store.php b/pandora_console/include/functions_credential_store.php index ea7b3d5c72..048c2bba00 100644 --- a/pandora_console/include/functions_credential_store.php +++ b/pandora_console/include/functions_credential_store.php @@ -56,8 +56,6 @@ function credentials_get_all( global $config; - $user_is_admin = users_is_admin(); - if (!is_array($filter)) { error_log('[credential_get_all] Filter must be an array.'); throw new Exception('[credential_get_all] Filter must be an array.'); diff --git a/pandora_console/include/styles/deployment_list.css b/pandora_console/include/styles/deployment_list.css index ca5385f3f5..c107342246 100644 --- a/pandora_console/include/styles/deployment_list.css +++ b/pandora_console/include/styles/deployment_list.css @@ -2,7 +2,7 @@ ul.wizard li > label:not(.p-switch) { width: auto; } -ul.wizard { +form.top-action-buttons ul.wizard { display: flex; flex-direction: row; } @@ -10,3 +10,15 @@ ul.wizard { ul.wizard li { margin-right: 1em; } + +form.modal ul.wizard li { + display: flex; + flex-direction: row; + width: 90%; + margin: 0.5em auto; + justify-items: center; +} + +form.modal ul.wizard li * { + flex: 1; +} diff --git a/pandora_console/include/styles/tables.css b/pandora_console/include/styles/tables.css index c3e1deb94c..7e49d32c83 100644 --- a/pandora_console/include/styles/tables.css +++ b/pandora_console/include/styles/tables.css @@ -122,6 +122,7 @@ letter-spacing: 0.3pt; color: #000; background-color: #fff; + cursor: pointer; } .info_table tr th { @@ -341,3 +342,8 @@ a.pandora_pagination.current:hover { background-position-y: center; cursor: pointer; } + +.info_table tr th.sorting_asc, +.info_table tr th.sorting_desc { + padding-left: 15px; +} From 3bbd01026ee745764765db94086a6a28d31cfc4c Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 15 Jul 2019 19:37:04 +0200 Subject: [PATCH 06/15] WIP agent deployment --- pandora_console/extras/mr/30.sql | 2 +- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 +- .../godmode/groups/credential_store.php | 4 ++-- pandora_console/godmode/wizards/Wizard.main.php | 6 +++--- pandora_console/images/deploy.png | Bin 0 -> 1159 bytes pandora_console/images/input_deploy.png | Bin 0 -> 978 bytes .../include/styles/deployment_list.css | 5 +++++ pandora_console/include/styles/pandora.css | 9 ++++++--- pandora_console/pandoradb.sql | 2 +- 9 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 pandora_console/images/deploy.png create mode 100644 pandora_console/images/input_deploy.png diff --git a/pandora_console/extras/mr/30.sql b/pandora_console/extras/mr/30.sql index fcb157f964..2ea39573c2 100644 --- a/pandora_console/extras/mr/30.sql +++ b/pandora_console/extras/mr/30.sql @@ -24,7 +24,7 @@ CREATE TABLE `ttask_credentials` ( CREATE TABLE `tdeployment_hosts` ( `id` SERIAL, `id_cs` VARCHAR(100), - `ip` VARCHAR(100) NOT NULL, + `ip` VARCHAR(100) NOT NULL UNIQUE, `id_os` INT(10) UNSIGNED DEFAULT 0, `os_version` VARCHAR(100) DEFAULT '' COMMENT "OS version in STR format", `arch` ENUM('x64', 'x86') DEFAULT 'x64', 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 fa3cc03741..fd9219ccc3 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 @@ -2240,7 +2240,7 @@ CREATE TABLE `ttask_credentials` ( CREATE TABLE `tdeployment_hosts` ( `id` SERIAL, `id_cs` VARCHAR(100), - `ip` VARCHAR(100) NOT NULL, + `ip` VARCHAR(100) NOT NULL UNIQUE, `id_os` INT(10) UNSIGNED DEFAULT 0, `os_version` VARCHAR(100) DEFAULT '' COMMENT "OS version in STR format", `arch` ENUM('x64', 'x86') DEFAULT 'x64', diff --git a/pandora_console/godmode/groups/credential_store.php b/pandora_console/godmode/groups/credential_store.php index dd7cc5affb..adea35f7c1 100644 --- a/pandora_console/godmode/groups/credential_store.php +++ b/pandora_console/godmode/groups/credential_store.php @@ -555,8 +555,8 @@ echo '
    '; success: function(data) { $('#form_new').html(data); $('#id_group').val(0); - // By default AWS. - $('#product').val('AWS'); + // By default CUSTOM. + $('#product').val('CUSTOM'); calculate_inputs(); $('#product').on('change', function() { diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 3292a88ef6..3a65560285 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -381,7 +381,7 @@ class Wizard $output .= '
  • '; } - $output .= '
      '; + $output .= '
        '; foreach ($input['block_content'] as $input) { $output .= $this->printBlock($input, $return); } @@ -439,7 +439,7 @@ class Wizard if (is_array($input['block_content']) === true) { // Print independent block of inputs. $output .= '
      • '; - $output .= '
          '; + $output .= '
            '; foreach ($input['block_content'] as $input) { $output .= $this->printBlockAsGrid($input, $return); } @@ -542,7 +542,7 @@ class Wizard if (is_array($input['block_content']) === true) { // Print independent block of inputs. $output .= '
          • '; - $output .= '
              '; + $output .= '
                '; foreach ($input['block_content'] as $input) { $output .= $this->printBlockAsList($input, $return); } diff --git a/pandora_console/images/deploy.png b/pandora_console/images/deploy.png new file mode 100644 index 0000000000000000000000000000000000000000..1cb28a44fbeece1f6fa3f9088d3cfcf9b12520cc GIT binary patch literal 1159 zcmV;21bF+2P)EX>4Tx04R}tkv&MmKp2MKrb>%cI@m$PAwzW#3!);9T7@E12(?114knlWK@&rg z;^HW{799LptU9+0Yt2!cN#F0M|BE>hxmNufoIcO3Wd-uJ%TeFq4QD$}g4F+kI8 zGm}b+x%`S4dPN9Pnj;9y%ra&rDGlH8b&mkw?-D%AzwXb`s}?K<1VrK)W|%hdI`Pz| zZE)Tvjjna#`*$B4yJ2P+-S%BDsWXJn7>faQzaw6mnI- z$T5!%Xpmh$_#gc4tyP>D_mUz>p!>yfK8AqMF3_wy&iAq7G*5uwGjOH1{TmHn`jhl} zTZ`FmeLa_+EpV2qvfxcUyXVvRl>l~*KK$d!yz5xyn zf#DKmulc+?+}XE(Yg+yL0YNo#lR-YeRsaA124YJ`L;(K){{a7>y{D4^000SaNLh0L z04^f{04^f|c%?sf00007bV*G`2jd415Ctv^z*R5+000?uMObu0Z*6U5Zgc=ca%Ew3 zWn>_CX>@2HM@dakSAh-}0007BNkl}H@|?X`DMd9?)ku$H)NjKGJSi6HB~(i7D~$t#<{2x?NdvdzQ9Iwz@d4sddp#btZG%5CejbR% zqjup~&42#%)vuZPk7Iz$Ki{!+GnZcyto8jR0Lxc7LsofB2bv!go=&A>B63|f*ImQK zJ`~A|{*=f(r%t(1n50M_2m{G0u znCE%j`|YCjchB>lt*)+4)V-zp`uaMQQe7r&KWga!CE%}7wvo+dx2lqcLZKlMnFB_Z zQeB?sMMNa6wI1^O{fpb%+XI0>;BzjQ>s3ma_2+9=HnCbuk002ovPDHLkV1gxs9Z&!O literal 0 HcmV?d00001 diff --git a/pandora_console/images/input_deploy.png b/pandora_console/images/input_deploy.png new file mode 100644 index 0000000000000000000000000000000000000000..c66f4ddd56c061d87e83264f22828571ec3b6310 GIT binary patch literal 978 zcmV;@11EX>4Tx04R}tkv&MmKp2MKrb>%cI@m$PAwzW#3!);9T7@E12(?114knlWK@&rg z;^HW{799LptU9+0Yt2!cN#F0M|BE>hxmNufoIcO3Wd-uJ%TeFq4QD$}g4F+kI8 zGm}b+x%`S4dPN9Pnj;9y%ra&rDGlH8b&mkw?-D%AzwXb`s}?K<1VrK)W|%hdI`Pz| zZE)Tvjjna#`*$B4yJ2P+-S%BDsWXJn7>faQzaw6mnI- z$T5!%Xpmh$_#gc4tyP>D_mUz>p!>yfK8AqMF3_wy&iAq7G*5uwGjOH1{TmHn`jhl} zTZ`FmeLa_+EpV2qvfxcUyXVvRl>l~*KK$d!yz5xyn zf#DKmulc+?+}XE(Yg+yL0YNo#lR-YeRsaA124YJ`L;(K){{a7>y{D4^000SaNLh0L z04^f{04^f|c%?sf00007bV*G`2jd415C_CX>@2HM@dakSAh-}00050Nklx5<`cG zba4>JfKHADS9K7Ln^cG(=v`#R4N_q^?Dh0Q7V=CTC3H5Y!{BZ6bgmI-ust8 zirtkFk@-fW(b>^?VQGI6H~_3oPnGUmKmTNmwAOx5)ilrn2&!ut?!7*<0OWx~z~aX5 z+Va!)x0$3M45k5I0INWD=wJD^`KGcLsHzy%Eku$lLvJ294ZIx|+q?7K@+Ye0^{c=$ z;1uuN=mR$Z zj4|Kq_4=#$&+@Mgv({b)ZjM+FqbPblHg*i>^Z6|BKt#Gg8c^UDAV3n>P}L-`*ladC z+px7Z3p@rss_G2z1(;IRZX%J`GR7S2_xneHO<)eV7DZ7f-mpp#1ZSOd$3 Date: Tue, 16 Jul 2019 20:56:47 +0200 Subject: [PATCH 07/15] WIP agent deployment --- pandora_console/extras/mr/30.sql | 2 +- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 +- .../wizards/DiscoveryTaskList.class.php | 135 ++++++++++-------- pandora_console/pandoradb.sql | 2 +- pandora_server/lib/PandoraFMS/Recon/Base.pm | 39 +++++ pandora_server/lib/PandoraFMS/Tools.pm | 2 + 6 files changed, 119 insertions(+), 63 deletions(-) diff --git a/pandora_console/extras/mr/30.sql b/pandora_console/extras/mr/30.sql index 2ea39573c2..d3c3b742b2 100644 --- a/pandora_console/extras/mr/30.sql +++ b/pandora_console/extras/mr/30.sql @@ -30,7 +30,7 @@ CREATE TABLE `tdeployment_hosts` ( `arch` ENUM('x64', 'x86') DEFAULT 'x64', `current_agent_version` VARCHAR(100) DEFAULT '', `desired_agent_version` VARCHAR(100) DEFAULT '', - `deployed` bigint(20) unsigned COMMENT "When it was deployed", + `deployed` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", `last_err` text, PRIMARY KEY (`id`), FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`) 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 fd9219ccc3..bdf79c59c0 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 @@ -2246,7 +2246,7 @@ CREATE TABLE `tdeployment_hosts` ( `arch` ENUM('x64', 'x86') DEFAULT 'x64', `current_agent_version` VARCHAR(100) DEFAULT '', `desired_agent_version` VARCHAR(100) DEFAULT '', - `deployed` bigint(20) unsigned COMMENT "When it was deployed", + `deployed` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", `last_err` text, PRIMARY KEY (`id`), FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`) diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index 586f24335b..e496bbf205 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -552,6 +552,17 @@ class DiscoveryTaskList extends Wizard $data[6] .= __('Discovery.App.Oracle'); break; + case DISCOVERY_DEPLOY_AGENTS: + // Internal deployment task. + $no_operations = true; + $data[6] = html_print_image( + 'images/deploy.png', + true, + ['title' => __('Agent deployment')] + ).'  '; + $data[6] .= __('Discovery.Agent.Deployment'); + break; + case DISCOVERY_HOSTDEVICES: default: if ($task['id_recon_script'] == 0) { @@ -595,71 +606,75 @@ class DiscoveryTaskList extends Wizard $data[8] = __('Not executed yet'); } - if ($task['disabled'] != 2) { - $data[9] = ''; - $data[9] .= html_print_image( - 'images/eye.png', - true - ); - $data[9] .= ''; - } - - if ($task['disabled'] != 2 && $task['utimestamp'] > 0 - && $task['type'] != DISCOVERY_APP_MYSQL - && $task['type'] != DISCOVERY_APP_ORACLE - && $task['type'] != DISCOVERY_CLOUD_AWS_RDS - ) { - $data[9] .= ''; - $data[9] .= html_print_image( - 'images/dynamic_network_icon.png', - true - ); - $data[9] .= ''; - } - - if (check_acl( - $config['id_user'], - $task['id_group'], - 'PM' - ) - ) { - if ($ipam === true) { - $data[9] .= ''.html_print_image( - 'images/config.png', + if (!$no_operations) { + if ($task['disabled'] != 2) { + $data[9] = ''; + $data[9] .= html_print_image( + 'images/eye.png', true - ).''; - $data[9] .= ''.html_print_image( - 'images/cross.png', + ); + $data[9] .= ''; + } + + if ($task['disabled'] != 2 && $task['utimestamp'] > 0 + && $task['type'] != DISCOVERY_APP_MYSQL + && $task['type'] != DISCOVERY_APP_ORACLE + && $task['type'] != DISCOVERY_CLOUD_AWS_RDS + ) { + $data[9] .= ''; + $data[9] .= html_print_image( + 'images/dynamic_network_icon.png', true - ).''; + ); + $data[9] .= ''; + } + + if (check_acl( + $config['id_user'], + $task['id_group'], + 'PM' + ) + ) { + if ($ipam === true) { + $data[9] .= ''.html_print_image( + 'images/config.png', + true + ).''; + $data[9] .= ''.html_print_image( + 'images/cross.png', + true + ).''; + } else { + // Check if is a H&D, Cloud or Application or IPAM. + $data[9] .= ''.html_print_image( + 'images/config.png', + true + ).''; + $data[9] .= ''.html_print_image( + 'images/cross.png', + true + ).''; + } } else { - // Check if is a H&D, Cloud or Application or IPAM. - $data[9] .= ''.html_print_image( - 'images/config.png', - true - ).''; - $data[9] .= ''.html_print_image( - 'images/cross.png', - true - ).''; + $data[9] = ''; } } else { - $data[9] = ''; + $data[9] = '-'; } $table->cellclass[][9] = 'action_buttons'; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index f3bed4951b..ad28ce9317 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -836,7 +836,7 @@ CREATE TABLE `tdeployment_hosts` ( `arch` ENUM('x64', 'x86') DEFAULT 'x64', `current_agent_version` VARCHAR(100) DEFAULT '', `desired_agent_version` VARCHAR(100) DEFAULT '', - `deployed` bigint(20) unsigned COMMENT "When it was deployed", + `deployed` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", `last_err` text, PRIMARY KEY (`id`), FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`) diff --git a/pandora_server/lib/PandoraFMS/Recon/Base.pm b/pandora_server/lib/PandoraFMS/Recon/Base.pm index 6c3e1b9ed5..223c36f248 100644 --- a/pandora_server/lib/PandoraFMS/Recon/Base.pm +++ b/pandora_server/lib/PandoraFMS/Recon/Base.pm @@ -1634,6 +1634,41 @@ sub app_scan($) { } + +########################################################################## +# Perform a deployment scan. +########################################################################## +sub deploy_scan($) { + my $self = shift; + my ($progress, $step); + + my $type = ''; + + # Initialize deployer object. + my $deployer = PandoraFMS::Recon::Util::enterprise_new( + 'PandoraFMS::Recon::Deployer', + [ + task_data => $self->{'task_data'}, + parent => $self + ] + + ); + + if (!$deployer) { + # Failed to initialize, check Cloud credentials or anything. + call('message', 'Unable to initialize PandoraFMS::Recon::Deployer', 3); + } else { + # Let deployer object manage scan. + $deployer->scan(); + } + + # Update progress. + # Done! + $self->{'step'} = ''; + $self->call('update_progress', -1); +} + + ########################################################################## # Perform a network scan. ########################################################################## @@ -1655,6 +1690,10 @@ sub scan($) { # Cloud scan. return $self->cloud_scan(); } + + if($self->{'task_data'}->{'type'} == DISCOVERY_DEPLOY_AGENTS) { + return $self->deploy_scan(); + } } # Find devices. diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 4a96c5851d..36050e4275 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -81,6 +81,7 @@ our @EXPORT = qw( DISCOVERY_CLOUD_AWS_EC2 DISCOVERY_CLOUD_AWS_RDS DISCOVERY_CLOUD_AZURE_COMPUTE + DISCOVERY_DEPLOY_AGENTS $DEVNULL $OS $OS_VERSION @@ -191,6 +192,7 @@ use constant DISCOVERY_APP_ORACLE => 5; use constant DISCOVERY_CLOUD_AWS_EC2 => 6; use constant DISCOVERY_CLOUD_AWS_RDS => 7; use constant DISCOVERY_CLOUD_AZURE_COMPUTE => 8; +use constant DISCOVERY_DEPLOY_AGENTS => 9; # Set OS, OS version and /dev/null our $OS = $^O; From 9b57ab8c13b8daad5cf2ce12928d805222863cde Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 17 Jul 2019 17:17:54 +0200 Subject: [PATCH 08/15] Review minor --- pandora_console/godmode/wizards/DiscoveryTaskList.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index e496bbf205..ed7e1f3b10 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -418,6 +418,7 @@ class DiscoveryTaskList extends Wizard $table->align[9] = 'left'; foreach ($recon_tasks as $task) { + $no_operations = false; $data = []; $server_name = servers_get_name($task['id_recon_server']); From 8d9c4682c7da5b748e1760d07a48d1aa29d51c57 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 17 Jul 2019 20:37:13 +0200 Subject: [PATCH 09/15] WIP Agent repository --- pandora_console/extras/mr/30.sql | 17 +++- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 19 +++- pandora_console/godmode/menu.php | 1 + pandora_console/godmode/servers/discovery.php | 4 +- .../godmode/wizards/HostDevices.class.php | 21 +++- .../include/functions_credential_store.php | 2 + pandora_console/include/javascript/pandora.js | 97 +++++++++++++++++++ .../include/styles/agent_repository.css | 29 ++++++ pandora_console/pandoradb.sql | 17 ++++ 9 files changed, 202 insertions(+), 5 deletions(-) create mode 100644 pandora_console/include/styles/agent_repository.css diff --git a/pandora_console/extras/mr/30.sql b/pandora_console/extras/mr/30.sql index 8c66c7b0a6..e8a9703835 100644 --- a/pandora_console/extras/mr/30.sql +++ b/pandora_console/extras/mr/30.sql @@ -38,7 +38,22 @@ CREATE TABLE `tdeployment_hosts` ( FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`) ON UPDATE CASCADE ON DELETE SET NULL, FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) - ON UPDATE CASCADE ON DELETE CASCADE + ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE `tagent_repository` ( + `id` SERIAL, + `id_os` INT(10) UNSIGNED DEFAULT 0, + `arch` ENUM('x64', 'x86') DEFAULT 'x64', + `version` VARCHAR(10) DEFAULT '', + `path` text, + `uploaded_by` VARCHAR(100) DEFAULT '', + `uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", + `last_err` text, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + COMMIT; 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 3fb25af44f..60c74f4a60 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 @@ -2253,5 +2253,22 @@ CREATE TABLE `tdeployment_hosts` ( FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`) ON UPDATE CASCADE ON DELETE SET NULL, FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) - ON UPDATE CASCADE ON DELETE CASCADE + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tagent_repository` +-- --------------------------------------------------------------------- +CREATE TABLE `tagent_repository` ( + `id` SERIAL, + `id_os` INT(10) UNSIGNED DEFAULT 0, + `arch` ENUM('x64', 'x86') DEFAULT 'x64', + `version` VARCHAR(10) DEFAULT '', + `path` text, + `uploaded_by` VARCHAR(100) DEFAULT '', + `uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", + `last_err` text, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) + ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index c9d9902b86..000a105257 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -129,6 +129,7 @@ if (check_acl($config['id_user'], 0, 'PM')) { $sub['godmode/modules/manage_network_templates']['id'] = 'Module templates'; enterprise_hook('inventory_submenu'); enterprise_hook('autoconfiguration_menu'); + enterprise_hook('agent_repository_menu'); } if (check_acl($config['id_user'], 0, 'AW')) { diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index edf7cc989e..3f2166bb39 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -93,7 +93,7 @@ function cl_load_cmp($a, $b) $classes = glob($config['homedir'].'/godmode/wizards/*.class.php'); if (enterprise_installed()) { $ent_classes = glob( - $config['homedir'].'/enterprise/godmode/wizards/*.class.php' + $config['homedir'].'/'.ENTERPRISE_DIR.'/godmode/wizards/*.class.php' ); if ($ent_classes === false) { $ent_classes = []; @@ -142,7 +142,7 @@ if ($classname_selected === null) { } } - // Show hints if there is no task + // Show hints if there is no task. if (get_parameter('discovery_hint', 0)) { ui_require_css_file('discovery-hint'); ui_print_info_message(__('You must create a task first')); diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 210717ff1b..fb9fba2cdd 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -156,11 +156,30 @@ class HostDevices extends Wizard ), 'label' => __('Discovery'), ], + [ + 'link' => ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd' + ), + 'label' => __('Host & Devices'), + 'selected' => true, + ], ], true ); - ui_print_page_header(__('Host & devices'), '', false, '', true, '', false, '', GENERIC_SIZE_TEXT, '', $this->printHeader(true)); + ui_print_page_header( + __('Host & devices'), + '', + false, + '', + true, + '', + false, + '', + GENERIC_SIZE_TEXT, + '', + $this->printHeader(true) + ); $this->printBigButtonsList($buttons); return; diff --git a/pandora_console/include/functions_credential_store.php b/pandora_console/include/functions_credential_store.php index 048c2bba00..1b64bba116 100644 --- a/pandora_console/include/functions_credential_store.php +++ b/pandora_console/include/functions_credential_store.php @@ -331,6 +331,8 @@ function print_inputs($values=null) case 'CUSTOM': $user_label = __('Account ID'); $pass_label = __('Password'); + $extra1 = false; + $extra2 = false; default: // Use defaults. break; diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 0fa503f81f..05009e7292 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -1870,3 +1870,100 @@ function logo_preview(icon_name, icon_path, incoming_options) { // console.log(err); } } + +// Advanced Form control. +/* global $ */ +/* exported load_modal */ +function load_modal(settings) { + var AJAX_RUNNING = 0; + var data = new FormData(); + if (settings.extradata) { + settings.extradata.forEach(function(item) { + if (item.value != undefined) data.append(item.name, item.value); + }); + } + data.append("page", settings.onshow.page); + data.append("method", settings.onshow.method); + + var width = 630; + if (settings.onshow.width) { + width = settings.onshow.width; + } + + $.ajax({ + method: "post", + url: settings.url, + processData: false, + contentType: false, + data: data, + success: function(data) { + settings.target.html(data); + settings.target.dialog({ + resizable: true, + draggable: true, + modal: true, + title: settings.modal.title, + width: width, + overlay: { + opacity: 0.5, + background: "black" + }, + buttons: [ + { + class: + "ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel", + text: settings.modal.cancel, + click: function() { + $(this).dialog("close"); + settings.cleanup(); + } + }, + { + class: + "ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next", + text: settings.modal.ok, + click: function() { + if (AJAX_RUNNING) return; + AJAX_RUNNING = 1; + var formdata = new FormData(); + if (settings.extradata) { + settings.extradata.forEach(function(item) { + if (item.value != undefined) + formdata.append(item.name, item.value); + }); + } + formdata.append("page", settings.onsubmit.page); + formdata.append("method", settings.onsubmit.method); + + $("#" + settings.form + " :input").each(function() { + if (this.type == "file") { + if ($(this).prop("files")[0]) { + formdata.append(this.name, $(this).prop("files")[0]); + } + } else { + formdata.append(this.name, $(this).val()); + } + }); + + $.ajax({ + method: "post", + url: settings.url, + processData: false, + contentType: false, + data: formdata, + success: function(data) { + settings.ajax_callback(data); + AJAX_RUNNING = 0; + } + }); + } + } + ], + closeOnEscape: false, + open: function() { + $(".ui-dialog-titlebar-close").hide(); + } + }); + } + }); +} diff --git a/pandora_console/include/styles/agent_repository.css b/pandora_console/include/styles/agent_repository.css new file mode 100644 index 0000000000..4f0794338d --- /dev/null +++ b/pandora_console/include/styles/agent_repository.css @@ -0,0 +1,29 @@ +ul.wizard li > label:not(.p-switch) { + width: auto; +} + +form.top-action-buttons ul.wizard { + display: flex; + flex-direction: row; +} + +ul.wizard li { + margin-right: 1em; +} + +form.modal ul.wizard li { + display: flex; + flex-direction: row; + width: 90%; + margin: 0.5em auto; + justify-items: center; +} + +form.modal ul.wizard li * { + flex: 1; +} + +ul.wizard li.flex-indep { + flex: 1; + margin: 0; +} diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 704e64ae2d..57c3f5c59b 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3646,3 +3646,20 @@ CREATE TABLE IF NOT EXISTS `tvisual_console_elements_cache` ( ON DELETE CASCADE ON UPDATE CASCADE ) engine=InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tagent_repository` +-- --------------------------------------------------------------------- +CREATE TABLE `tagent_repository` ( + `id` SERIAL, + `id_os` INT(10) UNSIGNED DEFAULT 0, + `arch` ENUM('x64', 'x86') DEFAULT 'x64', + `version` VARCHAR(10) DEFAULT '', + `path` text, + `uploaded_by` VARCHAR(100) DEFAULT '', + `uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", + `last_err` text, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; From 62d8c04ab3bf4798a241655a1d58918be0cb6993 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 23 Jul 2019 13:01:50 +0200 Subject: [PATCH 10/15] Agent deployment v1 --- pandora_console/extras/mr/30.sql | 42 ++++++++-------- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 48 ++++++++++--------- pandora_console/pandoradb.sql | 48 ++++++++++--------- .../lib/PandoraFMS/DiscoveryServer.pm | 6 +++ 4 files changed, 78 insertions(+), 66 deletions(-) diff --git a/pandora_console/extras/mr/30.sql b/pandora_console/extras/mr/30.sql index e8a9703835..dd8439745a 100644 --- a/pandora_console/extras/mr/30.sql +++ b/pandora_console/extras/mr/30.sql @@ -23,24 +23,6 @@ CREATE TABLE `ttask_credentials` ( ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE `tdeployment_hosts` ( - `id` SERIAL, - `id_cs` VARCHAR(100), - `ip` VARCHAR(100) NOT NULL UNIQUE, - `id_os` INT(10) UNSIGNED DEFAULT 0, - `os_version` VARCHAR(100) DEFAULT '' COMMENT "OS version in STR format", - `arch` ENUM('x64', 'x86') DEFAULT 'x64', - `current_agent_version` VARCHAR(100) DEFAULT '', - `desired_agent_version` VARCHAR(100) DEFAULT '', - `deployed` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", - `last_err` text, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`) - ON UPDATE CASCADE ON DELETE SET NULL, - FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - CREATE TABLE `tagent_repository` ( `id` SERIAL, `id_os` INT(10) UNSIGNED DEFAULT 0, @@ -48,12 +30,32 @@ CREATE TABLE `tagent_repository` ( `version` VARCHAR(10) DEFAULT '', `path` text, `uploaded_by` VARCHAR(100) DEFAULT '', - `uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", + `uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was uploaded", `last_err` text, PRIMARY KEY (`id`), - FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) + FOREIGN KEY (`id_os`) REFERENCES `tconfig_os`(`id_os`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE `tdeployment_hosts` ( + `id` SERIAL, + `id_cs` VARCHAR(100), + `ip` VARCHAR(100) NOT NULL UNIQUE, + `id_os` INT(10) UNSIGNED DEFAULT 0, + `os_version` VARCHAR(100) DEFAULT '' COMMENT "OS version in STR format", + `arch` ENUM('x64', 'x86') DEFAULT 'x64', + `current_agent_version` VARCHAR(100) DEFAULT '' COMMENT "String latest installed agent", + `target_agent_version_id` BIGINT UNSIGNED, + `deployed` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", + `last_err` text, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store`(`identifier`) + ON UPDATE CASCADE ON DELETE SET NULL, + FOREIGN KEY (`id_os`) REFERENCES `tconfig_os`(`id_os`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`target_agent_version_id`) REFERENCES `tagent_repository`(`id`) + ON UPDATE CASCADE ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + COMMIT; 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 60c74f4a60..40f192b32e 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 @@ -2235,27 +2235,6 @@ CREATE TABLE `ttask_credentials` ( ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ---------------------------------------------------------------------- --- Table `tdeployment_hosts` --- ---------------------------------------------------------------------- -CREATE TABLE `tdeployment_hosts` ( - `id` SERIAL, - `id_cs` VARCHAR(100), - `ip` VARCHAR(100) NOT NULL UNIQUE, - `id_os` INT(10) UNSIGNED DEFAULT 0, - `os_version` VARCHAR(100) DEFAULT '' COMMENT "OS version in STR format", - `arch` ENUM('x64', 'x86') DEFAULT 'x64', - `current_agent_version` VARCHAR(100) DEFAULT '', - `desired_agent_version` VARCHAR(100) DEFAULT '', - `deployed` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", - `last_err` text, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`) - ON UPDATE CASCADE ON DELETE SET NULL, - FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -- --------------------------------------------------------------------- -- Table `tagent_repository` -- --------------------------------------------------------------------- @@ -2266,9 +2245,32 @@ CREATE TABLE `tagent_repository` ( `version` VARCHAR(10) DEFAULT '', `path` text, `uploaded_by` VARCHAR(100) DEFAULT '', - `uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", + `uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was uploaded", `last_err` text, PRIMARY KEY (`id`), - FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) + FOREIGN KEY (`id_os`) REFERENCES `tconfig_os`(`id_os`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tdeployment_hosts` +-- ---------------------------------------------------------------------- +CREATE TABLE `tdeployment_hosts` ( + `id` SERIAL, + `id_cs` VARCHAR(100), + `ip` VARCHAR(100) NOT NULL UNIQUE, + `id_os` INT(10) UNSIGNED DEFAULT 0, + `os_version` VARCHAR(100) DEFAULT '' COMMENT "OS version in STR format", + `arch` ENUM('x64', 'x86') DEFAULT 'x64', + `current_agent_version` VARCHAR(100) DEFAULT '' COMMENT "String latest installed agent", + `target_agent_version_id` BIGINT UNSIGNED, + `deployed` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", + `last_err` text, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store`(`identifier`) + ON UPDATE CASCADE ON DELETE SET NULL, + FOREIGN KEY (`id_os`) REFERENCES `tconfig_os`(`id_os`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`target_agent_version_id`) REFERENCES `tagent_repository`(`id`) + ON UPDATE CASCADE ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 57c3f5c59b..b9a35fbb99 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -824,27 +824,6 @@ CREATE TABLE `ttask_credentials` ( ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ---------------------------------------------------------------------- --- Table `tdeployment_hosts` --- ---------------------------------------------------------------------- -CREATE TABLE `tdeployment_hosts` ( - `id` SERIAL, - `id_cs` VARCHAR(100), - `ip` VARCHAR(100) NOT NULL UNIQUE, - `id_os` INT(10) UNSIGNED DEFAULT 0, - `os_version` VARCHAR(100) DEFAULT '' COMMENT "OS version in STR format", - `arch` ENUM('x64', 'x86') DEFAULT 'x64', - `current_agent_version` VARCHAR(100) DEFAULT '', - `desired_agent_version` VARCHAR(100) DEFAULT '', - `deployed` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", - `last_err` text, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`) - ON UPDATE CASCADE ON DELETE SET NULL, - FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -- ---------------------------------------------------------------------- -- Table `tmodule_relationship` -- ---------------------------------------------------------------------- @@ -3657,9 +3636,32 @@ CREATE TABLE `tagent_repository` ( `version` VARCHAR(10) DEFAULT '', `path` text, `uploaded_by` VARCHAR(100) DEFAULT '', - `uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", + `uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was uploaded", `last_err` text, PRIMARY KEY (`id`), - FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) + FOREIGN KEY (`id_os`) REFERENCES `tconfig_os`(`id_os`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tdeployment_hosts` +-- ---------------------------------------------------------------------- +CREATE TABLE `tdeployment_hosts` ( + `id` SERIAL, + `id_cs` VARCHAR(100), + `ip` VARCHAR(100) NOT NULL UNIQUE, + `id_os` INT(10) UNSIGNED DEFAULT 0, + `os_version` VARCHAR(100) DEFAULT '' COMMENT "OS version in STR format", + `arch` ENUM('x64', 'x86') DEFAULT 'x64', + `current_agent_version` VARCHAR(100) DEFAULT '' COMMENT "String latest installed agent", + `target_agent_version_id` BIGINT UNSIGNED, + `deployed` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", + `last_err` text, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store`(`identifier`) + ON UPDATE CASCADE ON DELETE SET NULL, + FOREIGN KEY (`id_os`) REFERENCES `tconfig_os`(`id_os`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`target_agent_version_id`) REFERENCES `tagent_repository`(`id`) + ON UPDATE CASCADE ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index e91b580498..de3fa45f39 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -237,6 +237,12 @@ sub data_consumer ($$) { && -f $cnf_extra{'creds_file'}) { unlink($cnf_extra{'creds_file'}); } + + + # Clean one shot tasks + if ($task->{'type'} eq DISCOVERY_DEPLOY_AGENTS) { + db_delete_limit($dbh, ' trecon_task ', ' id_rt = ? ', 1, $task->{'id_rt'}); + } }; if ($@) { logger( From ce346bd60404d8809a8f0f40b308aab2179ceddf Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 24 Jul 2019 17:38:25 +0200 Subject: [PATCH 11/15] agent deployment --- pandora_console/extras/mr/30.sql | 1 + .../extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 1 + pandora_console/include/styles/pandora.css | 9 +++++++++ pandora_console/pandoradb.sql | 1 + pandora_server/lib/PandoraFMS/DiscoveryServer.pm | 1 + 5 files changed, 13 insertions(+) diff --git a/pandora_console/extras/mr/30.sql b/pandora_console/extras/mr/30.sql index dd8439745a..cb71a4bd4d 100644 --- a/pandora_console/extras/mr/30.sql +++ b/pandora_console/extras/mr/30.sql @@ -47,6 +47,7 @@ CREATE TABLE `tdeployment_hosts` ( `current_agent_version` VARCHAR(100) DEFAULT '' COMMENT "String latest installed agent", `target_agent_version_id` BIGINT UNSIGNED, `deployed` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", + `server_ip` varchar(100) default NULL COMMENT "Where to point target agent", `last_err` text, PRIMARY KEY (`id`), FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store`(`identifier`) 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 40f192b32e..b0e1ccb447 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 @@ -2265,6 +2265,7 @@ CREATE TABLE `tdeployment_hosts` ( `current_agent_version` VARCHAR(100) DEFAULT '' COMMENT "String latest installed agent", `target_agent_version_id` BIGINT UNSIGNED, `deployed` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", + `server_ip` varchar(100) default NULL COMMENT "Where to point target agent", `last_err` text, PRIMARY KEY (`id`), FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store`(`identifier`) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 94b1a54b15..8c12d11d04 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -437,8 +437,17 @@ select:-internal-list-box { * - GLOBAL STYLES - * --------------------------------------------------------------------- */ +.truncate { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.truncate:hover { + white-space: pre-wrap; +} .w120px { width: 120px; + max-width: 120px; } .mw120px { min-width: 120px; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index b9a35fbb99..8bd1c531b2 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3656,6 +3656,7 @@ CREATE TABLE `tdeployment_hosts` ( `current_agent_version` VARCHAR(100) DEFAULT '' COMMENT "String latest installed agent", `target_agent_version_id` BIGINT UNSIGNED, `deployed` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", + `server_ip` varchar(100) default NULL COMMENT "Where to point target agent", `last_err` text, PRIMARY KEY (`id`), FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store`(`identifier`) diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index de3fa45f39..ab9386666b 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -227,6 +227,7 @@ sub data_consumer ($$) { server_id => $server_id, %{$pa_config}, task_data => $task, + public_url => PandoraFMS::Config::pandora_get_tconfig_token($dbh, 'public_url', ''), %cnf_extra ); From 6ac21acd39c460365717cf2d324b6ddcdaf8e15c Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 25 Jul 2019 18:35:51 +0200 Subject: [PATCH 12/15] wip agent deployment scan --- pandora_console/godmode/groups/credential_store.php | 3 --- pandora_console/include/styles/deployment_list.css | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/groups/credential_store.php b/pandora_console/godmode/groups/credential_store.php index adea35f7c1..3273e1c038 100644 --- a/pandora_console/godmode/groups/credential_store.php +++ b/pandora_console/godmode/groups/credential_store.php @@ -588,9 +588,6 @@ echo '
  • '; text: 'OK', click: function(e) { var values = {}; - - console.log($('#form_new')); - $('#form_new :input').each(function() { values[this.name] = btoa($(this).val()); }); diff --git a/pandora_console/include/styles/deployment_list.css b/pandora_console/include/styles/deployment_list.css index 4f0794338d..e487207b05 100644 --- a/pandora_console/include/styles/deployment_list.css +++ b/pandora_console/include/styles/deployment_list.css @@ -27,3 +27,8 @@ ul.wizard li.flex-indep { flex: 1; margin: 0; } + +.datatable_filter.content li input[type="text"] { + width: 150px; + margin: 0 1em 0 0; +} From d504532d822599fabde4163a8b2f9a625e4ee8b5 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 26 Jul 2019 21:47:11 +0200 Subject: [PATCH 13/15] Agent deployment with candidate scan --- pandora_server/lib/PandoraFMS/DiscoveryServer.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index ab9386666b..2e2238fd16 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -354,9 +354,10 @@ sub PandoraFMS::Recon::Base::guess_os($$) { # Use xprobe2 if available if (-e $self->{pa_config}->{xprobe2}) { - my $output = `"$self->{pa_config}->{xprobe2}" $device 2>$DEVNULL | grep 'Running OS' | head -1`; - return OS_OTHER if ($? != 0); + my $output = `"$self->{pa_config}->{xprobe2}" $device 2>$DEVNULL | grep 'Running OS' | head -1`; + if ($? == 0) { return pandora_get_os($self->{'dbh'}, $output); + } } # Use nmap by default From db25d3b2316aab57f79c73f4d526e3c535fbc4fe Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 26 Jul 2019 21:56:37 +0200 Subject: [PATCH 14/15] Cleared unused table --- pandora_console/extras/mr/30.sql | 11 ----------- .../extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 14 -------------- pandora_console/pandoradb.sql | 14 -------------- 3 files changed, 39 deletions(-) diff --git a/pandora_console/extras/mr/30.sql b/pandora_console/extras/mr/30.sql index cb71a4bd4d..84e5adfa3e 100644 --- a/pandora_console/extras/mr/30.sql +++ b/pandora_console/extras/mr/30.sql @@ -12,17 +12,6 @@ ALTER TABLE `tmodule_relationship` ADD COLUMN `type` ENUM('direct', 'failover') ALTER TABLE `treport_content` MODIFY COLUMN `name` varchar(300) NULL; -CREATE TABLE `ttask_credentials` ( - `id_rt` int(10) unsigned NOT NULL, - `identifier` varchar(100) NOT NULL, - PRIMARY KEY (`id_rt`,`identifier`), - KEY `identifier` (`identifier`), - FOREIGN KEY (`id_rt`) REFERENCES `trecon_task` (`id_rt`) - ON DELETE CASCADE ON UPDATE CASCADE, - FOREIGN KEY (`identifier`) REFERENCES `tcredential_store` (`identifier`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - CREATE TABLE `tagent_repository` ( `id` SERIAL, `id_os` INT(10) UNSIGNED DEFAULT 0, 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 b0e1ccb447..1f759afabd 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 @@ -2221,20 +2221,6 @@ CREATE TABLE IF NOT EXISTS `tcredential_store` ( -- --------------------------------------------------------------------- ALTER TABLE `treport_content_sla_combined` ADD `id_agent_module_failover` int(10) unsigned NOT NULL; --- ---------------------------------------------------------------------- --- Table `ttask_credentials` --- ---------------------------------------------------------------------- -CREATE TABLE `ttask_credentials` ( - `id_rt` int(10) unsigned NOT NULL, - `identifier` varchar(100) NOT NULL, - PRIMARY KEY (`id_rt`,`identifier`), - KEY `identifier` (`identifier`), - FOREIGN KEY (`id_rt`) REFERENCES `trecon_task` (`id_rt`) - ON DELETE CASCADE ON UPDATE CASCADE, - FOREIGN KEY (`identifier`) REFERENCES `tcredential_store` (`identifier`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -- --------------------------------------------------------------------- -- Table `tagent_repository` -- --------------------------------------------------------------------- diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 8bd1c531b2..d1de66ab07 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -810,20 +810,6 @@ CREATE TABLE IF NOT EXISTS `trecon_task` ( KEY `recon_task_daemon` (`id_recon_server`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ---------------------------------------------------------------------- --- Table `ttask_credentials` --- ---------------------------------------------------------------------- -CREATE TABLE `ttask_credentials` ( - `id_rt` int(10) unsigned NOT NULL, - `identifier` varchar(100) NOT NULL, - PRIMARY KEY (`id_rt`,`identifier`), - KEY `identifier` (`identifier`), - FOREIGN KEY (`id_rt`) REFERENCES `trecon_task` (`id_rt`) - ON DELETE CASCADE ON UPDATE CASCADE, - FOREIGN KEY (`identifier`) REFERENCES `tcredential_store` (`identifier`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -- ---------------------------------------------------------------------- -- Table `tmodule_relationship` -- ---------------------------------------------------------------------- From d85b0141e4cb722d4ca2a76cdcc3292e2edf401e Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 29 Jul 2019 19:09:13 +0200 Subject: [PATCH 15/15] minor warning based on different configurations --- pandora_server/lib/PandoraFMS/DiscoveryServer.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index 2e2238fd16..6f7eab4c68 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -65,7 +65,8 @@ use constant { sub new ($$$$$$) { my ($class, $config, $dbh) = @_; - return undef unless $config->{'reconserver'} == 1 || $config->{'discoveryserver'} == 1; + return undef unless (defined($config->{'reconserver'}) && $config->{'reconserver'} == 1) + || (defined($config->{'discoveryserver'}) && $config->{'discoveryserver'} == 1); if (! -e $config->{'nmap'}) { logger ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Discovery Server not found.", 1);