Merge remote-tracking branch 'origin/develop' into ent-8676-consolas-visuales-en-consola-movil

This commit is contained in:
Daniel Barbero Martin 2022-03-14 09:01:27 +01:00
commit 78aa6f5a14
39 changed files with 877 additions and 368 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.760-220311
Version: 7.0NG.760-220314
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.760-220311"
pandora_version="7.0NG.760-220314"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -1015,7 +1015,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.760';
use constant AGENT_BUILD => '220311';
use constant AGENT_BUILD => '220314';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 7.0NG.760
%define release 220311
%define release 220314
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}
@ -24,7 +24,7 @@ Requires(preun): chkconfig /bin/rm /usr/sbin/userdel
Requires: coreutils unzip
Requires: util-linux procps grep
Requires: /sbin/ip /bin/awk
Requires: perl perl(Sys::Syslog) perl(IO::Compress::Zip)
Requires: perl(Sys::Syslog) perl(IO::Compress::Zip)
# Required by plugins
#Requires: sh-utils sed passwd net-tools rpm
AutoReq: 0

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 7.0NG.760
%define release 220311
%define release 220314
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.760"
PI_BUILD="220311"
PI_BUILD="220314"
OS_NAME=`uname -s`
FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{220311}
{220314}
ViewReadme
{Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.760 Build 220311")
#define PANDORA_VERSION ("7.0NG.760 Build 220314")
string pandora_path;
string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.760(Build 220311))"
VALUE "ProductVersion", "(7.0NG.760(Build 220314))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.760-220311
Version: 7.0NG.760-220314
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.760-220311"
pandora_version="7.0NG.760-220314"
package_pear=0
package_pandora=1

View File

@ -191,7 +191,7 @@ if ($disk_conf_delete) {
@unlink($filename['conf']);
}
echo '<form autocomplete="new-password" name="conf_agent" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente">';
echo '<form autocomplete="new-password" name="conf_agent" id="form_agent" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente">';
// Custom ID.
$custom_id_div = '<div class="label_select">';
@ -452,123 +452,14 @@ if (!$new_agent && $alias != '') {
echo '</div>';
if (enterprise_installed()) {
$secondary_groups_selected = enterprise_hook('agents_get_secondary_groups', [$id_agente]);
$adv_secondary_groups_label = '<div class="label_select"><p class="input_label">'.__('Secondary groups').'</p></div>';
$adv_secondary_groups_left = html_print_select_groups(
// Id_user.
// Use the current user to select the groups.
false,
// Privilege.
// ACL permission.
'AR',
// ReturnAllGroup.
// Not all group.
false,
// Name.
// HTML id.
'secondary_groups',
// Selected.
// No select any by default.
'',
// Script.
// Javascript onChange code.
'',
// Nothing.
// Do not user no selected value.
false,
// Nothing_value.
// Do not use no selected value.
0,
// Return.
// Return HTML (not echo).
true,
// Multiple.
// Multiple selection.
true,
// Sort.
// Sorting by default.
true,
// Class.
// CSS classnames (default).
'',
// Disabled.
// Not disabled (default).
false,
// Style.
// Inline styles (default).
'min-width:170px;',
// Option_style.
// Option style select (default).
false,
// Id_group.
// Do not truncate the users tree (default).
false,
// Keys_field.
// Key to get as value (default).
'id_grupo',
// Strict_user.
// Not strict user (default).
false,
// Delete_groups.
// Do not show the primary group in this selection.
array_merge(
(empty($secondary_groups_selected['plain']) === false) ? $secondary_groups_selected['plain'] : [],
[$agent['id_grupo']]
)
// Include_groups.
// Size.
// Simple_multiple_options.
);
$adv_secondary_groups_arrows = html_print_input_image(
'add_secondary',
'images/darrowright_green.png',
1,
'',
true,
[
'id' => 'right_autorefreshlist',
'title' => __('Add secondary groups'),
'onclick' => 'agent_manager_add_secondary_groups(event, '.$id_agente.');',
]
).html_print_input_image(
'remove_secondary',
'images/darrowleft_green.png',
1,
'',
true,
[
'id' => 'left_autorefreshlist',
'title' => __('Remove secondary groups'),
'onclick' => 'agent_manager_remove_secondary_groups(event, '.$id_agente.');',
]
);
$adv_secondary_groups_right .= html_print_select(
// Values.
$secondary_groups_selected['for_select'],
// HTML id.
'secondary_groups_selected',
// Selected.
'',
// Javascript onChange code.
'',
// Nothing selected.
false,
// Nothing selected.
0,
// Return HTML (not echo).
true,
// Multiple selection.
true,
// Sort.
true,
// Class.
'',
// Disabled.
false,
// Style.
'min-width:170px;'
$adv_secondary_groups_label = '<div class="label_select">';
$adv_secondary_groups_label .= '<p class="input_label">';
$adv_secondary_groups_label .= __('Secondary groups');
$adv_secondary_groups_label .= '</p>';
$adv_secondary_groups_label .= '</div>';
$select_agent_secondary = html_print_select_agent_secondary(
$agent,
$id_agente
);
// Safe operation mode.
@ -824,19 +715,15 @@ if (enterprise_installed()) {
}
// General display distribution.
$table_adv_options = $advanced_div.$adv_secondary_groups_label.'
<div class="sg_source">
'.$adv_secondary_groups_left.'
</div>
<div class="secondary_group_arrows">
'.$adv_secondary_groups_arrows.'
</div>
<div class="sg_target">
'.$adv_secondary_groups_right.'
</div>
</div>
<div class="agent_av_opt_right" >
'.$table_adv_parent.$table_adv_module_mode.$table_adv_cascade;
$table_adv_options = $advanced_div;
$table_adv_options .= $adv_secondary_groups_label;
$table_adv_options .= $select_agent_secondary;
$table_adv_options .= '</div>';
$table_adv_options .= '<div class="agent_av_opt_right" >';
$table_adv_options .= $table_adv_parent;
$table_adv_options .= $table_adv_module_mode;
$table_adv_options .= $table_adv_cascade;
if ($new_agent) {
// If agent is new, show custom id as old style format.
@ -1113,133 +1000,6 @@ ui_require_jquery_file('bgiframe');
}
}
function agent_manager_add_secondary_groups (event, id_agent) {
event.preventDefault();
var primary_value = $("#grupo").val()
// The selected primary value cannot be selected like secondary
if ($("#secondary_groups option:selected[value=" + primary_value + "]").length > 0) {
alert("<?php echo __('Primary group cannot be secondary too.'); ?>")
return
}
// On agent creation PHP will update the secondary groups table (not via AJAX)
if (id_agent == 0) {
agent_manager_add_secondary_groups_ui();
agent_manager_update_hidden_input_secondary();
return;
}
var selected_items = new Array();
$("#secondary_groups option:selected").each(function(){
selected_items.push($(this).val())
})
var data = {
page: "godmode/agentes/agent_manager",
id_agent: id_agent,
groups: selected_items,
add_secondary_groups: 1,
}
// Make the AJAX call to update the secondary groups
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "html",
data: data,
success: function (data) {
if (data == 1) {
agent_manager_add_secondary_groups_ui();
} else {
console.error("Error in AJAX call to add secondary groups")
}
},
error: function (data) {
console.error("Fatal error in AJAX call to add secondary groups")
}
});
}
function agent_manager_remove_secondary_groups (event, id_agent) {
event.preventDefault();
// On agent creation PHP will update the secondary groups table (not via AJAX)
if (id_agent == 0) {
agent_manager_remove_secondary_groups_ui();
agent_manager_update_hidden_input_secondary();
return;
}
var selected_items = new Array();
$("#secondary_groups_selected option:selected").each(function(){
selected_items.push($(this).val())
})
var data = {
page: "godmode/agentes/agent_manager",
id_agent: id_agent,
groups: selected_items,
remove_secondary_groups: 1,
}
// Make the AJAX call to update the secondary groups
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "html",
data: data,
success: function (data) {
if (data == 1) {
agent_manager_remove_secondary_groups_ui();
} else {
console.error("Error in AJAX call to add secondary groups")
}
},
error: function (data) {
console.error("Fatal error in AJAX call to add secondary groups")
}
});
}
// Move from left input to right input
function agent_manager_add_secondary_groups_ui () {
$("#secondary_groups_selected option[value=0]").remove()
$("#secondary_groups option:selected").each(function() {
$(this).remove().appendTo("#secondary_groups_selected")
})
}
// Move from right input to left input
function agent_manager_remove_secondary_groups_ui () {
// Remove the groups selected if success
$("#secondary_groups_selected option:selected").each(function(){
$(this).remove().appendTo("#secondary_groups")
})
// Add none if empty select
if ($("#secondary_groups_selected option").length == 0) {
$("#secondary_groups_selected").append($('<option>',{
value: 0,
text: "<?php echo __('None'); ?>"
}))
}
}
function agent_manager_update_hidden_input_secondary () {
var groups = [];
if(!$('form[name="conf_agent"] #secondary_hidden').length) {
$('form[name="conf_agent"]').append(
'<input name="secondary_hidden" type="hidden" id="secondary_hidden">'
);
}
var groups = new Array();
$("#secondary_groups_selected option").each(function() {
groups.push($(this).val())
})
$("#secondary_hidden").val(groups.join(','));
}
$(document).ready (function() {

View File

@ -985,7 +985,6 @@ if ($update_agent) {
$fields = db_get_all_fields_in_table('tagent_custom_fields');
$secondary_groups = (string) get_parameter('secondary_hidden', '');
if ($fields === false) {
$fields = [];
}

View File

@ -14,7 +14,7 @@
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -47,15 +47,17 @@ require_once $config['homedir'].'/include/functions_gis.php';
require_once $config['homedir'].'/include/functions_users.php';
enterprise_include_once('include/functions_config_agents.php');
if (is_ajax()) {
$get_n_conf_files = (bool) get_parameter('get_n_conf_files');
if ($get_n_conf_files) {
if (is_ajax() === true) {
$get_n_conf_files = (bool) get_parameter('get_n_conf_files', false);
$groups_secondary_selected = (bool) get_parameter('groups_secondary_selected', false);
if ($get_n_conf_files === true) {
$id_agents = get_parameter('id_agents');
$cont = 0;
foreach ($id_agents as $id_agent) {
$name = agents_get_name($id_agent);
$agent_md5 = md5($name);
if (file_exists($config['remote_config'].'/md5/'.$agent_md5.'.md5')) {
if (file_exists($config['remote_config'].'/md5/'.$agent_md5.'.md5') === true) {
$cont++;
}
}
@ -63,6 +65,24 @@ if (is_ajax()) {
echo $cont;
return;
}
if ($groups_secondary_selected === true) {
$groups = get_parameter('groups', []);
$groups_selected = get_parameter('groups_selected', []);
hd($groups, true);
hd($groups_selected, true);
$user_groups = users_get_groups($config['user'], 'AR', false);
$ret = [];
foreach ($user_groups as $id_gr => $name_group) {
if (in_array($id_gr, $groups) === false) {
$ret[$id_gr] = $name_group;
}
}
echo json_encode($ret);
return;
}
}
$update_agents = get_parameter('update_agents', 0);
@ -140,6 +160,9 @@ if ($update_agents) {
$values['safe_mode_module'] = '0';
}
$secondary_groups_added = (array) get_parameter('secondary_groups_added', []);
$secondary_groups_removed = (array) get_parameter('secondary_groups_removed', []);
$fields = db_get_all_fields_in_table('tagent_custom_fields');
if ($fields === false) {
@ -213,7 +236,7 @@ if ($update_agents) {
}
$n_edited = 0;
$result = false;
$result = [];
foreach ($id_agents as $id_agent) {
$old_interval_value = db_get_value_filter('intervalo', 'tagente', ['id_agente' => $id_agent]);
@ -231,20 +254,20 @@ if ($update_agents) {
$values['safe_mode_module'] = $id_module_safe[$id_agent];
}
$result = db_process_sql_update(
$result[$id_agent]['db'] = db_process_sql_update(
'tagente',
$values,
['id_agente' => $id_agent]
);
if ($result && $config['metaconsole_agent_cache'] == 1) {
if ($result[$id_agent]['db'] && $config['metaconsole_agent_cache'] == 1) {
$server_name['server_name'] = db_get_sql('SELECT server_name FROM tagente WHERE id_agente ='.$id_agent);
// Force an update of the agent cache.
$result_metaconsole = agent_update_from_cache($id_agent, $values, $server_name);
}
// Update the configuration files.
if ($result && ($old_interval_value != $values['intervalo']) && !empty($values['intervalo'])) {
if ($result[$id_agent]['db'] && ($old_interval_value != $values['intervalo']) && !empty($values['intervalo'])) {
enterprise_hook(
'config_agents_update_config_token',
[
@ -288,7 +311,7 @@ if ($update_agents) {
if ($old_value === false) {
// Create custom field if not exist.
$result = db_process_sql_insert(
$result[$id_agent]['fields'][$field['id_field']] = db_process_sql_insert(
'tagent_custom_data',
[
'id_field' => $key,
@ -298,7 +321,7 @@ if ($update_agents) {
);
} else {
if ($old_value[0]['description'] !== $value) {
$result = db_process_sql_update(
$result[$id_agent]['fields'][$field['id_field']] = db_process_sql_update(
'tagent_custom_data',
['description' => $value],
[
@ -311,36 +334,160 @@ if ($update_agents) {
}
}
$n_edited += (int) $result;
}
// Create or Remove the secondary groups.
if (empty($secondary_groups_added) === false
|| empty($secondary_groups_removed) === false
) {
$result[$id_agent]['secondary'] = enterprise_hook(
'agents_update_secondary_groups',
[
$id_agent,
$secondary_groups_added,
$secondary_groups_removed,
true,
]
);
}
if ($result !== false) {
db_pandora_audit(
AUDIT_LOG_MASSIVE_MANAGEMENT,
'Update agent '.$id_agent,
false,
false,
json_encode($info)
);
} else {
if (isset($id_agent)) {
if ($result['db'] !== false) {
db_pandora_audit(
AUDIT_LOG_MASSIVE_MANAGEMENT,
'Try to update agent '.$id_agent,
'Update agent '.$id_agent,
false,
false,
json_encode($info)
);
} else {
if (isset($id_agent) === true) {
db_pandora_audit(
AUDIT_LOG_MASSIVE_MANAGEMENT,
'Try to update agent '.$id_agent,
false,
false,
json_encode($info)
);
}
}
}
$ret = [];
foreach ($result as $id_agent => $item) {
if ($item['db'] !== false) {
$ret['db']['edited'] += 1;
$ret['db']['edited_agent'][] = $id_agent;
} else {
$ret['db']['failed'] += 1;
$ret['db']['failed_agent'][] = $id_agent;
}
ui_print_result_message(
$result !== false,
__('Agents updated successfully (%d)', $n_edited),
__('Agents cannot be updated (maybe there was no field to update)')
);
if (isset($item['fields']) === true
&& empty($item['fields']) === false
) {
foreach ($item['fields'] as $kfield => $vfield) {
if ($vfield !== false) {
$ret['fields'][$id_agent]['edited'] += 1;
$ret['fields'][$id_agent]['edited_field'][] = $kfield;
} else {
$ret['fields'][$id_agent]['failed'] += 1;
$ret['fields'][$id_agent]['failed_field'][] = $kfield;
}
}
}
if (isset($item['secondary']) === true
&& empty($item['secondary']) === false
) {
foreach ($item['secondary'] as $type_action => $values_secondary) {
foreach ($values_secondary as $kgr => $vgr) {
if ($vgr !== false) {
$ret['secondary'][$type_action][$id_agent]['edited'] += 1;
$ret['secondary'][$type_action][$id_agent]['edited_gr'][] = $kgr;
} else {
$ret['secondary'][$type_action][$id_agent]['failed'] += 1;
$ret['secondary'][$type_action][$id_agent]['failed_gr'][] = $kgr;
}
}
}
}
}
foreach ($ret as $type => $ret_val) {
switch ($type) {
case 'db':
if (isset($ret_val['edited']) === true
&& $ret_val['edited'] > 0
) {
ui_print_success_message(
__(
'Agents updated successfully (%d)',
$ret_val['edited'],
implode(
',',
$ret_val['edited_agent']
)
)
);
}
if (isset($ret_val['failed']) === true
&& $ret_val['failed'] > 0
) {
ui_print_error_message(
__(
'Agents cannot be updated (%d), ids (%s)',
$ret_val['failed'],
implode(',', $ret_val['failed_agent'])
)
);
}
break;
case 'fields':
$str = '';
foreach ($ret_val as $kag => $vag) {
if (isset($vag['failed']) === true
&& $vag['failed'] > 0
) {
$str .= __(
'Agent ID: %s cannot be updated custom fields (%s)',
$kag,
implode(',', $vag['failed_field'])
).'<br>';
}
}
if (empty($str) === false) {
ui_print_error_message($str);
}
break;
case 'secondary':
$str = '';
foreach ($ret_val as $type => $values_secondary) {
foreach ($values_secondary as $kag => $vag) {
if (isset($vag['failed']) === true
&& $vag['failed'] > 0
) {
$str .= __(
'Agent ID: %s cannot be updated %s secondary groups (%s)',
$kag,
$type,
implode(',', $vag['failed_gr'])
).'<br>';
}
}
}
if (empty($str) === false) {
ui_print_error_message($str);
}
break;
default:
// Not posible.
break;
}
}
}
$id_group = 0;
@ -526,7 +673,16 @@ $table->data[0][1] .= '<b>'.__('Cascade protection').'</b>'.html_print_select(
true
);
$table->data[0][1] .= '&nbsp;&nbsp;'.__('Module').'&nbsp;'.html_print_select($modules, 'cascade_protection_module', $cascade_protection_module, '', '', 0, true);
$table->data[0][1] .= '&nbsp;&nbsp;'.__('Module').'&nbsp;';
$table->data[0][1] .= html_print_select(
$modules,
'cascade_protection_module',
$cascade_protection_module,
'',
'',
0,
true
);
$table->data[1][0] = __('Group');
$table->data[1][1] = '<div class="w290px inline">';
@ -550,7 +706,17 @@ $table->data[1][1] .= '</div>';
$table->data[2][0] = __('Interval');
$table->data[2][1] = html_print_extended_select_for_time('interval', 0, '', __('No change'), '0', 10, true, 'width: 150px', false);
$table->data[2][1] = html_print_extended_select_for_time(
'interval',
0,
'',
__('No change'),
'0',
10,
true,
'width: 150px',
false
);
$table->data[3][0] = __('OS');
$table->data[3][1] = html_print_select_from_sql(
@ -594,7 +760,14 @@ $table->data[4][1] = html_print_select(
// Description.
$table->data[5][0] = __('Description');
$table->data[5][1] = html_print_input_text('description', $description, '', 45, 255, true);
$table->data[5][1] = html_print_input_text(
'description',
$description,
'',
45,
255,
true
);
html_print_table($table);
unset($table);
@ -627,18 +800,148 @@ $table->data = [];
$table->data[0][0] = __('Custom ID');
$table->data[0][1] = html_print_input_text('custom_id', $custom_id, '', 16, 255, true);
// Secondary Groups.
if (enterprise_installed() === true) {
$groups = users_get_groups($config['id_user'], 'AW', false);
$table->data['secondary_groups_added'][0] = __('Add secondary groups');
$table->data['secondary_groups_added'][1] = html_print_select(
$groups,
'secondary_groups_added[]',
0,
false,
'',
'',
true,
true,
true,
'',
false,
'min-width: 500px; max-width: 500px; max-height: 100px',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true
);
$table->data['secondary_groups_removed'][0] = __('Remove secondary groups');
$table->data['secondary_groups_removed'][1] = html_print_select(
$groups,
'secondary_groups_removed[]',
0,
false,
'',
'',
true,
true,
true,
'',
false,
'min-width: 500px; max-width: 500px; max-height: 100px',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true
);
}
// Learn mode / Normal mode.
$table->data[1][0] = __('Module definition');
$table->data[1][1] = __('No change').' '.html_print_radio_button_extended('mode', -1, '', $mode, false, '', 'class="mrgn_right_40px"', true);
$table->data[1][1] .= __('Learning mode').' '.html_print_radio_button_extended('mode', 1, '', $mode, false, '', 'class="mrgn_right_40px"', true);
$table->data[1][1] .= __('Normal mode').' '.html_print_radio_button_extended('mode', 0, '', $mode, false, '', 'class="mrgn_right_40px"', true);
$table->data[1][1] .= __('Autodisable mode').' '.html_print_radio_button_extended('mode', 2, '', $mode, false, '', 'class="mrgn_right_40px"', true);
$table->data[1][1] = __('No change').' ';
$table->data[1][1] .= html_print_radio_button_extended(
'mode',
-1,
'',
$mode,
false,
'',
'class="mrgn_right_40px"',
true
);
$table->data[1][1] .= __('Learning mode').' ';
$table->data[1][1] .= html_print_radio_button_extended(
'mode',
1,
'',
$mode,
false,
'',
'class="mrgn_right_40px"',
true
);
$table->data[1][1] .= __('Normal mode').' ';
$table->data[1][1] .= html_print_radio_button_extended(
'mode',
0,
'',
$mode,
false,
'',
'class="mrgn_right_40px"',
true
);
$table->data[1][1] .= __('Autodisable mode').' ';
$table->data[1][1] .= html_print_radio_button_extended(
'mode',
2,
'',
$mode,
false,
'',
'class="mrgn_right_40px"',
true
);
// Status (Disabled / Enabled).
$table->data[2][0] = __('Status');
$table->data[2][1] = __('No change').' '.html_print_radio_button_extended('disabled', -1, '', $disabled, false, '', 'class="mrgn_right_40px"', true);
$table->data[2][1] .= __('Disabled').' '.ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true).' '.html_print_radio_button_extended('disabled', 1, '', $disabled, false, '', 'class="mrgn_right_40px"', true);
$table->data[2][1] .= __('Active').' '.html_print_radio_button_extended('disabled', 0, '', $disabled, false, '', 'class="mrgn_right_40px"', true);
$table->data[2][1] = __('No change').' ';
$table->data[1][1] .= html_print_radio_button_extended(
'disabled',
-1,
'',
$disabled,
false,
'',
'class="mrgn_right_40px"',
true
);
$table->data[2][1] .= __('Disabled').' ';
$table->data[1][1] .= ui_print_help_tip(
__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'),
true
).' ';
$table->data[1][1] .= html_print_radio_button_extended(
'disabled',
1,
'',
$disabled,
false,
'',
'class="mrgn_right_40px"',
true
);
$table->data[2][1] .= __('Active').' ';
$table->data[1][1] .= html_print_radio_button_extended(
'disabled',
0,
'',
$disabled,
false,
'',
'class="mrgn_right_40px"',
true
);
// Remote configuration.
$table->data[3][0] = __('Remote configuration');
@ -813,7 +1116,6 @@ attachActionButton('update_agents', 'update', $table->width);
echo '</div></form>';
ui_require_jquery_file('form');
ui_require_jquery_file('pandora.controls');
ui_require_jquery_file('ajaxqueue');
ui_require_jquery_file('bgiframe');
@ -912,25 +1214,26 @@ $(document).ready (function () {
jQuery.each ($("#id_agents option:selected"), function (i, val) {
idAgents.push($(val).val());
});
jQuery.post ("ajax.php",
{"page" : "godmode/massive/massive_edit_agents",
jQuery.post (
"ajax.php",
{
"page" : "godmode/massive/massive_edit_agents",
"get_n_conf_files" : 1,
"id_agents[]" : idAgents
},
function (data, status) {
if (data == 0) {
$("#delete_configurations").attr("style", "display: none");
$("#not_available_configurations").attr("style", "");
}
else {
$("#n_configurations").text(data);
$("#not_available_configurations").attr("style", "display: none");
$("#delete_configurations").attr("style", "");
}
},
"json"
);
},
function (data, status) {
if (data == 0) {
$("#delete_configurations").attr("style", "display: none");
$("#not_available_configurations").attr("style", "");
}
else {
$("#n_configurations").text(data);
$("#not_available_configurations").attr("style", "display: none");
$("#delete_configurations").attr("style", "");
}
},
"json"
);
$("#form_agents").attr("style", "");
if($("#safe_mode_change").val() == 1) {
@ -970,8 +1273,41 @@ $(document).ready (function () {
disabled = 2;
//$("#id_group").trigger("change");
$("#status_agents").change(function() {
$("#id_group").trigger("change");
});
$("#secondary_groups_added").change(
function() {
var groups = $("#secondary_groups_added").val();
var groups_selected = $("#secondary_groups_removed").val();
jQuery.post (
"ajax.php",
{
"page" : "godmode/massive/massive_edit_agents",
"groups_secondary_selected" : 1,
"groups" : groups
},
function (data, status) {
$('#secondary_groups_removed').empty();
$('#secondary_groups_removed').val(null).trigger("change");
if($.type(data) === "object"){
jQuery.each (data, function (id, value) {
option = $("<option></option>").attr("value", id).html(value);
if (inArray(id, groups_selected) === true) {
option.attr("selected", true);
}
$("#secondary_groups_removed").append(option).trigger("change");
});
} else {
option = $("<option></option>").attr("value", '').html('None');
$("#secondary_groups_removed").append(option).trigger("change");
}
},
"json"
);
}
);
});
function changeIcons() {

View File

@ -3556,25 +3556,6 @@ if ($enterpriseEnable && defined('METACONSOLE')) {
}
if ($resultOperationDB !== null) {
$err = '';
switch ($_POST['type']) {
case 'custom_graph':
$err .= 'You must enter custom graph';
break;
case 'SLA':
$err .= 'You must enter some character in SLA limit field';
default:
$err .= '';
break;
}
ui_print_result_message(
$resultOperationDB,
__('Successfull action'),
__('Unsuccessful action<br><br>'.$err)
);
if ($action == 'update') {
$buttons[$activeTab]['active'] = false;
$activeTab = 'list_items';
@ -3602,6 +3583,25 @@ if ($resultOperationDB !== null) {
);
}
}
$err = '';
switch ($_POST['type']) {
case 'custom_graph':
$err .= 'You must enter custom graph';
break;
case 'SLA':
$err .= 'You must enter some character in SLA limit field';
default:
$err .= '';
break;
}
ui_print_result_message(
$resultOperationDB,
__('Successfull action'),
__('Unsuccessful action<br><br>'.$err)
);
}
switch ($activeTab) {

View File

@ -47,6 +47,8 @@ if (isset($_GET['server'])) {
$exec_server_enable = __('Yes');
}
$table = new stdClass();
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = '100%';

View File

@ -167,8 +167,10 @@ class Tree
*/
protected function getDisabledFilter()
{
$only_disabled = (is_metaconsole() === true) ? (int) $this->filter['show_disabled'] : 0;
if (empty($this->filter['showDisabled'])) {
return ' tam.disabled = 0 AND ta.disabled = 0';
return ' tam.disabled = 0 AND ta.disabled = '.$only_disabled;
}
return ' 1 = 1';

View File

@ -311,13 +311,14 @@ class TreeGroup extends Tree
$table = is_metaconsole() ? 'tmetaconsole_agent' : 'tagente';
$table_sec = is_metaconsole() ? 'tmetaconsole_agent_secondary_group' : 'tagent_secondary_group';
$only_disabled = (is_metaconsole() === true) ? (int) $this->filter['show_disabled'] : 0;
$sql_model = "SELECT %s FROM
(
SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_grupo AS g
FROM $table ta
$module_search_inner
WHERE ta.disabled = 0
WHERE ta.disabled = $only_disabled
%s
$agent_search_filter
$agent_status_filter
@ -330,7 +331,7 @@ class TreeGroup extends Tree
FROM $table ta INNER JOIN $table_sec tasg
ON ta.id_agente = tasg.id_agent
$module_search_inner
WHERE ta.disabled = 0
WHERE ta.disabled = $only_disabled
%s
$agent_search_filter
$agent_status_filter

View File

@ -20,7 +20,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC220311';
$build_version = 'PC220314';
$pandora_version = 'v7.0NG.760';
// Do not overwrite default timezone set if defined.

View File

@ -5734,3 +5734,198 @@ function html_print_select_search(
echo $output;
}
}
/**
* Print html select for agents secondary.
*
* @param integer $agent Agent.
* @param integer $id_agente Id Agent.
* @param array $options Array options.
*
* @return string Html output.
*/
function html_print_select_agent_secondary($agent, $id_agente, $options=[])
{
ui_require_css_file('agent_manager');
ui_require_javascript_file('pandora_agents');
if (empty($options) === '' || isset($options['id_form']) === false) {
$options['id_form'] = 'form_agent';
}
if (empty($options) === '' || isset($options['extra_id']) === false) {
$options['extra_id'] = '';
}
if (empty($options) === '' || isset($options['only_select']) === false) {
$options['only_select'] = false;
}
$secondary_groups_selected = enterprise_hook(
'agents_get_secondary_groups',
[$id_agente]
);
$name = 'secondary_groups'.$options['extra_id'];
if ($options['only_select'] === true) {
$name = 'secondary_groups'.$options['extra_id'].'[]';
}
$adv_secondary_groups_left = html_print_select_groups(
// Id_user.
// Use the current user to select the groups.
false,
// Privilege.
// ACL permission.
'AR',
// ReturnAllGroup.
// Not all group.
false,
// Name.
// HTML id.
$name,
// Selected.
// No select any by default.
'',
// Script.
// Javascript onChange code.
'',
// Nothing.
// Do not user no selected value.
false,
// Nothing_value.
// Do not use no selected value.
0,
// Return.
// Return HTML (not echo).
true,
// Multiple.
// Multiple selection.
true,
// Sort.
// Sorting by default.
true,
// Class.
// CSS classnames (default).
'',
// Disabled.
// Not disabled (default).
false,
// Style.
// Inline styles (default).
'min-width:170px;',
// Option_style.
// Option style select (default).
false,
// Id_group.
// Do not truncate the users tree (default).
false,
// Keys_field.
// Key to get as value (default).
'id_grupo',
// Strict_user.
// Not strict user (default).
false,
// Delete_groups.
// Do not show the primary group in this selection.
array_merge(
(empty($secondary_groups_selected['plain']) === false) ? $secondary_groups_selected['plain'] : [],
[$agent['id_grupo']]
)
// Include_groups.
// Size.
// Simple_multiple_options.
);
if ($options['only_select'] === false) {
$dictionary = base64_encode(
json_encode(
[
'primary_group' => __('Primary group cannot be secondary too.'),
'strNone' => __('None'),
]
)
);
$adv_secondary_groups_arrows = html_print_input_image(
'add_secondary',
'images/darrowright_green.png',
1,
'',
true,
[
'id' => 'right_autorefreshlist'.$options['extra_id'],
'title' => __('Add secondary groups'),
'onclick' => 'agent_manager_add_secondary_groups(event, '.$id_agente.',\''.$options['extra_id'].'\', \''.$options['id_form'].'\', \''.$dictionary.'\');',
]
);
$adv_secondary_groups_arrows .= html_print_input_image(
'remove_secondary',
'images/darrowleft_green.png',
1,
'',
true,
[
'id' => 'left_autorefreshlist'.$options['extra_id'],
'title' => __('Remove secondary groups'),
'onclick' => 'agent_manager_remove_secondary_groups(event, '.$id_agente.',\''.$options['extra_id'].'\', \''.$options['id_form'].'\', \''.$dictionary.'\');',
]
);
$adv_secondary_groups_right .= html_print_select(
// Values.
$secondary_groups_selected['for_select'],
// HTML id.
'secondary_groups_selected'.$options['extra_id'],
// Selected.
'',
// Javascript onChange code.
'',
// Nothing selected.
false,
// Nothing selected.
0,
// Return HTML (not echo).
true,
// Multiple selection.
true,
// Sort.
true,
// Class.
'',
// Disabled.
false,
// Style.
'min-width:170px;'
);
$output = '';
if (isset($options['container']) === true
&& $options['container'] === true
) {
$output = '<div class="secondary_groups_list">';
}
$output .= '<div class="sg_source">';
$output .= $adv_secondary_groups_left;
$output .= '</div>';
$output .= '<div class="secondary_group_arrows">';
$output .= $adv_secondary_groups_arrows;
$output .= '</div>';
$output .= '<div class="sg_target">';
$output .= $adv_secondary_groups_right;
$output .= '</div>';
if (isset($options['container']) === true
&& $options['container'] === true
) {
$output .= '</div>';
}
} else {
$output .= $adv_secondary_groups_left;
}
return $output;
}

View File

@ -2017,3 +2017,11 @@ function progressBarSvg(option) {
return svg;
}
function inArray(needle, haystack) {
var length = haystack.length;
for (var i = 0; i < length; i++) {
if (haystack[i] == needle) return true;
}
return false;
}

View File

@ -0,0 +1,169 @@
/* globals $ */
// eslint-disable-next-line no-unused-vars
function agent_manager_add_secondary_groups(
event,
id_agent,
extra_id,
id_form,
dictionary
) {
event.preventDefault();
var primary_value = $("#grupo").val();
dictionary = JSON.parse(atob(dictionary));
// The selected primary value cannot be selected like secondary.
if (
$(
"#secondary_groups" +
extra_id +
" option:selected[value=" +
primary_value +
"]"
).length > 0
) {
alert(dictionary.primary_group);
return;
}
// On agent creation PHP will update the secondary groups table (not via AJAX).
if (id_agent == 0) {
agent_manager_add_secondary_groups_ui(extra_id);
agent_manager_update_hidden_input_secondary(id_form, extra_id);
return;
}
var selected_items = new Array();
$("#secondary_groups" + extra_id + " option:selected").each(function() {
selected_items.push($(this).val());
});
var data = {
page: "godmode/agentes/agent_manager",
id_agent: id_agent,
groups: selected_items,
add_secondary_groups: 1
};
// Make the AJAX call to update the secondary groups.
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "html",
data: data,
success: function(data) {
if (data == 1) {
agent_manager_add_secondary_groups_ui(extra_id);
} else {
console.error("Error in AJAX call to add secondary groups");
}
},
error: function(data) {
console.error(
"Fatal error in AJAX call to add secondary groups: " + data
);
}
});
}
// eslint-disable-next-line no-unused-vars
function agent_manager_remove_secondary_groups(
event,
id_agent,
extra_id,
id_form,
dictionary
) {
event.preventDefault();
dictionary = JSON.parse(atob(dictionary));
// On agent creation PHP will update the secondary groups table (not via AJAX).
if (id_agent == 0) {
agent_manager_remove_secondary_groups_ui(dictionary.strNone, extra_id);
agent_manager_update_hidden_input_secondary(id_form, extra_id);
return;
}
var selected_items = new Array();
$("#secondary_groups_selected" + extra_id + " option:selected").each(
function() {
selected_items.push($(this).val());
}
);
var data = {
page: "godmode/agentes/agent_manager",
id_agent: id_agent,
groups: selected_items,
remove_secondary_groups: 1
};
// Make the AJAX call to update the secondary groups.
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "html",
data: data,
success: function(data) {
if (data == 1) {
agent_manager_remove_secondary_groups_ui(dictionary.strNone, extra_id);
} else {
console.error("Error in AJAX call to add secondary groups");
}
},
error: function(data) {
console.error(
"Fatal error in AJAX call to add secondary groups: " + data
);
}
});
}
// Move from left input to right input.
function agent_manager_add_secondary_groups_ui(extra_id) {
$("#secondary_groups_selected" + extra_id + " option[value=0]").remove();
$("#secondary_groups" + extra_id + " option:selected").each(function() {
$(this)
.remove()
.appendTo("#secondary_groups_selected" + extra_id);
});
}
// Move from right input to left input.
function agent_manager_remove_secondary_groups_ui(strNone, extra_id) {
// Remove the groups selected if success.
$("#secondary_groups_selected" + extra_id + " option:selected").each(
function() {
$(this)
.remove()
.appendTo("#secondary_groups" + extra_id);
}
);
// Add none if empty select.
if ($("#secondary_groups_selected" + extra_id + " option").length == 0) {
$("#secondary_groups_selected" + extra_id).append(
$("<option>", {
value: 0,
text: strNone
})
);
}
}
function agent_manager_update_hidden_input_secondary(id_form, extra_id) {
var groups = [];
if (!$("#" + id_form + " #secondary_hidden" + extra_id).length) {
$("#" + id_form).append(
'<input name="secondary_hidden' +
extra_id +
'" type="hidden" id="secondary_hidden' +
extra_id +
'">'
);
}
$("#secondary_groups_selected" + extra_id + " option").each(function() {
groups.push($(this).val());
});
$("#secondary_hidden" + extra_id).val(groups.join(","));
}

View File

@ -59,7 +59,26 @@ function show_event_dialog(event, dialog_page, result) {
background: "black"
},
width: 710,
height: 600
height: 600,
autoOpen: true,
open: function() {
if (
$.ui &&
$.ui.dialog &&
$.ui.dialog.prototype._allowInteraction
) {
var ui_dialog_interaction =
$.ui.dialog.prototype._allowInteraction;
$.ui.dialog.prototype._allowInteraction = function(e) {
if ($(e.target).closest(".select2-dropdown").length)
return true;
return ui_dialog_interaction.apply(this, arguments);
};
}
},
_allowInteraction: function(event) {
return !!$(event.target).is(".select2-input") || this._super(event);
}
})
.show();
$.post({

View File

@ -7678,6 +7678,11 @@ div.graph div.legend table {
float: left;
}
#table3-secondary_groups_added .select2-container,
#table3-secondary_groups_removed .select2-container {
width: 100% !important;
}
.ux_console_module {
float: left;
width: 98%;

View File

@ -129,7 +129,7 @@
<div style='height: 10px'>
<?php
$version = '7.0NG.760';
$build = '220311';
$build = '220314';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -365,7 +365,7 @@ $data[1] = ui_progress(
($agent['intervalo'] - (strtotime('now') - strtotime($agent['ultimo_contacto']))).' s',
[
'page' => 'operation/agentes/ver_agente',
'interval' => (100 / $agent['intervalo']),
'interval' => (empty($agent['intervalo']) === true) ? 0 : (100 / $agent['intervalo']),
'data' => [
'id_agente' => $id_agente,
'refresh_contact' => 1,

View File

@ -45,6 +45,8 @@ $group_id = (int) get_parameter('group_id');
$tag_id = (int) get_parameter('tag_id');
$strict_acl = (bool) db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
$serach_hirearchy = (bool) get_parameter('searchHirearchy', false);
$show_disabled = get_parameter('show_disabled', false);
// ---------------------Tabs -------------------------------------------
$enterpriseEnable = false;
if (enterprise_include_once('include/functions_policies.php') !== ENTERPRISE_NOT_HOOK) {
@ -249,6 +251,10 @@ $row[] = html_print_input_hidden('show_not_init_modules_hidden', $show_not_init_
if (is_metaconsole() === true) {
$table->data[] = $row;
$row = [];
$row[] = __('Show only disabled');
$row[] = html_print_checkbox('show_disabled', $show_disabled, false, true);
$table->data[] = $row;
$row = [];
}
$row[] = html_print_submit_button(__('Filter'), 'uptbutton', false, 'class="sub search"', true);
@ -390,6 +396,13 @@ enterprise_hook('close_meta_frame');
$('#hidden-show_not_init_modules_hidden').val(0);
}
if($("#checkbox-show_disabled").is(':checked')){
parameters['filter']['show_disabled'] = 1;
}
else{
parameters['filter']['show_disabled'] = 0;
}
$.ajax({
type: "POST",
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.760
%define release 220311
%define release 220314
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.760
%define release 220311
%define release 220314
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.760
%define release 220311
%define release 220314
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.760-220311
Version: 7.0NG.760-220314
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.760-220311"
pandora_version="7.0NG.760-220314"
package_cpan=0
package_pandora=1

View File

@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.760";
my $pandora_build = "220311";
my $pandora_build = "220314";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash

View File

@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.760";
my $pandora_build = "220311";
my $pandora_build = "220314";
our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 7.0NG.760
%define release 220311
%define release 220314
Summary: Pandora FMS Server
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 7.0NG.760
%define release 220311
%define release 220314
Summary: Pandora FMS Server
Name: %{name}

View File

@ -9,7 +9,7 @@
# **********************************************************************
PI_VERSION="7.0NG.760"
PI_BUILD="220311"
PI_BUILD="220314"
MODE=$1
if [ $# -gt 1 ]; then

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB;
# version: define current version
my $version = "7.0NG.760 Build 220311";
my $version = "7.0NG.760 Build 220314";
# Pandora server configuration
my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "7.0NG.760 Build 220311";
my $version = "7.0NG.760 Build 220314";
# save program name for logging
my $progname = basename($0);