diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index b85bad5f8b..57b1b77d69 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
package: pandorafms-agent-unix
-Version: 7.0NG.758.1-211209
+Version: 7.0NG.758.1-211210
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 78c2f450bf..a7c88922c7 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.758.1-211209"
+pandora_version="7.0NG.758.1-211210"
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 8785e3288a..e01e061a44 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.758.1';
-use constant AGENT_BUILD => '211209';
+use constant AGENT_BUILD => '211210';
# 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 b719f93ca2..c92fcf61b4 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.758.1
-%define release 211209
+%define release 211210
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index aee4484e05..16f4b6fee4 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.758.1
-%define release 211209
+%define release 211210
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 acc2227413..adca572c73 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.758.1"
-PI_BUILD="211209"
+PI_BUILD="211210"
OS_NAME=`uname -s`
FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index 7cfdde9d37..ffc71aaccb 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
-{211209}
+{211210}
ViewReadme
{Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index 9c169ee9b8..7b6560677e 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.758.1 Build 211209")
+#define PANDORA_VERSION ("7.0NG.758.1 Build 211210")
string pandora_path;
string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index 77def11f3d..43106ff959 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.758.1(Build 211209))"
+ VALUE "ProductVersion", "(7.0NG.758.1(Build 211210))"
VALUE "FileVersion", "1.0.0.0"
END
END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index f728ce6013..98a48ae7c0 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
package: pandorafms-console
-Version: 7.0NG.758.1-211209
+Version: 7.0NG.758.1-211210
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 e166255f37..d0fcd0a5b6 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.758.1-211209"
+pandora_version="7.0NG.758.1-211210"
package_pear=0
package_pandora=1
diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php
index 3c5defe04d..815a0ed8d0 100644
--- a/pandora_console/extensions/agents_modules.php
+++ b/pandora_console/extensions/agents_modules.php
@@ -89,14 +89,13 @@ function agents_modules_load_js()
var controls = document.getElementById('vc-controls');
autoHideElement(controls, 1000);
-
+
$('select#refresh').change(function (event) {
refr = Number.parseInt(event.target.value, 10);
startCountDown(refr, false);
});
}
else {
-
var agentes_id = $("#id_agents2").val();
var id_agentes = getQueryParam("full_agents_id");
if (agentes_id === null && id_agentes !== null) {
@@ -104,15 +103,15 @@ function agents_modules_load_js()
id_agentes.forEach(function(element) {
$("#id_agents2 option[value="+ element +"]").attr("selected",true);
});
-
+
selection_agent_module();
}
-
+
$('#refresh').change(function () {
$('#hidden-vc_refr').val($('#refresh option:selected').val());
});
}
-
+
$("#group_id").change (function () {
jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente",
@@ -128,7 +127,6 @@ function agents_modules_load_js()
jQuery.each (data, function (id, value) {
// Remove keys_prefix from the index
id = id.substring(1);
-
option = $(" ")
.attr ("value", value["id_agente"])
.html (value["alias"]);
@@ -139,7 +137,7 @@ function agents_modules_load_js()
"json"
);
});
-
+
$("#checkbox-recursion").change (function () {
jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente",
@@ -155,7 +153,6 @@ function agents_modules_load_js()
jQuery.each (data, function (id, value) {
// Remove keys_prefix from the index
id = id.substring(1);
-
option = $(" ")
.attr ("value", value["id_agente"])
.html (value["alias"]);
@@ -166,7 +163,7 @@ function agents_modules_load_js()
"json"
);
});
-
+
$("#modulegroup").change (function () {
jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente",
@@ -180,8 +177,8 @@ function agents_modules_load_js()
if(data){
jQuery.each (data, function (id, value) {
option = $(" ")
- .attr ("value", value["id_agente_modulo"])
- .html (value["nombre"]);
+ .attr ("value", id)
+ .html (value);
$("#module").append (option);
});
}
@@ -207,8 +204,8 @@ function agents_modules_load_js()
if(data){
jQuery.each (data, function (id, value) {
option = $(" ")
- .attr ("value", value["id_agente_modulo"])
- .html (value["nombre"]);
+ .attr ("value", id)
+ .html (value);
$("#module").append (option);
});
}
@@ -231,11 +228,11 @@ function agents_modules_load_js()
if(data){
jQuery.each (data, function (id, value) {
option = $(" ")
- .attr ("value", value["id_agente_modulo"])
- .html (value["nombre"]);
+ .attr ("value", id)
+ .html (value);
$("#module").append (option);
});
-
+
var id_modules = getQueryParam("full_modules_selected");
if(id_modules !== null) {
id_modules = id_modules.split(";");
@@ -249,20 +246,19 @@ function agents_modules_load_js()
);
}
- function getQueryParam (key) {
- key = key.replace(/[[]/, '[');
- key = key.replace(/[]]/, ']');
- var pattern = "[?&]" + key + "=([^]*)";
+ function getQueryParam (key) {
+ key = key.replace(/[[]/, '[');
+ key = key.replace(/[]]/, ']');
+ var pattern = "[?&]" + key + "=([^]*)";
var regex = new RegExp(pattern);
var url = unescape(window.location.href);
var results = regex.exec(url);
- if (results === null) {
- return null;
- } else {
- return results[1];
- }
+ if (results === null) {
+ return null;
+ } else {
+ return results[1];
+ }
}
-
__('None')];
+$valuesGroupByDefaultAlertActions = [
+ 'agent' => __('Agent'),
+ 'module' => __('Module'),
+ 'group' => __('Group'),
+];
+if (is_metaconsole() === false) {
+ $valuesGroupByDefaultAlertActions['template'] = __('Template');
+}
+
switch ($action) {
case 'new':
$actionParameter = 'save';
@@ -733,21 +745,73 @@ switch ($action) {
case 'agent_module':
$description = $item['description'];
$es = json_decode($item['external_source'], true);
- $id_agents = $es['id_agents'];
+
+ // Decode agents and modules.
+ $id_agents = json_decode(
+ io_safe_output(base64_decode($es['id_agents'])),
+ true
+ );
+ $module = json_decode(
+ io_safe_output(base64_decode($es['module'])),
+ true
+ );
+
$selection_a_m = get_parameter('selection');
$recursion = $item['recursion'];
- if ((count($es['module']) == 1) && ($es['module'][0] == 0)) {
- $module = '';
- } else {
- $module = $es['module'];
- }
-
$group = $item['id_group'];
$modulegroup = $item['id_module_group'];
$idAgentModule = $module;
break;
+ case 'alert_report_actions':
+ $description = $item['description'];
+ $es = json_decode($item['external_source'], true);
+
+ // Decode agents and modules.
+ $id_agents = json_decode(
+ io_safe_output(base64_decode($es['id_agents'])),
+ true
+ );
+ $module = json_decode(
+ io_safe_output(base64_decode($es['module'])),
+ true
+ );
+
+ $selection_a_m = get_parameter('selection');
+ $recursion = $item['recursion'];
+
+ $group = $item['id_group'];
+ $modulegroup = $item['id_module_group'];
+ $idAgentModule = $module;
+
+ $alert_templates_selected = $es['templates'];
+ $alert_actions_selected = $es['actions'];
+
+ $show_summary = $es['show_summary'];
+
+ $group_by = $es['group_by'];
+
+ $only_data = $es['only_data'];
+
+ $period = $item['period'];
+
+ $lapse = $item['lapse'];
+
+ // Set values.
+ $valuesGroupBy = [
+ 'agent' => __('Agent'),
+ 'module' => __('Module'),
+ 'group' => __('Group'),
+ ];
+
+ if (is_metaconsole() === false) {
+ $valuesGroupBy['template'] = __('Template');
+ }
+
+ $lapse_calc = 1;
+ break;
+
case 'agents_inventory':
$description = $item['description'];
$es = json_decode($item['external_source'], true);
@@ -1648,30 +1712,12 @@ $class = 'databox filters';
")
- .attr ("value", value["id_agente_modulo"])
- .html (value["nombre"]);
+ .attr ("value", id)
+ .html (value);
$("#module").append (option);
});
},
@@ -4368,17 +4607,20 @@ $(document).ready (function () {
jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente",
"get_modules_group_json" : 1,
+ "selection" : $("#selection_agent_module").val(),
"id_module_group" : $("#combo_modulegroup").val(),
"id_agents" : $("#id_agents2").val(),
- "selection" : $("#selection_agent_module").val()
+ "select_mode": 1
},
function (data, status) {
$("#module").html('');
+ // Check module all.
+ $("#checkbox-module-check-all").prop('checked', false);
if(data){
jQuery.each (data, function (id, value) {
option = $(" ")
- .attr ("value", value["id_agente_modulo"])
- .html (value["nombre"]);
+ .attr ("value", id)
+ .html (value);
$("#module").append (option);
});
}
@@ -4395,15 +4637,18 @@ $(document).ready (function () {
"get_modules_group_json" : 1,
"id_module_group" : $("#combo_modulegroup").val(),
"id_agents" : $("#id_agents2").val(),
- "selection" : $("#selection_agent_module").val()
+ "selection" : $("#selection_agent_module").val(),
+ "select_mode": 1
},
function (data, status) {
$("#module").html('');
+ // Check module all.
+ $("#checkbox-module-check-all").prop('checked', false);
if(data){
jQuery.each (data, function (id, value) {
option = $(" ")
- .attr ("value", value["id_agente_modulo"])
- .html (value["nombre"]);
+ .attr ("value", id)
+ .html (value);
$("#module").append (option);
});
}
@@ -4494,6 +4739,15 @@ $(document).ready (function () {
}
switch (type){
+ case 'agent_module':
+ case 'alert_report_actions':
+ var agents_multiple = $('#id_agents2').val();
+ var modules_multiple = $('#module').val();
+ $('#hidden-id_agents2-multiple-text').val(JSON.stringify(agents_multiple));
+ $('#hidden-module-multiple-text').val(JSON.stringify(modules_multiple));
+ $('#id_agents2').val('');
+ $('#module').val('');
+ break;
case 'alert_report_module':
case 'alert_report_agent':
case 'event_report_agent':
@@ -4518,12 +4772,6 @@ $(document).ready (function () {
return false;
}
break;
- case 'agent_module':
- if ($("select#id_agents2>option:selected").val() == undefined) {
- dialog_message('#message_no_agent');
- return false;
- }
- break;
case 'inventory':
case 'inventory_changes':
if ($("select#id_agents>option:selected").val() == undefined) {
@@ -4568,18 +4816,11 @@ $(document).ready (function () {
case 'sumatory':
case 'historical_data':
case 'increment':
-
if ($("#id_agent_module").val() == 0) {
dialog_message('#message_no_module');
return false;
}
break;
- case 'agent_module':
- if ($("select#module>option:selected").val() == undefined) {
- dialog_message('#message_no_module');
- return false;
- }
- break;
case 'inventory':
case 'inventory_changes':
if ($("select#inventory_modules>option:selected").val() == 0) {
@@ -4632,6 +4873,15 @@ $(document).ready (function () {
return false;
}
switch (type){
+ case 'agent_module':
+ case 'alert_report_actions':
+ var agents_multiple = $('#id_agents2').val();
+ var modules_multiple = $('#module').val();
+ $('#hidden-id_agents2-multiple-text').val(JSON.stringify(agents_multiple));
+ $('#hidden-module-multiple-text').val(JSON.stringify(modules_multiple));
+ $('#id_agents2').val('');
+ $('#module').val('');
+ break;
case 'alert_report_module':
case 'alert_report_agent':
case 'event_report_agent':
@@ -4656,12 +4906,6 @@ $(document).ready (function () {
return false;
}
break;
- case 'agent_module':
- if ($("select#id_agents2>option:selected").val() == undefined) {
- dialog_message('#message_no_agent');
- return false;
- }
- break;
case 'inventory':
if ($("select#id_agents>option:selected").val() == undefined) {
dialog_message('#message_no_agent');
@@ -4701,18 +4945,11 @@ $(document).ready (function () {
case 'sumatory':
case 'historical_data':
case 'increment':
-
if ($("#id_agent_module").val() == 0) {
dialog_message('#message_no_module');
return false;
}
break;
- case 'agent_module':
- if ($("select#module>option:selected").val() == undefined) {
- dialog_message('#message_no_module');
- return false;
- }
- break;
case 'inventory':
if ($("select#inventory_modules>option:selected").val() == 0) {
dialog_message('#message_no_module');
@@ -5485,6 +5722,7 @@ function addGeneralRow() {
}
function chooseType() {
+ var meta = '';
type = $("#type").val();
$("#row_description").hide();
$("#row_label").hide();
@@ -5538,6 +5776,8 @@ function chooseType() {
$('#row_hide_notinit_agents').hide();
$('#row_priority_mode').hide();
$("#row_module_group").hide();
+ $("#row_alert_templates").hide();
+ $("#row_alert_actions").hide();
$("#row_servers").hide();
$("#row_sort").hide();
$("#row_date").hide();
@@ -5562,6 +5802,7 @@ function chooseType() {
$("#select_agent_modules").hide();
$("#modules_row").hide();
$("#row_show_summary_group").hide();
+ $("#row_show_only_data").hide();
$("#row_event_severity").hide();
$("#row_event_type").hide();
$("#row_event_status").hide();
@@ -5586,6 +5827,8 @@ function chooseType() {
$("#row_network_filter").hide();
$("#row_alive_ip").hide();
$("#row_agent_not_assigned_to_ip").hide();
+ $("#row_show_summary").hide();
+ $("#row_group_by").hide();
// SLA list default state.
$("#sla_list").hide();
@@ -5896,6 +6139,37 @@ function chooseType() {
$("#row_historical_db_check").hide();
break;
+ case 'alert_report_actions':
+ $("#row_description").show();
+ $("#row_group").show();
+ $("#select_agent_modules").show();
+ $("#agents_modules_row").show();
+ $("#modules_row").show();
+ if(meta == 0){
+ $("#row_alert_templates").show();
+ }
+ $("#row_alert_actions").show();
+ $("#row_period").show();
+ $("#row_lapse").show();
+ $("#row_show_summary").show();
+ $("#row_show_only_data").show();
+ $("#row_group_by").show();
+ if('' === 'new'){
+ $("#group_by").html('');
+ var dataDefault = '';
+ Object.entries(JSON.parse(dataDefault)).forEach(function (item) {
+ option = $(" ")
+ .attr ("value", item[0])
+ .html (item[1]);
+ $("#group_by").append(option);
+ });
+
+ $("#lapse_select").attr('disabled', false);
+ $("#lapse_select").val('0').trigger('change');
+ $("#hidden-lapse").val('0');
+ }
+ break;
+
case 'event_report_group':
$("#row_description").show();
$("#row_period").show();
diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php
index 1f5eba566c..9421f120f2 100755
--- a/pandora_console/godmode/reporting/reporting_builder.php
+++ b/pandora_console/godmode/reporting/reporting_builder.php
@@ -1676,22 +1676,77 @@ switch ($action) {
break;
case 'agent_module':
- $agents_to_report = get_parameter('id_agents2');
- $modules_to_report = get_parameter(
- 'module',
- ''
+ $agents_to_report_text = get_parameter('id_agents2-multiple-text', '');
+ $modules_to_report_text = get_parameter('module-multiple-text', '');
+
+ // Decode json check modules.
+ $agents_to_report = json_decode(
+ io_safe_output($agents_to_report_text),
+ true
+ );
+ $modules_to_report = json_decode(
+ io_safe_output($modules_to_report_text),
+ true
);
- $es['module'] = get_same_modules(
+ $es['module'] = get_same_modules_all(
$agents_to_report,
$modules_to_report
);
- $es['id_agents'] = $agents_to_report;
+
+ // Encode json modules and agents.
+ $es['module'] = base64_encode(json_encode($es['module']));
+ $es['id_agents'] = base64_encode(json_encode($agents_to_report));
$values['external_source'] = json_encode($es);
$good_format = true;
break;
+ case 'alert_report_actions':
+ $alert_templates_to_report = get_parameter('alert_templates');
+ $alert_actions_to_report = get_parameter('alert_actions');
+ $show_summary = get_parameter('show_summary', 0);
+ $group_by = get_parameter('group_by');
+ $only_data = get_parameter('only_data', 0);
+ $agents_to_report_text = get_parameter('id_agents2-multiple-text');
+ $modules_to_report_text = get_parameter('module-multiple-text', '');
+
+ // Decode json check modules.
+ $agents_to_report = json_decode(
+ io_safe_output($agents_to_report_text),
+ true
+ );
+ $modules_to_report = json_decode(
+ io_safe_output($modules_to_report_text),
+ true
+ );
+
+ $es['module'] = get_same_modules_all(
+ $agents_to_report,
+ $modules_to_report
+ );
+
+ // Encode json modules and agents.
+ $es['module'] = base64_encode(json_encode($es['module']));
+ $es['id_agents'] = base64_encode(json_encode($agents_to_report));
+
+ $es['templates'] = $alert_templates_to_report;
+ $es['actions'] = $alert_actions_to_report;
+ $es['show_summary'] = $show_summary;
+ $es['group_by'] = $group_by;
+ $es['only_data'] = $only_data;
+
+ $values['external_source'] = json_encode($es);
+
+ $values['period'] = get_parameter('period');
+ $values['lapse_calc'] = get_parameter(
+ 'lapse_calc'
+ );
+ $values['lapse'] = get_parameter('lapse');
+
+ $good_format = true;
+ break;
+
case 'inventory':
$values['period'] = 0;
$es['date'] = get_parameter('date');
@@ -2422,22 +2477,78 @@ switch ($action) {
break;
case 'agent_module':
- $agents_to_report = get_parameter('id_agents2');
- $modules_to_report = get_parameter(
- 'module',
- ''
+ $agents_to_report_text = get_parameter('id_agents2-multiple-text');
+ $modules_to_report_text = get_parameter('module-multiple-text', '');
+
+ // Decode json check modules.
+ $agents_to_report = json_decode(
+ io_safe_output($agents_to_report_text),
+ true
+ );
+ $modules_to_report = json_decode(
+ io_safe_output($modules_to_report_text),
+ true
);
- $es['module'] = get_same_modules(
+ $es['module'] = get_same_modules_all(
$agents_to_report,
$modules_to_report
);
- $es['id_agents'] = $agents_to_report;
+
+ // Encode json modules and agents.
+ $es['module'] = base64_encode(json_encode($es['module']));
+ $es['id_agents'] = base64_encode(json_encode($agents_to_report));
$values['external_source'] = json_encode($es);
$good_format = true;
break;
+ case 'alert_report_actions':
+ $alert_templates_to_report = get_parameter('alert_templates');
+ $alert_actions_to_report = get_parameter('alert_actions');
+ $show_summary = get_parameter('show_summary', 0);
+ $group_by = get_parameter('group_by');
+ $only_data = get_parameter('only_data', 0);
+
+ $agents_to_report_text = get_parameter('id_agents2-multiple-text');
+ $modules_to_report_text = get_parameter('module-multiple-text', '');
+
+ // Decode json check modules.
+ $agents_to_report = json_decode(
+ io_safe_output($agents_to_report_text),
+ true
+ );
+ $modules_to_report = json_decode(
+ io_safe_output($modules_to_report_text),
+ true
+ );
+
+ $es['module'] = get_same_modules_all(
+ $agents_to_report,
+ $modules_to_report
+ );
+
+ // Encode json modules and agents.
+ $es['module'] = base64_encode(json_encode($es['module']));
+ $es['id_agents'] = base64_encode(json_encode($agents_to_report));
+
+ $es['templates'] = $alert_templates_to_report;
+ $es['actions'] = $alert_actions_to_report;
+ $es['show_summary'] = $show_summary;
+ $es['group_by'] = $group_by;
+ $es['only_data'] = $only_data;
+
+ $values['external_source'] = json_encode($es);
+
+ $values['period'] = get_parameter('period');
+ $values['lapse_calc'] = get_parameter(
+ 'lapse_calc'
+ );
+ $values['lapse'] = get_parameter('lapse');
+
+ $good_format = true;
+ break;
+
case 'inventory_changes':
$values['period'] = get_parameter('period');
$es['id_agents'] = get_parameter('id_agents');
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index cc993ea8db..fb12849375 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 = 'PC211209';
+$build_version = 'PC211210';
$pandora_version = 'v7.0NG.758.1';
// Do not overwrite default timezone set if defined.
diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php
index ce6f814e95..872f4a0496 100644
--- a/pandora_console/include/db/mysql.php
+++ b/pandora_console/include/db/mysql.php
@@ -1244,57 +1244,6 @@ function mysql_db_get_all_row_by_steps_sql($new=true, &$result, $sql=null)
}
-/**
- * Starts a database transaction.
- */
-function mysql_db_process_sql_begin()
-{
- global $config;
-
- if ($config['mysqli']) {
- mysqli_query($config['dbconnection'], 'SET AUTOCOMMIT = 0');
- mysqli_query($config['dbconnection'], 'START TRANSACTION');
- } else {
- mysql_query('SET AUTOCOMMIT = 0');
- mysql_query('START TRANSACTION');
- }
-}
-
-
-/**
- * Commits a database transaction.
- */
-function mysql_db_process_sql_commit()
-{
- global $config;
-
- if ($config['mysqli']) {
- mysqli_query($config['dbconnection'], 'COMMIT');
- mysqli_query($config['dbconnection'], 'SET AUTOCOMMIT = 1');
- } else {
- mysql_query('COMMIT');
- mysql_query('SET AUTOCOMMIT = 1');
- }
-}
-
-
-/**
- * Rollbacks a database transaction.
- */
-function mysql_db_process_sql_rollback()
-{
- global $config;
-
- if ($config['mysqli']) {
- mysqli_query($config['dbconnection'], 'ROLLBACK ');
- mysqli_query($config['dbconnection'], 'SET AUTOCOMMIT = 1');
- } else {
- mysql_query('ROLLBACK ');
- mysql_query('SET AUTOCOMMIT = 1');
- }
-}
-
-
/**
* Get last error.
*
@@ -1390,7 +1339,7 @@ function mysql_db_process_file($path, $handle_error=true)
$query = '';
// Begin the transaction
- mysql_db_process_sql_begin();
+ db_process_sql_begin();
foreach ($file_content as $sql_line) {
if (trim($sql_line) != '' && strpos($sql_line, '--') === false) {
@@ -1405,7 +1354,7 @@ function mysql_db_process_file($path, $handle_error=true)
if (!$result = $query_result) {
// Error. Rollback the transaction
- mysql_db_process_sql_rollback();
+ db_process_sql_rollback();
if ($config['mysqli']) {
$error_message = mysqli_error($config['dbconnection']);
@@ -1442,7 +1391,7 @@ function mysql_db_process_file($path, $handle_error=true)
}
// No errors. Commit the transaction
- mysql_db_process_sql_commit();
+ db_process_sql_commit();
return true;
} else {
return false;
@@ -1481,7 +1430,7 @@ function db_run_sql_file($location)
$mysqli->query($config['dbconnection'], 'START TRANSACTION');
} else {
// Run commands
- mysql_db_process_sql_begin();
+ db_process_sql_begin();
// Begin transaction
}
@@ -1507,7 +1456,7 @@ function db_run_sql_file($location)
$mysqli->query($config['dbconnection'], 'COMMIT');
$mysqli->query($config['dbconnection'], 'SET AUTOCOMMIT = 1');
} else {
- mysql_db_process_sql_commit();
+ db_process_sql_commit();
// Save results
}
@@ -1517,7 +1466,7 @@ function db_run_sql_file($location)
$mysqli->query($config['dbconnection'], 'ROLLBACK ');
$mysqli->query($config['dbconnection'], 'SET AUTOCOMMIT = 1');
} else {
- mysql_db_process_sql_rollback();
+ db_process_sql_rollback();
// Undo results
}
diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php
index 28f563b8e7..c87f1f62b4 100644
--- a/pandora_console/include/functions_agents.php
+++ b/pandora_console/include/functions_agents.php
@@ -733,6 +733,63 @@ function agents_get_agents(
}
+function agents_get_agents_selected($group)
+{
+ if (is_metaconsole() === true) {
+ $all = agents_get_agents(
+ ['id_grupo' => $group],
+ [
+ 'id_tagente',
+ 'id_tmetaconsole_setup',
+ 'id_agente',
+ 'alias',
+ ],
+ 'AR',
+ [
+ 'field' => 'alias',
+ 'order' => 'ASC',
+ ],
+ false,
+ 0,
+ true
+ );
+
+ $all = array_reduce(
+ $all,
+ function ($carry, $item) {
+ $carry[$item['id_tmetaconsole_setup'].'|'.$item['id_tagente']] = $item['alias'];
+ return $carry;
+ },
+ []
+ );
+ } else {
+ $all = agents_get_agents(
+ ['id_grupo' => $group],
+ [
+ 'id_agente',
+ 'alias',
+ ],
+ 'AR',
+ [
+ 'field' => 'alias',
+ 'order' => 'ASC',
+ ]
+ );
+
+ $all = array_reduce(
+ $all,
+ function ($carry, $item) {
+ $carry[$item['id_agente']] = $item['alias'];
+ return $carry;
+ },
+ []
+ );
+ }
+
+ return $all;
+}
+
+
/**
* Get all the alerts of an agent, simple and combined.
*
@@ -1649,6 +1706,85 @@ function agents_get_name($id_agent, $case='none')
}
+/**
+ * Get the agents names of an agent.
+ *
+ * @param array $array_ids Agents ids.
+ *
+ * @return array Id => name.
+ */
+function agents_get_alias_array($array_ids)
+{
+ if (is_array($array_ids) === false || empty($array_ids) === true) {
+ return [];
+ }
+
+ if ((bool) is_metaconsole() === true) {
+ $agents = array_reduce(
+ $array_ids,
+ function ($carry, $item) {
+ $explode = explode('|', $item);
+
+ $carry[$explode[0]][] = $explode[1];
+ return $carry;
+ }
+ );
+
+ $result = [];
+ foreach ($agents as $tserver => $id_agents) {
+ $sql = sprintf(
+ 'SELECT id_tagente as id, alias as `name`
+ FROM tmetaconsole_agent
+ WHERE id_tagente IN (%s) AND id_tmetaconsole_setup = %d',
+ implode(',', $id_agents),
+ $tserver
+ );
+
+ $data_server = db_get_all_rows_sql($sql);
+
+ if ($data_server === false) {
+ $data_server = [];
+ }
+
+ $data_server = array_reduce(
+ $data_server,
+ function ($carry, $item) {
+ $carry[$item['id']] = $item['name'];
+ return $carry;
+ },
+ []
+ );
+
+ $result[$tserver] = $data_server;
+ }
+ } else {
+ $sql = sprintf(
+ 'SELECT id_agente as id, alias as `name`
+ FROM tagente
+ WHERE id_agente IN (%s)',
+ implode(',', $array_ids)
+ );
+
+ $result = db_get_all_rows_sql($sql);
+
+ if ($result === false) {
+ $result = [];
+ }
+
+ $result = array_reduce(
+ $result,
+ function ($carry, $item) {
+ $carry[$item['id']] = $item['name'];
+ return $carry;
+ },
+ []
+ );
+ }
+
+ return $result;
+}
+
+
/**
* Get alias of an agent (cached function).
*
diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php
index 19aff75cce..f308acaa0a 100644
--- a/pandora_console/include/functions_alerts.php
+++ b/pandora_console/include/functions_alerts.php
@@ -2837,3 +2837,588 @@ function alerts_get_agent_modules(
return $agent_modules;
}
+
+
+function alerts_get_actions_names($actions, $reduce=false)
+{
+ $where = '';
+ if (empty($actions) === false) {
+ if (is_array($actions) === true) {
+ $where = sprintf(
+ 'WHERE id IN (%s)',
+ implode(',', $actions)
+ );
+ } else {
+ $where = sprintf('WHERE id = %d', $actions);
+ }
+ }
+
+ $sql = sprintf(
+ 'SELECT id, `name`
+ FROM talert_actions
+ %s',
+ $where
+ );
+
+ $result = db_get_all_rows_sql($sql);
+
+ if ($result === false) {
+ $result = [];
+ }
+
+ if ($reduce === true) {
+ $result = array_reduce(
+ $result,
+ function ($carry, $item) {
+ $carry[$item['id']] = $item['name'];
+ return $carry;
+ },
+ []
+ );
+ }
+
+ return $result;
+}
+
+
+/**
+ * Alert fired.
+ *
+ * @param array $filters Filters.
+ * @param array $groupsBy Groupby and lapse.
+ *
+ * @return array Result data.
+ */
+function alerts_get_alert_fired($filters=[], $groupsBy=[])
+{
+ global $config;
+
+ $table = 'tevento';
+ if (is_metaconsole() === true) {
+ $table = 'tmetaconsole_event';
+ }
+
+ $filter_date = '';
+ if (isset($filters['period']) === true
+ && empty($filters['period']) === false
+ ) {
+ $filter_date = sprintf(
+ 'AND %s.utimestamp > %d',
+ $table,
+ (time() - $filters['period'])
+ );
+ }
+
+ $filter_group = '';
+ if (isset($filters['group']) === true
+ && empty($filters['group']) === false
+ ) {
+ $filter_group = sprintf(
+ 'AND %s.id_grupo = %d',
+ $table,
+ $filters['group']
+ );
+ }
+
+ $filter_agents = '';
+ if (isset($filters['agents']) === true
+ && empty($filters['agents']) === false
+ ) {
+ if (is_metaconsole() === true) {
+ $agents = array_reduce(
+ $filters['agents'],
+ function ($carry, $item) {
+ $explode = explode('|', $item);
+
+ $carry[$explode[0]][] = $explode[1];
+ return $carry;
+ }
+ );
+
+ $filter_agents .= ' AND ( ';
+ $i = 0;
+ foreach ($agents as $tserver => $agent) {
+ if ($i !== 0) {
+ $filter_agents .= ' OR ';
+ }
+
+ $filter_agents .= sprintf(
+ '( %s.id_agente IN (%s) AND %s.server_id = %d )',
+ $table,
+ implode(',', $agent),
+ $table,
+ (int) $tserver
+ );
+
+ $i++;
+ }
+
+ $filter_agents .= ' )';
+ } else {
+ $filter_agents = sprintf(
+ 'AND %s.id_agente IN (%s)',
+ $table,
+ implode(',', $filters['agents'])
+ );
+ }
+ }
+
+ $filter_modules = '';
+ if (isset($filters['modules']) === true
+ && empty($filters['modules']) === false
+ ) {
+ if (is_metaconsole() === true) {
+ $modules = array_reduce(
+ $filters['modules'],
+ function ($carry, $item) {
+ $explode = explode('|', $item);
+
+ $carry[$explode[0]][] = $explode[1];
+ return $carry;
+ }
+ );
+
+ $filter_modules .= ' AND ( ';
+ $i = 0;
+ foreach ($modules as $tserver => $module) {
+ if ($i !== 0) {
+ $filter_modules .= ' OR ';
+ }
+
+ $filter_modules .= sprintf(
+ '( %s.id_agentmodule IN (%s) AND %s.server_id = %d )',
+ $table,
+ implode(',', $module),
+ $table,
+ (int) $tserver
+ );
+
+ $i++;
+ }
+
+ $filter_modules .= ' )';
+ } else {
+ $filter_modules = sprintf(
+ 'AND %s.id_agentmodule IN (%s)',
+ $table,
+ implode(',', $filters['modules'])
+ );
+ }
+ }
+
+ $filter_templates = '';
+ if (isset($filters['templates']) === true
+ && empty($filters['templates']) === false
+ ) {
+ if (is_metaconsole() === false) {
+ $filter_templates = sprintf(
+ 'AND talert_template_modules.id_alert_template IN (%s)',
+ implode(',', $filters['templates'])
+ );
+ }
+ }
+
+ $total = (bool) $filters['show_summary'];
+ $only_data = (bool) $filters['only_data'];
+
+ $actions_names = alerts_get_actions_names($filters['actions'], true);
+
+ $group_array = [];
+
+ $filter_actions = '';
+ $fields_actions = [];
+ if (isset($filters['actions']) === true
+ && empty($filters['actions']) === false
+ ) {
+ $filter_actions .= 'AND ( ';
+ $first = true;
+ foreach ($actions_names as $name_action) {
+ if ($first === false) {
+ $filter_actions .= ' OR ';
+ }
+
+ $filter_actions .= sprintf(
+ "JSON_CONTAINS(%s.custom_data, '\"%s\"', '\$.actions')",
+ $table,
+ io_safe_output($name_action)
+ );
+
+ $fields_actions[$name_action] = sprintf(
+ "SUM(JSON_CONTAINS(%s.custom_data, '\"%s\"', '\$.actions')) as '%s'",
+ $table,
+ io_safe_output($name_action),
+ io_safe_output($name_action)
+ );
+
+ $first = false;
+ }
+
+ $filter_actions .= ' ) ';
+ } else {
+ foreach ($actions_names as $name_action) {
+ $fields[] = sprintf(
+ "SUM(JSON_CONTAINS(%s.custom_data, '\"%s\"', '\$.actions')) as '%s'",
+ $table,
+ io_safe_output($name_action),
+ io_safe_output($name_action)
+ );
+ }
+ }
+
+ if (is_array($fields_actions) === true
+ && empty($fields_actions) === false
+ ) {
+ foreach ($fields_actions as $name => $field) {
+ $fields[] = $field;
+ }
+ }
+
+ $names_search = [];
+ $names_server = [];
+ if (isset($groupsBy['group_by']) === true) {
+ switch ($groupsBy['group_by']) {
+ case 'module':
+ $fields[] = $table.'.id_agentmodule as module';
+ $group_array[] = $table.'.id_agentmodule';
+ $names_search = modules_get_agentmodule_name_array(
+ array_values($filters['modules'])
+ );
+
+ if (is_metaconsole() === true) {
+ $fields[] = $table.'.server_id as server';
+ $group_array[] = $table.'.server_id';
+ $names_server = metaconsole_get_names();
+ }
+ break;
+
+ case 'template':
+ if (is_metaconsole() === false) {
+ $fields[] = 'talert_template_modules.id_alert_template as template';
+ $group_array[] = 'talert_template_modules.id_alert_template';
+ $names_search = alerts_get_templates_name_array(
+ array_values($filters['templates'])
+ );
+ }
+ break;
+
+ case 'agent':
+ $fields[] = $table.'.id_agente as agent';
+ $group_array[] = $table.'.id_agente';
+ $names_search = agents_get_alias_array(
+ array_values($filters['agents'])
+ );
+
+ if (is_metaconsole() === true) {
+ $fields[] = $table.'.server_id as server';
+ $group_array[] = $table.'.server_id';
+ $names_server = metaconsole_get_names();
+ }
+ break;
+
+ case 'group':
+ $fields[] = $table.'.id_grupo as `group`';
+ $group_array[] = $table.'.id_grupo';
+ $names_search = users_get_groups($config['user'], 'AR', false);
+ break;
+
+ default:
+ // Nothing.
+ break;
+ }
+ }
+
+ if (isset($groupsBy['lapse']) === true
+ && empty($groupsBy['lapse']) === false
+ ) {
+ $fields[] = sprintf(
+ '%s.utimestamp AS Period',
+ $table
+ );
+ $group_array[] = 'period';
+ }
+
+ $group_by = '';
+ if (is_array($group_array) === true && empty($group_array) === false) {
+ $group_by = sprintf(' GROUP BY %s', implode(", \n", $group_array));
+ }
+
+ $innerJoin = '';
+ if (is_metaconsole() === false) {
+ $innerJoin = sprintf(
+ 'INNER JOIN talert_template_modules
+ ON talert_template_modules.id = %s.id_alert_am',
+ $table
+ );
+ }
+
+ $query = sprintf(
+ 'SELECT
+ %s
+ FROM %s
+ %s
+ WHERE custom_data != ""
+ AND %s.event_type="alert_fired"
+ %s
+ %s
+ %s
+ %s
+ %s
+ %s
+ %s',
+ implode(", \n", $fields),
+ $table,
+ $innerJoin,
+ $table,
+ $filter_date,
+ $filter_group,
+ $filter_agents,
+ $filter_modules,
+ $filter_actions,
+ $filter_templates,
+ $group_by
+ );
+
+ $data_query = db_get_all_rows_sql($query);
+
+ if ($data_query === false) {
+ $data_query = [];
+ }
+
+ if (empty($data_query) === false) {
+ $data = array_reduce(
+ $data_query,
+ function ($carry, $item) use ($groupsBy) {
+ $period = (isset($item['Period']) === true) ? (int) $item['Period'] : 0;
+ if (is_metaconsole() === true
+ && ($groupsBy['group_by'] === 'agent'
+ || $groupsBy['group_by'] === 'module')
+ ) {
+ $grby = $item[$groupsBy['group_by']];
+ $server = $item['server'];
+ unset($item['Period']);
+ unset($item[$groupsBy['group_by']]);
+ unset($item['server']);
+ $carry[$period][$server][$grby] = $item;
+ } else {
+ $grby = $item[$groupsBy['group_by']];
+ unset($item['Period']);
+ unset($item[$groupsBy['group_by']]);
+ $carry[$period][$grby] = $item;
+ }
+
+ return $carry;
+ },
+ []
+ );
+
+ $intervals = [];
+ if (isset($groupsBy['lapse']) === true
+ && empty($groupsBy['lapse']) === false
+ ) {
+ $tend = time();
+ $tstart = ($tend - (int) $filters['period']);
+ for ($current_time = $tstart; $current_time < $tend; ($current_time += $groupsBy['lapse'])) {
+ $intervals[] = (int) $current_time;
+ }
+ }
+
+ $first_element = reset($data);
+ $first_element = reset($first_element);
+ if (is_metaconsole() === true
+ && ($groupsBy['group_by'] === 'agent'
+ || $groupsBy['group_by'] === 'module')
+ ) {
+ $first_element = reset($first_element);
+ }
+
+ $clone = [];
+ foreach ($first_element as $key_clone => $value_clone) {
+ $clone[$key_clone] = 0;
+ }
+
+ $result = [];
+ if (empty($intervals) === true) {
+ foreach ($data as $period => $array_data) {
+ if (is_metaconsole() === true
+ && ($groupsBy['group_by'] === 'agent'
+ || $groupsBy['group_by'] === 'module')
+ ) {
+ foreach ($names_search as $server => $names) {
+ foreach ($names as $id => $name) {
+ $name = $names_server[$server].' » '.$name;
+ if (isset($array_data[$server][$id]) === true) {
+ $result[$period][$server.'|'.$id] = $array_data[$server][$id];
+ $result[$period][$server.'|'.$id][$groupsBy['group_by']] = $name;
+ } else {
+ if ($only_data === false) {
+ $clone[$groupsBy['group_by']] = $name;
+ $result[$period][$server.'|'.$id] = $clone;
+ }
+ }
+ }
+ }
+ } else {
+ foreach ($names_search as $id => $name) {
+ if (isset($array_data[$id]) === true) {
+ $result[$period][$id] = $array_data[$id];
+ $result[$period][$id][$groupsBy['group_by']] = $name;
+ } else {
+ if ($only_data === false) {
+ $clone[$groupsBy['group_by']] = $name;
+ $result[$period][$id] = $clone;
+ }
+ }
+ }
+ }
+ }
+ } else {
+ $period_lapse = (int) $groupsBy['lapse'];
+ foreach ($intervals as $interval) {
+ $start_interval = $interval;
+ $end_interval = ($interval + $period_lapse);
+
+ if ($only_data === false) {
+ if (is_metaconsole() === true
+ && ($groupsBy['group_by'] === 'agent'
+ || $groupsBy['group_by'] === 'module')
+ ) {
+ foreach ($names_search as $server => $names) {
+ foreach ($names as $id => $name) {
+ $result_name = $names_server[$server].' » '.$name;
+ $result[$start_interval][$server.'|'.$id] = $clone;
+ $result[$start_interval][$server.'|'.$id][$groupsBy['group_by']] = $result_name;
+ }
+ }
+ } else {
+ foreach ($names_search as $id => $name) {
+ $result[$start_interval][$id] = $clone;
+ $result[$start_interval][$id][$groupsBy['group_by']] = $name;
+ }
+ }
+ } else {
+ foreach ($data as $period => $array_data) {
+ if (is_metaconsole() === true
+ && ($groupsBy['group_by'] === 'agent'
+ || $groupsBy['group_by'] === 'module')
+ ) {
+ foreach ($array_data as $server => $datas) {
+ foreach ($datas as $id_data => $value_data) {
+ $name = $names_server[$server].' » '.$names_search[$server][$id_data];
+ $result[$start_interval][$server.'|'.$id_data] = $clone;
+ $result[$start_interval][$server.'|'.$id_data][$groupsBy['group_by']] = $name;
+ }
+ }
+ } else {
+ foreach ($array_data as $id_data => $value_data) {
+ $name = $names_search[$id_data];
+ $result[$start_interval][$id_data] = $clone;
+ $result[$start_interval][$id_data][$groupsBy['group_by']] = $name;
+ }
+ }
+ }
+ }
+
+ foreach ($data as $period => $array_data) {
+ $period_time = (int) $period;
+ if ($start_interval < $period_time && $period_time <= $end_interval) {
+ if (is_metaconsole() === true
+ && ($groupsBy['group_by'] === 'agent'
+ || $groupsBy['group_by'] === 'module')
+ ) {
+ foreach ($array_data as $server => $datas) {
+ foreach ($datas as $id_data => $value_data) {
+ foreach ($value_data as $key_data => $v) {
+ if ($key_data !== $groupsBy['group_by']) {
+ if (isset($result[$start_interval][$server.'|'.$id_data][$key_data])) {
+ $result[$start_interval][$server.'|'.$id_data][$key_data] += $v;
+ } else {
+ $result[$start_interval][$server.'|'.$id_data][$key_data] = $v;
+ }
+ }
+ }
+ }
+ }
+ } else {
+ foreach ($array_data as $id_data => $value_data) {
+ foreach ($value_data as $key_data => $v) {
+ if ($key_data !== $groupsBy['group_by']) {
+ if (isset($result[$start_interval][$id_data][$key_data])) {
+ $result[$start_interval][$id_data][$key_data] += $v;
+ } else {
+ $result[$start_interval][$id_data][$key_data] = $v;
+ }
+ }
+ }
+ }
+ }
+
+ unset($data[$period]);
+ }
+ }
+ }
+ }
+ }
+
+ $result['data'] = $result;
+
+ if ($total === true) {
+ $total_values = [];
+ foreach ($data_query as $key => $array_data) {
+ foreach ($array_data as $key_value => $v) {
+ $total_values[$key_value] = ($total_values[$key_value] + $v);
+ }
+ }
+
+ if (is_metaconsole() === true
+ && ($groupsBy['group_by'] === 'agent'
+ || $groupsBy['group_by'] === 'module')
+ ) {
+ unset($total_values['server']);
+ }
+
+ unset($total_values['Period']);
+ $result['summary']['total'] = $total_values;
+ $result['summary']['total'][$groupsBy['group_by']] = __('Total');
+ }
+
+ return $result;
+}
+
+
+/**
+ * Get the templates names of an agent.
+ *
+ * @param array $array_ids Templates ids.
+ *
+ * @return array Id => name.
+ */
+function alerts_get_templates_name_array($array_ids)
+{
+ if (is_array($array_ids) === false || empty($array_ids) === true) {
+ return [];
+ }
+
+ $sql = sprintf(
+ 'SELECT id, `name`
+ FROM talert_templates
+ WHERE id IN (%s)',
+ implode(',', $array_ids)
+ );
+
+ $result = db_get_all_rows_sql($sql);
+
+ if ($result === false) {
+ $result = [];
+ }
+
+ $result = array_reduce(
+ $result,
+ function ($carry, $item) {
+ $carry[$item['id']] = $item['name'];
+ return $carry;
+ },
+ []
+ );
+
+ return $result;
+}
diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php
index a4c21d3bc6..34bb53ef26 100644
--- a/pandora_console/include/functions_db.php
+++ b/pandora_console/include/functions_db.php
@@ -1377,42 +1377,56 @@ function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache
break;
}
- if ($rc !== false) {
- if (enterprise_hook('is_metaconsole') === true
- && isset($config['centralized_management']) === true
- && (bool) $config['centralized_management'] === true
- && $dbconnection === ''
- ) {
- $errors = null;
- try {
- // Synchronize changes to nodes if needed.
- $sync = new Synchronizer();
- if ($sync !== null) {
- if ($sync->queue($sql) === false) {
- // Launch events per failed query.
- $errors = $sync->getLatestErrors();
- if ($errors !== null) {
- $errors = join(', ', $errors);
- } else {
- $errors = '';
- }
- }
- }
- } catch (\Exception $e) {
- $errors = $e->getMessage();
- }
-
- if ($errors !== null) {
- // TODO: Generate pandora event.
- error_log($errors);
- }
- }
- }
+ db_sync($dbconnection, $sql, $rc);
return $rc;
}
+/**
+ * Propagate to nodes.
+ *
+ * @param mixed $dbconnection Dbconnection.
+ * @param mixed $sql Sql.
+ * @param mixed $rc Rc.
+ *
+ * @return void
+ */
+function db_sync($dbconnection, $sql, $rc)
+{
+ global $config;
+ if (enterprise_hook('is_metaconsole') === true
+ && isset($config['centralized_management']) === true
+ && (bool) $config['centralized_management'] === true
+ && $dbconnection === ''
+ ) {
+ $errors = null;
+ try {
+ // Synchronize changes to nodes if needed.
+ $sync = new Synchronizer();
+ if ($sync !== null) {
+ if ($sync->queue($sql, $rc) === false) {
+ // Launch events per failed query.
+ $errors = $sync->getLatestErrors();
+ if ($errors !== null) {
+ $errors = join(', ', $errors);
+ } else {
+ $errors = '';
+ }
+ }
+ }
+ } catch (\Exception $e) {
+ $errors = $e->getMessage();
+ }
+
+ if ($errors !== null) {
+ // TODO: Generate pandora event.
+ error_log($errors);
+ }
+ }
+}
+
+
/**
* Get all the rows in a table of the database.
*
@@ -1808,20 +1822,20 @@ function db_process_sql_delete($table, $where, $where_join='AND')
function db_process_sql_begin()
{
global $config;
+ $null = null;
switch ($config['dbtype']) {
- case 'mysql':
- return mysql_db_process_sql_begin();
-
- break;
case 'postgresql':
return postgresql_db_process_sql_begin();
- break;
case 'oracle':
return oracle_db_process_sql_begin();
- break;
+ default:
+ case 'mysql':
+ db_process_sql('SET AUTOCOMMIT = 0', 'affected_rows', '', false, $null, false);
+ db_process_sql('START TRANSACTION', 'affected_rows', '', false, $null, false);
+ break;
}
}
@@ -1832,20 +1846,20 @@ function db_process_sql_begin()
function db_process_sql_commit()
{
global $config;
+ $null = null;
switch ($config['dbtype']) {
- case 'mysql':
- return mysql_db_process_sql_commit();
-
- break;
case 'postgresql':
return postgresql_db_process_sql_commit();
- break;
case 'oracle':
return oracle_db_process_sql_commit();
- break;
+ default:
+ case 'mysql':
+ db_process_sql('COMMIT', 'affected_rows', '', false, $null, false);
+ db_process_sql('SET AUTOCOMMIT = 1', 'affected_rows', '', false, $null, false);
+ break;
}
}
@@ -1856,20 +1870,20 @@ function db_process_sql_commit()
function db_process_sql_rollback()
{
global $config;
+ $null = null;
switch ($config['dbtype']) {
- case 'mysql':
- return mysql_db_process_sql_rollback();
-
- break;
case 'postgresql':
return postgresql_db_process_sql_rollback();
- break;
case 'oracle':
return oracle_db_process_sql_rollback();
- break;
+ default:
+ case 'mysql':
+ db_process_sql('ROLLBACK', 'affected_rows', '', false, $null, false);
+ db_process_sql('SET AUTOCOMMIT = 1', 'affected_rows', '', false, $null, false);
+ break;
}
}
@@ -1889,6 +1903,7 @@ function db_print_database_debug()
echo ''.__('Database debug').'
';
+ $table = new stdClass();
$table->id = 'database_debug';
$table->cellpadding = '0';
$table->width = '95%';
@@ -1946,18 +1961,15 @@ function db_get_last_error()
global $config;
switch ($config['dbtype']) {
- case 'mysql':
- return mysql_db_get_last_error();
-
- break;
case 'postgresql':
return postgresql_db_get_last_error();
- break;
case 'oracle':
return oracle_db_get_last_error();
- break;
+ case 'mysql':
+ default:
+ return mysql_db_get_last_error();
}
}
@@ -1975,18 +1987,15 @@ function db_get_type_field_table($table, $field)
global $config;
switch ($config['dbtype']) {
- case 'mysql':
- return mysql_db_get_type_field_table($table, $field);
-
- break;
case 'postgresql':
return postgresql_db_get_type_field_table($table, $field);
- break;
case 'oracle':
return oracle_db_get_type_field_table($table, $field);
- break;
+ case 'mysql':
+ default:
+ return mysql_db_get_type_field_table($table, $field);
}
}
diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php
index 06d56df4ed..ad17a5ad99 100644
--- a/pandora_console/include/functions_html.php
+++ b/pandora_console/include/functions_html.php
@@ -729,7 +729,8 @@ function html_print_select(
$required=false,
$truncate_size=false,
$select2_enable=true,
- $multiple_select2=false
+ $select2_multiple_enable=false,
+ $select2_multiple_enable_all=false
) {
$output = "\n";
@@ -791,6 +792,12 @@ function html_print_select(
$required = 'required';
}
+ if ($select2_multiple_enable === true
+ && $select2_multiple_enable_all === true
+ ) {
+ $output .= '';
+ }
+
$output .= '
';
if ($nothing !== false) {
@@ -890,6 +897,24 @@ function html_print_select(
}
$output .= ' ';
+
+ if ($select2_multiple_enable === true
+ && $select2_multiple_enable_all === true
+ ) {
+ $output .= '
';
+ $output .= ''.__('All').' ';
+ $output .= html_print_checkbox_switch(
+ $id.'-check-all',
+ 1,
+ false,
+ true,
+ $disabled,
+ 'checkMultipleAll('.$id.')'
+ );
+ $output .= '
';
+ $output .= '
';
+ }
+
if ($modal && !enterprise_installed()) {
$output .= "
@@ -901,8 +926,7 @@ function html_print_select(
$select2 = 'select2_dark.min';
}
- // Note that multiple_select2 is introduced as a workaround to overcome the pointless limitation of preventing "multiple" select inputs from using select2 library without affecting the existing calls to this function.
- if ($multiple === false && $select2_enable === true || $multiple_select2 === true) {
+ if (($multiple === false || $select2_multiple_enable === true) && $select2_enable === true) {
if (is_ajax()) {
$output .= '';
}
diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php
index eaa44fe741..4f27b17896 100755
--- a/pandora_console/include/functions_modules.php
+++ b/pandora_console/include/functions_modules.php
@@ -26,6 +26,8 @@
* ============================================================================
*/
+use PandoraFMS\Enterprise\Metaconsole\Node;
+
// Begin.
require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_users.php';
@@ -1435,6 +1437,90 @@ function modules_get_agentmodule_name($id_agente_modulo)
}
+/**
+ * Get the module names of an agent module.
+ *
+ * @param array $array_ids Agents module ids.
+ *
+ * @return array Id => name.
+ */
+function modules_get_agentmodule_name_array($array_ids)
+{
+ if (is_array($array_ids) === false || empty($array_ids) === true) {
+ return [];
+ }
+
+ if ((bool) is_metaconsole() === true) {
+ $modules = array_reduce(
+ $array_ids,
+ function ($carry, $item) {
+ $explode = explode('|', $item);
+
+ $carry[$explode[0]][] = $explode[1];
+ return $carry;
+ }
+ );
+
+ $result = [];
+ foreach ($modules as $tserver => $id_modules) {
+ if (metaconsole_connect(null, $tserver) == NOERR) {
+ $result_modules = modules_get_agentmodule_name_array_data(
+ $id_modules
+ );
+
+ $result[$tserver] = $result_modules;
+ metaconsole_restore_db();
+ }
+ }
+ } else {
+ $result = modules_get_agentmodule_name_array_data(
+ $array_ids
+ );
+ }
+
+ return $result;
+}
+
+
+/**
+ * Data names.
+ *
+ * @param array $array_ids Ids.
+ *
+ * @return array
+ */
+function modules_get_agentmodule_name_array_data($array_ids)
+{
+ if (is_array($array_ids) === false || empty($array_ids) === true) {
+ return [];
+ }
+
+ $sql = sprintf(
+ 'SELECT id_agente_modulo as id, nombre as `name`
+ FROM tagente_modulo
+ WHERE id_agente_modulo IN (%s)',
+ implode(',', $array_ids)
+ );
+
+ $result = db_get_all_rows_sql($sql);
+
+ if ($result === false) {
+ $result = [];
+ }
+
+ $result = array_reduce(
+ $result,
+ function ($carry, $item) {
+ $carry[$item['id']] = $item['name'];
+ return $carry;
+ },
+ []
+ );
+
+ return $result;
+}
+
+
/**
* Get the module descripcion of an agent module.
*
@@ -3469,32 +3555,271 @@ function modules_get_agentmodule_mininterval_no_async($id_agent)
}
-function get_same_modules($agents, $modules)
+function get_modules_agents($id_module_group, $id_agents, $selection, $select_mode=true)
{
- $modules_to_report = [];
- if ($modules != '') {
- foreach ($modules as $m) {
- $module_name = modules_get_agentmodule_name($m);
- foreach ($agents as $a) {
- $module_in_agent = db_get_value_filter(
- 'id_agente_modulo',
- 'tagente_modulo',
- [
- 'id_agente' => $a,
- 'nombre' => $module_name,
- ]
- );
- if ($module_in_agent) {
- $modules_to_report[] = $module_in_agent;
+ if ((bool) is_metaconsole() === true) {
+ if ($select_mode === true) {
+ $agents = array_reduce(
+ $id_agents,
+ function ($carry, $item) {
+ $explode = explode('|', $item);
+
+ $carry[$explode[0]][] = $explode[1];
+ return $carry;
}
+ );
+ } else {
+ if (count($id_agents) > 0) {
+ $rows = db_get_all_rows_sql(
+ sprintf(
+ 'SELECT `id_agente`, `id_tagente`, `id_tmetaconsole_setup`
+ FROM `tmetaconsole_agent`
+ WHERE `id_agente` IN (%s)',
+ implode(',', $id_agents)
+ )
+ );
+ } else {
+ $rows = [];
+ }
+
+ $agents = array_reduce(
+ $rows,
+ function ($carry, $item) {
+ if ($carry[$item['id_tmetaconsole_setup']] === null) {
+ $carry[$item['id_tmetaconsole_setup']] = [];
+ }
+
+ $carry[$item['id_tmetaconsole_setup']][] = $item['id_tagente'];
+ return $carry;
+ },
+ []
+ );
+ }
+
+ $modules = [];
+ foreach ($agents as $tserver => $id_agents) {
+ if (metaconsole_connect(null, $tserver) == NOERR) {
+ $modules[$tserver] = select_modules_for_agent_group(
+ $id_module_group,
+ $id_agents,
+ $selection,
+ false,
+ false,
+ true
+ );
+
+ metaconsole_restore_db();
}
}
+
+ if (!$selection) {
+ // Common modules.
+ $final_modules = [];
+ $nodes_consulted = count($modules);
+
+ foreach ($modules as $tserver => $mods) {
+ foreach ($mods as $module) {
+ if ($final_modules[$module['nombre']] === null) {
+ $final_modules[$module['nombre']] = 0;
+ }
+
+ $final_modules[$module['nombre']]++;
+ }
+ }
+
+ $modules = [];
+ foreach ($final_modules as $module_name => $occurrences) {
+ if ($occurrences === $nodes_consulted) {
+ // Module already present in ALL nodes.
+ $modules[] = [
+ 'id_agente_modulo' => $module_name,
+ 'nombre' => $module_name,
+ ];
+ }
+ }
+ } else {
+ // All modules.
+ $return = [];
+ $nodes = [];
+ foreach ($agents as $tserver => $id_agents) {
+ try {
+ $nodes[$tserver] = new Node($tserver);
+ } catch (Exception $e) {
+ hd($e);
+ }
+
+ $return = array_reduce(
+ $modules[$tserver],
+ function ($carry, $item) use ($tserver, $nodes) {
+ $t = [];
+ foreach ($item as $k => $v) {
+ $t[$k] = $v;
+ }
+
+ $t['id_node'] = $tserver;
+ if ($nodes[$tserver] !== null) {
+ $t['nombre'] = io_safe_output(
+ $nodes[$tserver]->server_name().' » '.$t['nombre']
+ );
+ }
+
+ $carry[] = $t;
+ return $carry;
+ },
+ $return
+ );
+ }
+
+ $modules = $return;
+ }
+
+ $modules = array_reduce(
+ $modules,
+ function ($carry, $item) {
+ $carry[$item['id_node'].'|'.$item['id_agente_modulo']] = $item['nombre'];
+ return $carry;
+ },
+ []
+ );
+ } else {
+ $modules = select_modules_for_agent_group(
+ $id_module_group,
+ $id_agents,
+ $selection,
+ false
+ );
}
- $modules_to_report = array_merge($modules_to_report, $modules);
+ return $modules;
+}
+
+
+/**
+ * List all modules in agents selection.
+ *
+ * @param array $agents Agents ids array.
+ * @param array $modules Modules ids array.
+ *
+ * @return array
+ */
+function get_same_modules($agents, $modules)
+{
+ if (is_array($agents) === false || empty($agents) === true) {
+ return [];
+ }
+
+ $name_modules = modules_get_agentmodule_name_array_data(
+ array_values($modules)
+ );
+
+ $sql = sprintf(
+ 'SELECT id_agente_modulo as id,
+ nombre as `name`
+ FROM tagente_modulo
+ WHERE id_agente IN (%s)',
+ implode(',', array_values($agents))
+ );
+
+ $all = db_get_all_rows_sql($sql);
+
+ if ($all === false) {
+ $all = [];
+ }
+
+ $all = array_reduce(
+ $all,
+ function ($carry, $item) use ($name_modules) {
+ if (array_search($item['name'], $name_modules)) {
+ $carry[$item['id']] = $item['id'];
+ }
+
+ return $carry;
+ },
+ []
+ );
+
+ $modules_to_report = array_merge($all, $modules);
$modules_to_report = array_unique($modules_to_report);
- return $modules_to_report;
+ return $all;
+}
+
+
+/**
+ * List all modules in agents selection to metaconsole or node.
+ *
+ * @param array $agents Agents ids array.
+ * @param array $modules Modules ids array.
+ *
+ * @return array List modules [server|id_module, ...].
+ */
+function get_same_modules_all($agents, $modules, $select_mode=true)
+{
+ if (is_array($agents) === false || empty($agents) === true) {
+ return [];
+ }
+
+ if (is_metaconsole() === true) {
+ $modules = array_reduce(
+ $modules,
+ function ($carry, $item) {
+ $explode = explode('|', $item);
+
+ $carry[$explode[0]][] = $explode[1];
+ return $carry;
+ }
+ );
+
+ if ($select_mode === true) {
+ $agents = array_reduce(
+ $agents,
+ function ($carry, $item) {
+ $explode = explode('|', $item);
+
+ $carry[$explode[0]][] = $explode[1];
+ return $carry;
+ }
+ );
+ } else {
+ $rows = db_get_all_rows_sql(
+ sprintf(
+ 'SELECT `id_agente`, `id_tagente`, `id_tmetaconsole_setup`
+ FROM `tmetaconsole_agent`
+ WHERE `id_agente` IN (%s)',
+ implode(',', $agents)
+ )
+ );
+
+ $agents = array_reduce(
+ $rows,
+ function ($carry, $item) {
+ if ($carry[$item['id_tmetaconsole_setup']] === null) {
+ $carry[$item['id_tmetaconsole_setup']] = [];
+ }
+
+ $carry[$item['id_tmetaconsole_setup']][] = $item['id_tagente'];
+ return $carry;
+ },
+ []
+ );
+ }
+
+ $result = [];
+ foreach ($agents as $tserver => $id_agents) {
+ if (metaconsole_connect(null, $tserver) == NOERR) {
+ $same_modules = get_same_modules($id_agents, $modules[$tserver]);
+ foreach ($same_modules as $id_module) {
+ $result[] = $tserver.'|'.$id_module;
+ }
+
+ metaconsole_restore_db();
+ }
+ }
+ } else {
+ $result = get_same_modules($agents, $modules);
+ }
+
+ return $result;
}
diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php
index 5f90f130c8..231684c90a 100755
--- a/pandora_console/include/functions_reporting.php
+++ b/pandora_console/include/functions_reporting.php
@@ -734,6 +734,13 @@ function reporting_make_reporting_data(
);
break;
+ case 'alert_report_actions':
+ $report['contents'][] = reporting_alert_report_actions(
+ $report,
+ $content
+ );
+ break;
+
case 'agents_inventory':
$report['contents'][] = reporting_agents_inventory(
$report,
@@ -2658,15 +2665,119 @@ function reporting_inventory($report, $content, $type)
}
+/**
+ * Build data for report alert actions.
+ *
+ * @param array $report Report info.
+ * @param array $content Content.
+ *
+ * @return array Result data.
+ */
+function reporting_alert_report_actions($report, $content)
+{
+ $return = [];
+
+ $return['type'] = 'alert_report_actions';
+ if (empty($content['name']) === true) {
+ $content['name'] = __('Alert actions');
+ }
+
+ $return['title'] = io_safe_output($content['name']);
+ $return['landscape'] = $content['landscape'];
+ $return['pagebreak'] = $content['pagebreak'];
+
+ $return['subtitle'] = __('Actions');
+ $return['description'] = io_safe_output($content['description']);
+ $return['date'] = reporting_get_date_text($report, $content);
+
+ $return['data'] = [];
+
+ $es = json_decode($content['external_source'], true);
+ if (isset($report['id_template']) === true
+ && empty($report['id_template']) === false
+ ) {
+ if (is_metaconsole() === true) {
+ $server_id = metaconsole_get_id_server($content['server_name']);
+ $modules = [$server_id.'|'.$content['id_agent_module']];
+ $agents = [$server_id.'|'.$content['id_agent']];
+ } else {
+ $modules = [$content['id_agent_module']];
+ $agents = [$content['id_agent']];
+ }
+ } else {
+ $modules = json_decode(
+ io_safe_output(base64_decode($es['module'])),
+ true
+ );
+ $agents = json_decode(
+ io_safe_output(base64_decode($es['id_agents'])),
+ true
+ );
+ }
+
+ $period = $content['period'];
+ $id_group = $content['id_group'];
+ $templates = $es['templates'];
+ $actions = $es['actions'];
+ $show_summary = $es['show_summary'];
+ $group_by = $es['group_by'];
+ $lapse = $content['lapse'];
+ $only_data = $es['only_data'];
+
+ $filters = [
+ 'group' => $id_group,
+ 'agents' => $agents,
+ 'modules' => $modules,
+ 'templates' => $templates,
+ 'actions' => $actions,
+ 'period' => $period,
+ 'show_summary' => (bool) $show_summary,
+ 'only_data' => (bool) $only_data,
+ ];
+
+ $groupsBy = [
+ 'group_by' => $group_by,
+ 'lapse' => $lapse,
+ ];
+
+ $return['filters'] = $filters;
+ $return['groupsBy'] = $groupsBy;
+
+ $return['data'] = alerts_get_alert_fired($filters, $groupsBy);
+
+ return reporting_check_structure_content($return);
+}
+
+
+/**
+ * Data report agent/module.
+ *
+ * @param array $report Report info.
+ * @param array $content Content info.
+ *
+ * @return array Structure Content.
+ */
function reporting_agent_module($report, $content)
{
global $config;
- $agents_and_modules = json_decode($content['external_source'], true);
- $agents = [];
- $agents = $agents_and_modules['id_agents'];
- $modules = $agents_and_modules['module'];
- $id_group = $content['id_group'];
- $id_module_group = $content['id_module_group'];
+ $external_source = json_decode(
+ $content['external_source'],
+ true
+ );
+
+ $agents = json_decode(
+ io_safe_output(
+ base64_decode($external_source['id_agents'])
+ ),
+ true
+ );
+
+ $modules = json_decode(
+ io_safe_output(
+ base64_decode($external_source['module'])
+ ),
+ true
+ );
$return['type'] = 'agent_module';
@@ -2700,7 +2811,9 @@ function reporting_agent_module($report, $content)
$cont = 0;
foreach ($modules as $modul_id) {
- $modules_by_name[$cont]['name'] = io_safe_output(modules_get_agentmodule_name($modul_id));
+ $modules_by_name[$cont]['name'] = io_safe_output(
+ modules_get_agentmodule_name($modul_id)
+ );
$modules_by_name[$cont]['id'] = $modul_id;
$cont++;
}
diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php
index d93848c3f1..7260843d29 100644
--- a/pandora_console/include/functions_reporting_html.php
+++ b/pandora_console/include/functions_reporting_html.php
@@ -377,6 +377,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
reporting_html_agent_module($table, $item);
break;
+ case 'alert_report_actions':
+ reporting_html_alert_report_actions($table, $item);
+ break;
+
case 'agents_inventory':
reporting_html_agents_inventory($table, $item);
break;
@@ -2729,6 +2733,94 @@ function reporting_html_group_configuration($table, $item, $pdf=0)
}
+/**
+ * Html output report alert actions
+ *
+ * @param object $table Table.
+ * @param array $item Data for draw report.
+ * @param integer $pdf PDF output.
+ *
+ * @return string Html output.
+ */
+function reporting_html_alert_report_actions($table, $item, $pdf=0)
+{
+ $data = $item['data'];
+ $groupsBy = $item['groupsBy'];
+
+ $output = '';
+ if (isset($data['data']) === true
+ && empty($data['data']) === false
+ ) {
+ foreach ($data['data'] as $period => $data_array) {
+ if (empty($period) === false) {
+ $output .= '';
+ $output .= __('From').' ';
+ $output .= date(
+ 'd-m-Y H:i:s',
+ $period
+ );
+ $output .= ' '.__('to').' ';
+ $output .= date('d-m-Y H:i:s', ($period + (int) $groupsBy['lapse']));
+ $output .= ' ';
+ }
+
+ $output .= get_alert_table($data_array);
+ }
+
+ if (isset($data['summary']) === true
+ && empty($data['summary']) === false
+ ) {
+ $output .= '';
+ $output .= __('Total summary');
+ $output .= ' ';
+
+ $output .= get_alert_table($data['summary']);
+ }
+ } else {
+ $output .= ui_print_empty_data(
+ __('No alerts fired'),
+ '',
+ true
+ );
+ }
+
+ if ($pdf === 0) {
+ $table->colspan['alert_report_action']['cell'] = 3;
+ $table->cellstyle['alert_report_action']['cell'] = 'text-align: center;';
+ $table->data['alert_report_action']['cell'] = $output;
+ } else {
+ return $output;
+ }
+
+}
+
+
+function get_alert_table($data)
+{
+ $table = new StdCLass();
+ $table->width = '100%';
+ $table->data = [];
+ $table->head = [];
+ $table->headstyle = [];
+ $table->cellstyle = [];
+ $table->headstyle[0] = 'text-align:left;';
+
+ $head = reset($data);
+ foreach (array_reverse(array_keys($head)) as $name) {
+ $table->head[] = $name;
+ }
+
+ foreach ($data as $key => $params) {
+ $table->cellstyle[$key][0] = 'text-align:left;';
+ foreach (array_reverse($params) as $name => $value) {
+ $table->data[$key][] = $value;
+ }
+ }
+
+ return html_print_table($table, true);
+}
+
+
/**
* This type of report element will generate the interface graphs
* of all those devices that belong to the selected group.
diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php
index 09e3340e70..4460a34ae5 100755
--- a/pandora_console/include/functions_reports.php
+++ b/pandora_console/include/functions_reports.php
@@ -834,6 +834,7 @@ function reports_get_report_types($template=false, $not_editor=false)
'optgroup' => __('Alerts'),
'name' => __('Agent alert report '),
];
+
if (!$template) {
$types['alert_report_group'] = [
'optgroup' => __('Alerts'),
@@ -841,6 +842,11 @@ function reports_get_report_types($template=false, $not_editor=false)
];
}
+ $types['alert_report_actions'] = [
+ 'optgroup' => __('Alerts'),
+ 'name' => __('Actions alert report '),
+ ];
+
$types['event_report_module'] = [
'optgroup' => __('Events'),
'name' => __('Module event report'),
diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php
index 03ec3ee614..8e9fe01210 100755
--- a/pandora_console/include/functions_ui.php
+++ b/pandora_console/include/functions_ui.php
@@ -329,7 +329,7 @@ function ui_print_message($message, $class='', $attributes='', $return=false, $t
if (!$no_close_bool) {
// Use the no_meta parameter because this image is only in
// the base console.
- $output .= ''.html_print_image('images/blade.png', true, false, false, true).' ';
+ $output .= ''.html_print_image('images/blade.png', true, false, false, false).' ';
}
$output .= '
diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css
index 496f57ea1c..169e3918ce 100644
--- a/pandora_console/include/styles/pandora.css
+++ b/pandora_console/include/styles/pandora.css
@@ -8347,3 +8347,41 @@ div.stat-win-spinner img {
#license_error_msg_dialog {
min-height: 350px !important;
}
+
+.select2-container--default
+ .select2-selection--multiple
+ .select2-selection__rendered {
+ padding: 5px 10px 10px !important;
+ max-height: 120px;
+ overflow: auto !important;
+}
+
+.select2-container--default
+ .select2-selection--multiple
+ .select2-selection__choice {
+ background-color: #82b92e !important;
+ border: 1px solid #82b92e !important;
+ padding: 0.3em 0.6em !important;
+ color: #fff;
+ font-size: 1em;
+ display: flex;
+ flex-direction: row;
+ justify-content: flex-start;
+ align-items: center;
+ align-content: center;
+}
+
+.select2-container--default
+ .select2-selection--multiple
+ .select2-selection__choice__remove {
+ color: #fff !important;
+ font-size: 1.2em;
+ margin-right: 5px !important;
+}
+
+.h1-report-alert-actions {
+ text-transform: none;
+ text-align: left;
+ margin: 5px;
+ font-size: 12px;
+}
diff --git a/pandora_console/install.php b/pandora_console/install.php
index fa22b799d2..9409f2e16a 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -129,7 +129,7 @@
0) {
- $rows = db_get_all_rows_sql(
- sprintf(
- 'SELECT `id_agente`, `id_tagente`, `id_tmetaconsole_setup`
- FROM `tmetaconsole_agent`
- WHERE `id_agente` IN (%s)',
- implode(',', $id_agents)
- )
- );
- } else {
- $rows = [];
- }
-
- $agents = array_reduce(
- $rows,
- function ($carry, $item) {
- if ($carry[$item['id_tmetaconsole_setup']] === null) {
- $carry[$item['id_tmetaconsole_setup']] = [];
- }
-
- $carry[$item['id_tmetaconsole_setup']][] = $item['id_tagente'];
- return $carry;
- },
- []
- );
-
- $modules = [];
-
- foreach ($agents as $tserver => $id_agents) {
- if (metaconsole_connect(null, $tserver) == NOERR) {
- $modules[$tserver] = select_modules_for_agent_group(
- $id_group,
- $id_agents,
- $selection,
- false,
- false,
- true
- );
-
- metaconsole_restore_db();
- }
- }
-
-
- if (!$selection) {
- // Common modules.
- $final_modules = [];
- $nodes_consulted = count($modules);
-
- foreach ($modules as $tserver => $mods) {
- foreach ($mods as $module) {
- if ($final_modules[$module['nombre']] === null) {
- $final_modules[$module['nombre']] = 0;
- }
-
- $final_modules[$module['nombre']]++;
- }
- }
-
- $modules = [];
- foreach ($final_modules as $module_name => $occurrences) {
- if ($occurrences === $nodes_consulted) {
- // Module already present in ALL nodes.
- $modules[] = [
- 'id_agente_modulo' => $module_name,
- 'nombre' => $module_name,
- ];
- }
- }
- } else {
- // All modules.
- $return = [];
- $nodes = [];
- foreach ($agents as $tserver => $id_agents) {
- try {
- $nodes[$tserver] = new Node($tserver);
- } catch (Exception $e) {
- hd($e);
- }
-
- $return = array_reduce(
- $modules[$tserver],
- function ($carry, $item) use ($tserver, $nodes) {
- $t = [];
- foreach ($item as $k => $v) {
- $t[$k] = $v;
- }
-
- $t['id_node'] = $tserver;
- if ($nodes[$tserver] !== null) {
- $t['nombre'] = io_safe_output(
- $nodes[$tserver]->server_name().' » '.$t['nombre']
- );
- }
-
- $carry[] = $t;
- return $carry;
- },
- $return
- );
- }
-
- $modules = $return;
- }
-
- echo json_encode($modules);
- } else {
- select_modules_for_agent_group($id_group, $id_agents, $selection);
- }
+ $modules = get_modules_agents(
+ $id_group,
+ $id_agents,
+ $selection,
+ $select_mode
+ );
+ echo json_encode($modules);
+ return;
}
if ($filter_modules_group_json) {
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index 6243ccb98d..f007e25a12 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.758.1
-%define release 211209
+%define release 211210
# User and Group under which Apache is running
%define httpd_name httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index f609bb7ca0..80c78d72aa 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.758.1
-%define release 211209
+%define release 211210
# User and Group under which Apache is running
%define httpd_name httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index 68a1181434..8cc9321eb1 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.758.1
-%define release 211209
+%define release 211210
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2
diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql
index 258f9409f1..b1a1399734 100644
--- a/pandora_console/pandoradb.sql
+++ b/pandora_console/pandoradb.sql
@@ -4087,6 +4087,7 @@ CREATE TABLE IF NOT EXISTS `tsync_queue` (
`operation` text,
`table` text,
`error` MEDIUMTEXT,
+ `result` TEXT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index 40872eaf34..3e96bf368f 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
package: pandorafms-server
-Version: 7.0NG.758.1-211209
+Version: 7.0NG.758.1-211210
Architecture: all
Priority: optional
Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index 0faa851bb7..04e18363f4 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/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.758.1-211209"
+pandora_version="7.0NG.758.1-211210"
package_cpan=0
package_pandora=1
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index f5e63897b2..ee2bae798e 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.758.1";
-my $pandora_build = "211209";
+my $pandora_build = "211210";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index b3b4658af8..3cb04c7d09 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.758.1";
-my $pandora_build = "211209";
+my $pandora_build = "211210";
our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index b2c23967b4..fa361febce 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 7.0NG.758.1
-%define release 211209
+%define release 211210
Summary: Pandora FMS Server
Name: %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index c620bf046b..bee4d6e6af 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 7.0NG.758.1
-%define release 211209
+%define release 211210
Summary: Pandora FMS Server
Name: %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index a5113530fd..d4c119cc3c 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
# **********************************************************************
PI_VERSION="7.0NG.758.1"
-PI_BUILD="211209"
+PI_BUILD="211210"
MODE=$1
if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index 82d95ba626..0c25f4e03d 100755
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB;
# version: define current version
-my $version = "7.0NG.758.1 Build 211209";
+my $version = "7.0NG.758.1 Build 211210";
# Pandora server configuration
my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index 99eec58391..b1a59eac21 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
-my $version = "7.0NG.758.1 Build 211209";
+my $version = "7.0NG.758.1 Build 211210";
# save program name for logging
my $progname = basename($0);