Merge branch 'ent-5530-Mostrar-el-tiempo-en-que-un-elemento-se-ha-mantenido-en-un-estado' of https://brutus.artica.es:8081/artica/pandorafms into ent-5530-Mostrar-el-tiempo-en-que-un-elemento-se-ha-mantenido-en-un-estado
This commit is contained in:
commit
669122dbb6
|
@ -1680,6 +1680,10 @@ sub pandora_process_module ($$$$$$$$$;$) {
|
|||
|
||||
# Get new status
|
||||
my $new_status = get_module_status ($processed_data, $module, $module_type);
|
||||
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
|
||||
my $current_interval;
|
||||
|
@ -1747,6 +1751,9 @@ sub pandora_process_module ($$$$$$$$$;$) {
|
|||
generate_status_event ($pa_config, $processed_data, $agent, $module, $new_status, $status, $known_status, $dbh);
|
||||
$status = $new_status;
|
||||
|
||||
# Update the change of status timestamp.
|
||||
$last_status_change = $utimestamp;
|
||||
|
||||
# Update module status count.
|
||||
$mark_for_update = 1;
|
||||
|
||||
|
@ -1783,6 +1790,9 @@ sub pandora_process_module ($$$$$$$$$;$) {
|
|||
generate_status_event ($pa_config, $processed_data, $agent, $module, $new_status, $status, $known_status, $dbh);
|
||||
$status = $new_status;
|
||||
|
||||
# Update the change of status timestamp.
|
||||
$last_status_change = $utimestamp;
|
||||
|
||||
# Update module status count.
|
||||
$mark_for_update = 1;
|
||||
|
||||
|
@ -1809,6 +1819,9 @@ sub pandora_process_module ($$$$$$$$$;$) {
|
|||
generate_status_event ($pa_config, $processed_data, $agent, $module, 0, $status, $known_status, $dbh);
|
||||
$status = 0;
|
||||
|
||||
# Update the change of status timestamp.
|
||||
$last_status_change = $utimestamp;
|
||||
|
||||
# Update module status count.
|
||||
$mark_for_update = 1;
|
||||
}
|
||||
|
@ -1817,6 +1830,9 @@ sub pandora_process_module ($$$$$$$$$;$) {
|
|||
generate_status_event ($pa_config, $processed_data, $agent, $module, $known_status, $status, $known_status, $dbh);
|
||||
$status = $known_status;
|
||||
|
||||
# Update the change of status timestamp.
|
||||
$last_status_change = $utimestamp;
|
||||
|
||||
# reset counters because change status.
|
||||
$ff_normal = 0;
|
||||
$ff_critical = 0;
|
||||
|
@ -1834,11 +1850,12 @@ sub pandora_process_module ($$$$$$$$$;$) {
|
|||
status_changes = ?, utimestamp = ?, timestamp = ?,
|
||||
id_agente = ?, current_interval = ?, running_by = ?,
|
||||
last_execution_try = ?, last_try = ?, last_error = ?,
|
||||
ff_start_utimestamp = ?, ff_normal = ?, ff_warning = ?, ff_critical = ?
|
||||
ff_start_utimestamp = ?, ff_normal = ?, ff_warning = ?, ff_critical = ?,
|
||||
last_status_change = ?
|
||||
WHERE id_agente_modulo = ?', $processed_data, $status, $status, $new_status, $new_status, $status_changes,
|
||||
$current_utimestamp, $timestamp, $module->{'id_agente'}, $current_interval, $server_id,
|
||||
$utimestamp, ($save == 1) ? $timestamp : $agent_status->{'last_try'}, $last_error, $ff_start_utimestamp,
|
||||
$ff_normal, $ff_warning, $ff_critical, $module->{'id_agente_modulo'});
|
||||
$ff_normal, $ff_warning, $ff_critical, $last_status_change, $module->{'id_agente_modulo'});
|
||||
}
|
||||
|
||||
# Save module data. Async and log4x modules are not compressed.
|
||||
|
@ -5402,7 +5419,7 @@ sub pandora_module_unknown ($$) {
|
|||
}
|
||||
|
||||
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
|
||||
WHERE tagente.id_agente = tagente_estado.id_agente
|
||||
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
|
@ -5429,7 +5446,7 @@ sub pandora_module_unknown ($$) {
|
|||
|
||||
# Set the module state to normal
|
||||
logger ($pa_config, "Module " . $module->{'nombre'} . " is going to NORMAL", 10);
|
||||
db_do ($dbh, 'UPDATE tagente_estado SET last_status = 0, estado = 0, known_status = 0, last_known_status = 0 WHERE id_agente_estado = ?', $module->{'id_agente_estado'});
|
||||
db_do ($dbh, 'UPDATE tagente_estado SET last_status = 0, estado = 0, known_status = 0, last_known_status = 0, last_status_change = ? WHERE id_agente_estado = ?', time(), $module->{'id_agente_estado'});
|
||||
|
||||
# Get agent information
|
||||
my $agent = get_db_single_row ($dbh, 'SELECT *
|
||||
|
@ -5446,7 +5463,8 @@ sub pandora_module_unknown ($$) {
|
|||
|
||||
# Generate alerts
|
||||
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 {
|
||||
logger($pa_config, "Alerts inhibited for agent '" . $agent->{'nombre'} . "'.", 10);
|
||||
|
@ -5459,6 +5477,7 @@ sub pandora_module_unknown ($$) {
|
|||
# Replace macros
|
||||
my %macros = (
|
||||
_module_ => safe_output($module->{'nombre'}),
|
||||
_modulelaststatuschange_ => $module->{'last_status_change'},
|
||||
_data_ => 'N/A',
|
||||
);
|
||||
load_module_macros ($module->{'module_macros'}, \%macros);
|
||||
|
@ -5475,7 +5494,8 @@ sub pandora_module_unknown ($$) {
|
|||
# Set the module status to unknown (the module can already be unknown if unknown_updates is enabled).
|
||||
if ($module->{'estado'} != 3) {
|
||||
logger ($pa_config, "Module " . $module->{'nombre'} . " is going to UNKNOWN", 10);
|
||||
db_do ($dbh, 'UPDATE tagente_estado SET last_status = 3, estado = 3, last_unknown_update = ? WHERE id_agente_estado = ?', time(), $module->{'id_agente_estado'});
|
||||
my $utimestamp = time();
|
||||
db_do ($dbh, 'UPDATE tagente_estado SET last_status = 3, estado = 3, last_unknown_update = ?, last_status_change = ? WHERE id_agente_estado = ?', $utimestamp, $utimestamp, , $module->{'id_agente_estado'});
|
||||
}
|
||||
|
||||
# Get agent information
|
||||
|
@ -5490,7 +5510,8 @@ sub pandora_module_unknown ($$) {
|
|||
|
||||
# Generate alerts
|
||||
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 {
|
||||
logger($pa_config, "Alerts inhibited for agent '" . $agent->{'nombre'} . "'.", 10);
|
||||
|
@ -5528,6 +5549,7 @@ sub pandora_module_unknown ($$) {
|
|||
# Replace macros
|
||||
my %macros = (
|
||||
_module_ => safe_output($module->{'nombre'}),
|
||||
_modulelaststatuschange_ => $module->{'last_status_change'},
|
||||
);
|
||||
load_module_macros ($module->{'module_macros'}, \%macros);
|
||||
$description = subst_alert_macros ($description, \%macros, $pa_config, $dbh, $agent, $module);
|
||||
|
|
Loading…
Reference in New Issue