diff --git a/pandora_console/include/help/en/help_alert_config.php b/pandora_console/include/help/en/help_alert_config.php
index 2c8c251037..24082e6a74 100644
--- a/pandora_console/include/help/en/help_alert_config.php
+++ b/pandora_console/include/help/en/help_alert_config.php
@@ -35,6 +35,7 @@ Apart from the defined module macros, the following macros are also available:
_timestamp_ : Time when the alert was fired (yy-mm-dd hh:mm:ss).
_timezone_ : Timezone name that _timestamp_ represents in.
_data_ : Module data that caused the alert to fire.
+_prevdata_ : Module data previus the alert to fire.
_alert_description_ : Alert description.
_alert_threshold_ : Alert threshold.
_alert_times_fired_ : Number of times the alert has been fired.
diff --git a/pandora_console/include/help/en/help_alert_macros.php b/pandora_console/include/help/en/help_alert_macros.php
index 650722a8c8..6753e2c59a 100644
--- a/pandora_console/include/help/en/help_alert_macros.php
+++ b/pandora_console/include/help/en/help_alert_macros.php
@@ -29,6 +29,7 @@ Besides the defined module macros, the following macros are available:
_timestamp_: Time and date on which the alert was triggered (yy-mm-dd hh:mm:ss).
_timezone_: Timezone that is represented on _timestamp_.
_data_: Module data that caused the alert to fire.
+_prevdata_ : Module data previus the alert to fire.
_alert_description_: Alert description.
_alert_threshold_: Alert threshold.
_alert_times_fired_: Number of times the alert has been triggered.
diff --git a/pandora_console/include/help/es/help_alert_config.php b/pandora_console/include/help/es/help_alert_config.php
index 6218519489..9540e75b86 100644
--- a/pandora_console/include/help/es/help_alert_config.php
+++ b/pandora_console/include/help/es/help_alert_config.php
@@ -37,6 +37,7 @@ Además de las macros de módulo definidas, las siguientes macros están disponi
_timestamp_: Hora y fecha en que se disparó la alerta.
_timezone_: Area Nombre _timestamp_ que representa en.
_data_: Dato que hizo que la alerta se disparase.
+_prevdata_: Dato previo antes de disparase la alerta.
_alert_description_: Descripción de la alerta.
_alert_threshold_: Umbral de la alerta.
_alert_times_fired_: Número de veces que se ha disparado la alerta.
diff --git a/pandora_console/include/help/es/help_alert_macros.php b/pandora_console/include/help/es/help_alert_macros.php
index 6054b33f05..f4c8f476d9 100644
--- a/pandora_console/include/help/es/help_alert_macros.php
+++ b/pandora_console/include/help/es/help_alert_macros.php
@@ -29,6 +29,7 @@ Además de las macros de módulo definidas, las siguientes macros están disponi
_timestamp_: Hora y fecha en que se disparó la alerta.
_timezone_: Area Nombre _timestamp_ que representa en.
_data_: Dato que hizo que la alerta se disparase.
+_prevdata_: Dato previo antes de disparase la alerta.
_alert_description_: Descripción de la alerta.
_alert_threshold_: Umbral de la alerta.
_alert_times_fired_: Número de veces que se ha disparado la alerta.
diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm
index eed9b23e11..c36695e5d2 100644
--- a/pandora_server/lib/PandoraFMS/Core.pm
+++ b/pandora_server/lib/PandoraFMS/Core.pm
@@ -936,6 +936,7 @@ sub pandora_execute_action ($$$$$$$$$;$) {
_timestamp_ => (defined($timestamp)) ? $timestamp : strftime ("%Y-%m-%d %H:%M:%S", localtime()),
_timezone_ => strftime ("%Z", localtime()),
_data_ => $data,
+ _prevdata_ => undef,
_alert_name_ => $alert->{'name'},
_alert_description_ => $alert->{'description'},
_alert_threshold_ => $alert->{'time_threshold'},
@@ -3529,8 +3530,10 @@ sub on_demand_macro($$$$$$) {
return '' unless defined ($agent);
my $field_number = $1;
my $field_value = get_db_value($dbh, 'SELECT description FROM tagent_custom_data WHERE id_field=? AND id_agent=?', $field_number, $agent->{'id_agente'});
- return (defined($field_value)) ? $field_value : '';
-
+ return (defined($field_value)) ? $field_value : '';
+ } elsif ($macro eq '_prevdata_') {
+ return '' unless defined ($module);
+ my $field_value = get_db_value($dbh, 'SELECT datos FROM tagente_datos where id_agente_modulo = ? order by utimestamp desc limit 1 offset 1', $module->{'id_agente_modulo'});
}
}