diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index ebdb8664f2..02b7efcc57 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
package: pandorafms-agent-unix
-Version: 7.0NG.760-220311
+Version: 7.0NG.760-220314
Architecture: all
Priority: optional
Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index 7baaf48a41..1476b5233e 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-pandora_version="7.0NG.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
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index ac23026142..0b8afec734 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -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;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index 38d18895f2..65e11db2f9 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 7.0NG.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
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index 51b0426c61..f6504f8be3 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 7.0NG.760
-%define release 220311
+%define release 220314
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index f8c0a0e18c..e3924157b7 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.760"
-PI_BUILD="220311"
+PI_BUILD="220314"
OS_NAME=`uname -s`
FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index 79ce6b7ff3..66a17b8bf0 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
-{220311}
+{220314}
ViewReadme
{Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index 09f3dc6556..01a72c4d48 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.760 Build 220311")
+#define PANDORA_VERSION ("7.0NG.760 Build 220314")
string pandora_path;
string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index 3c2a4fc8fd..067058fac5 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
- VALUE "ProductVersion", "(7.0NG.760(Build 220311))"
+ VALUE "ProductVersion", "(7.0NG.760(Build 220314))"
VALUE "FileVersion", "1.0.0.0"
END
END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index 11f7e1281c..7d33de7073 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
package: pandorafms-console
-Version: 7.0NG.760-220311
+Version: 7.0NG.760-220314
Architecture: all
Priority: optional
Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index 19aefc5e48..2ea3651e7d 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-pandora_version="7.0NG.760-220311"
+pandora_version="7.0NG.760-220314"
package_pear=0
package_pandora=1
diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php
index 2076d50975..d1246b298c 100644
--- a/pandora_console/godmode/agentes/agent_manager.php
+++ b/pandora_console/godmode/agentes/agent_manager.php
@@ -191,7 +191,7 @@ if ($disk_conf_delete) {
@unlink($filename['conf']);
}
-echo '
';
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 = $("").attr("value", id).html(value);
+ if (inArray(id, groups_selected) === true) {
+ option.attr("selected", true);
+ }
+ $("#secondary_groups_removed").append(option).trigger("change");
+ });
+ } else {
+ option = $("").attr("value", '').html('None');
+ $("#secondary_groups_removed").append(option).trigger("change");
+ }
+ },
+ "json"
+ );
+ }
+ );
});
function changeIcons() {
diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php
index e82bf0264b..079b132ba2 100755
--- a/pandora_console/godmode/reporting/reporting_builder.php
+++ b/pandora_console/godmode/reporting/reporting_builder.php
@@ -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
'.$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
'.$err)
+ );
}
switch ($activeTab) {
diff --git a/pandora_console/godmode/servers/modificar_server.php b/pandora_console/godmode/servers/modificar_server.php
index 8fe9d303f2..b4fcf95fcc 100644
--- a/pandora_console/godmode/servers/modificar_server.php
+++ b/pandora_console/godmode/servers/modificar_server.php
@@ -47,6 +47,8 @@ if (isset($_GET['server'])) {
$exec_server_enable = __('Yes');
}
+ $table = new stdClass();
+
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = '100%';
diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php
index 97f70426bf..8d99fb6d82 100644
--- a/pandora_console/include/class/Tree.class.php
+++ b/pandora_console/include/class/Tree.class.php
@@ -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';
diff --git a/pandora_console/include/class/TreeGroup.class.php b/pandora_console/include/class/TreeGroup.class.php
index 48c64c898d..dbc48b9296 100644
--- a/pandora_console/include/class/TreeGroup.class.php
+++ b/pandora_console/include/class/TreeGroup.class.php
@@ -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
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index 9a185a4f89..2c44e50ada 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
/**
* Pandora build version and version
*/
-$build_version = 'PC220311';
+$build_version = 'PC220314';
$pandora_version = 'v7.0NG.760';
// Do not overwrite default timezone set if defined.
diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php
index 0563cac803..1d0c8cf298 100644
--- a/pandora_console/include/functions_html.php
+++ b/pandora_console/include/functions_html.php
@@ -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 = '';
+ }
+
+ $output .= '
';
+ $output .= $adv_secondary_groups_left;
+ $output .= '
';
+ $output .= '
';
+ $output .= $adv_secondary_groups_arrows;
+ $output .= '
';
+ $output .= '
';
+ $output .= $adv_secondary_groups_right;
+ $output .= '
';
+
+ if (isset($options['container']) === true
+ && $options['container'] === true
+ ) {
+ $output .= '
';
+ }
+ } else {
+ $output .= $adv_secondary_groups_left;
+ }
+
+ return $output;
+}
diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js
index e26cd5e2a8..bde3c583f0 100644
--- a/pandora_console/include/javascript/pandora.js
+++ b/pandora_console/include/javascript/pandora.js
@@ -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;
+}
diff --git a/pandora_console/include/javascript/pandora_agents.js b/pandora_console/include/javascript/pandora_agents.js
new file mode 100644
index 0000000000..a0ce0614a3
--- /dev/null
+++ b/pandora_console/include/javascript/pandora_agents.js
@@ -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(
+ $("