mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 15:54:29 +02:00
Add a macro for the last status change.
This commit is contained in:
parent
4815c9c29b
commit
7f0ce1cbda
@ -1682,6 +1682,9 @@ sub pandora_process_module ($$$$$$$$$;$) {
|
|||||||
my $new_status = get_module_status ($processed_data, $module, $module_type);
|
my $new_status = get_module_status ($processed_data, $module, $module_type);
|
||||||
my $last_status_change = $agent_status->{'last_status_change'};
|
my $last_status_change = $agent_status->{'last_status_change'};
|
||||||
|
|
||||||
|
# Set the last status change macro. Even if its value changes later, whe want the original value.
|
||||||
|
$extra_macros->{'_modulelaststatuschange_'} = $last_status_change;
|
||||||
|
|
||||||
# Calculate the current interval
|
# Calculate the current interval
|
||||||
my $current_interval;
|
my $current_interval;
|
||||||
if (defined ($module->{'cron_interval'}) && $module->{'cron_interval'} ne '' && $module->{'cron_interval'} ne '* * * * *') {
|
if (defined ($module->{'cron_interval'}) && $module->{'cron_interval'} ne '' && $module->{'cron_interval'} ne '* * * * *') {
|
||||||
@ -5416,7 +5419,7 @@ sub pandora_module_unknown ($$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my @modules = get_db_rows ($dbh, 'SELECT tagente_modulo.*,
|
my @modules = get_db_rows ($dbh, 'SELECT tagente_modulo.*,
|
||||||
tagente_estado.id_agente_estado, tagente_estado.estado
|
tagente_estado.id_agente_estado, tagente_estado.estado, tagente_estado.last_status_change
|
||||||
FROM tagente_modulo, tagente_estado, tagente
|
FROM tagente_modulo, tagente_estado, tagente
|
||||||
WHERE tagente.id_agente = tagente_estado.id_agente
|
WHERE tagente.id_agente = tagente_estado.id_agente
|
||||||
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||||
@ -5460,7 +5463,8 @@ sub pandora_module_unknown ($$) {
|
|||||||
|
|
||||||
# Generate alerts
|
# Generate alerts
|
||||||
if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0 && pandora_cps_enabled($agent, $module) == 0) {
|
if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0 && pandora_cps_enabled($agent, $module) == 0) {
|
||||||
pandora_generate_alerts ($pa_config, 0, 3, $agent, $module, time (), $dbh, undef, undef, 0, 'unknown');
|
my $extra_macros = { _modulelaststatuschange_ => $module->{'last_status_change'}};
|
||||||
|
pandora_generate_alerts ($pa_config, 0, 3, $agent, $module, time (), $dbh, $extra_macros, undef, 0, 'unknown');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger($pa_config, "Alerts inhibited for agent '" . $agent->{'nombre'} . "'.", 10);
|
logger($pa_config, "Alerts inhibited for agent '" . $agent->{'nombre'} . "'.", 10);
|
||||||
@ -5473,6 +5477,7 @@ sub pandora_module_unknown ($$) {
|
|||||||
# Replace macros
|
# Replace macros
|
||||||
my %macros = (
|
my %macros = (
|
||||||
_module_ => safe_output($module->{'nombre'}),
|
_module_ => safe_output($module->{'nombre'}),
|
||||||
|
_modulelaststatuschange_ => $module->{'last_status_change'},
|
||||||
_data_ => 'N/A',
|
_data_ => 'N/A',
|
||||||
);
|
);
|
||||||
load_module_macros ($module->{'module_macros'}, \%macros);
|
load_module_macros ($module->{'module_macros'}, \%macros);
|
||||||
@ -5505,7 +5510,8 @@ sub pandora_module_unknown ($$) {
|
|||||||
|
|
||||||
# Generate alerts
|
# Generate alerts
|
||||||
if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0 && pandora_cps_enabled($agent, $module) == 0) {
|
if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0 && pandora_cps_enabled($agent, $module) == 0) {
|
||||||
pandora_generate_alerts ($pa_config, 0, 3, $agent, $module, time (), $dbh, undef, undef, 0, 'unknown');
|
my $extra_macros = { _modulelaststatuschange_ => $module->{'last_status_change'}};
|
||||||
|
pandora_generate_alerts ($pa_config, 0, 3, $agent, $module, time (), $dbh, $extra_macros, undef, 0, 'unknown');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger($pa_config, "Alerts inhibited for agent '" . $agent->{'nombre'} . "'.", 10);
|
logger($pa_config, "Alerts inhibited for agent '" . $agent->{'nombre'} . "'.", 10);
|
||||||
@ -5543,6 +5549,7 @@ sub pandora_module_unknown ($$) {
|
|||||||
# Replace macros
|
# Replace macros
|
||||||
my %macros = (
|
my %macros = (
|
||||||
_module_ => safe_output($module->{'nombre'}),
|
_module_ => safe_output($module->{'nombre'}),
|
||||||
|
_modulelaststatuschange_ => $module->{'last_status_change'},
|
||||||
);
|
);
|
||||||
load_module_macros ($module->{'module_macros'}, \%macros);
|
load_module_macros ($module->{'module_macros'}, \%macros);
|
||||||
$description = subst_alert_macros ($description, \%macros, $pa_config, $dbh, $agent, $module);
|
$description = subst_alert_macros ($description, \%macros, $pa_config, $dbh, $agent, $module);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user