Console changes for 8950

This commit is contained in:
Calvo 2022-06-08 13:10:01 +02:00
parent fc18c1a168
commit 5297123d17
6 changed files with 73 additions and 1 deletions

View File

@ -4,4 +4,8 @@ ALTER TABLE `tservice` ADD COLUMN `enable_sunburst` tinyint(1) NOT NULL default
ALTER TABLE `tdashboard` MODIFY `name` TEXT NOT NULL DEFAULT '';
ALTER TABLE `tagente` ADD COLUMN `satellite_server` INT NOT NULL default 0;
ALTER TABLE `tmetaconsole_agent` ADD COLUMN `satellite_server` INT NOT NULL default 0;
COMMIT;

View File

@ -1660,6 +1660,8 @@ ALTER TABLE tagente ADD COLUMN (alias varchar(600) not null default '');
ALTER TABLE tagente ADD `alias_as_name` int(2) unsigned default '0';
ALTER TABLE tagente ADD COLUMN `safe_mode_module` int(10) unsigned NOT NULL default '0';
ALTER TABLE `tagente` ADD COLUMN `cps` int NOT NULL default 0;
ALTER TABLE `tagente` ADD COLUMN `satellite_server` INT NOT NULL DEFAULT 0;
UPDATE tagente SET tagente.alias = tagente.nombre;

View File

@ -245,8 +245,11 @@ if (!$new_agent && $alias != '') {
}
// Remote configuration available.
$remote_agent = false;
if (isset($filename)) {
if (file_exists($filename['md5'])) {
$remote_agent = true;
$agent_name = agents_get_name($id_agente);
$agent_name = io_safe_output($agent_name);
$agent_md5 = md5($agent_name, false);
@ -427,6 +430,42 @@ $table_server .= html_print_select(
true
).'<div class="label_select_child_icons"></div></div></div>';
$table_satellite = '';
if ($remote_agent === true) {
// Satellite server selector.
$satellite_servers = db_get_all_rows_filter(
'tserver',
['server_type' => SERVER_TYPE_ENTERPRISE_SATELLITE],
[
'id_server',
'name',
]
);
$satellite_names = [];
if (empty($satellite_servers) === false) {
foreach ($satellite_servers as $s_server) {
$satellite_names[$s_server['id_server']] = $s_server['name'];
}
$table_satellite = '<div class="label_select"><p class="input_label">'.__('Satellite').'</p>';
$table_satellite .= '<div class="label_select_parent">';
$table_satellite .= html_print_input(
[
'type' => 'select',
'fields' => $satellite_names,
'name' => 'satellite_server',
'selected' => $satellite_server,
'nothing' => __('None'),
'nothinf_value' => 0,
'return' => true,
]
).'<div class="label_select_child_icons"></div></div></div>';
}
}
// Description.
$table_description = '<div class="label_select"><p class="input_label">'.__('Description').'</p>';
$table_description .= html_print_textarea(
@ -443,7 +482,7 @@ $table_description .= html_print_textarea(
echo '<div class="first_row">
<div class="box-shadow agent_options '.$agent_options_update.' white_box">
<div class="agent_options_column_left">'.$table_agent_name.$table_alias.$table_ip.$table_primary_group.'</div>
<div class="agent_options_column_right">'.$table_interval.$table_os.$table_server.$table_description.'</div>
<div class="agent_options_column_right">'.$table_interval.$table_os.$table_server.$table_satellite.$table_description.'</div>
</div>';
if (!$new_agent && $alias != '') {
echo $table_qr_code;

View File

@ -155,6 +155,7 @@ $alert_d7 = 1;
$alert_recovery = 0;
$alert_priority = 0;
$server_name = '';
$satellite_server = 0;
$grupo = 0;
$id_os = 9;
// Windows.
@ -985,6 +986,7 @@ if ($update_agent) {
$old_values = db_get_row('tagente', 'id_agente', $id_agente);
$fields = db_get_all_fields_in_table('tagent_custom_fields');
$secondary_groups = (string) get_parameter('secondary_hidden', '');
$satellite_server = (int) get_parameter('satellite_server', 0);
if ($fields === false) {
$fields = [];
@ -1092,6 +1094,7 @@ if ($update_agent) {
'quiet' => $quiet,
'cps' => $cps,
'safe_mode_module' => $safe_mode_module,
'satellite_server' => $satellite_server,
];
if ($config['metaconsole_agent_cache'] == 1) {
@ -1230,6 +1233,7 @@ if ($id_agente) {
$cps = $agent['cps'];
$safe_mode_module = $agent['safe_mode_module'];
$safe_mode = ($safe_mode_module) ? 1 : 0;
$satellite_server = (int) $agent['satellite_server'];
}
$update_module = (bool) get_parameter('update_module');

View File

@ -265,6 +265,27 @@ if ($has_remote_conf) {
['class' => 'invert_filter']
);
$remote_cfg .= __('Remote configuration enabled').'</p>';
$satellite_server = (int) db_get_value_filter(
'satellite_server',
'tagente',
['id_agente' => $id_agente]
);
if (empty($satellite_server) === false) {
$satellite_name = db_get_value_filter(
'name',
'tserver',
['id_server' => $satellite_server]
);
$remote_cfg .= '<p>'.html_print_image(
'images/satellite.png',
true,
['class' => 'invert_filter']
);
$remote_cfg .= __('Satellite server: ').$satellite_name.'</p>';
}
} else {
$remote_cfg = '';
}

View File

@ -88,6 +88,7 @@ CREATE TABLE IF NOT EXISTS `tagente` (
`alias_as_name` TINYINT NOT NULL DEFAULT 0,
`safe_mode_module` INT UNSIGNED NOT NULL DEFAULT 0,
`cps` INT NOT NULL DEFAULT 0,
`satellite_server` INT NOT NULL DEFAULT 0,
PRIMARY KEY (`id_agente`),
KEY `nombre` (`nombre`(255)),
KEY `direccion` (`direccion`),
@ -3468,6 +3469,7 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_agent` (
`alias_as_name` TINYINT NOT NULL DEFAULT 0,
`safe_mode_module` INT UNSIGNED NOT NULL DEFAULT 0,
`cps` INT NOT NULL DEFAULT 0,
`satellite_server` INT NOT NULL DEFAULT 0,
PRIMARY KEY (`id_agente`),
KEY `nombre` (`nombre`(255)),
KEY `direccion` (`direccion`),